1
0
mirror of https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud.git synced 2025-12-15 11:22:43 +03:00
Jake Buchholz Göktürk 1d2618dfd0 * imds is now an executable script
* numerous imds script enhancements, including -h/--help
* check imds for secondary ipv4 & ipvs via ifupdown-ng executor
* simplify shell source to things /etc/conf.d/ and /lib/tiny-cloud/
* move log function to /lib/tiny-cloud/common
2022-01-24 19:07:35 -08:00

35 lines
943 B
Bash

# Tiny Cloud - Main Phase Functions
# vim:set ts=4 et ft=sh:
source /etc/conf.d/tiny-cloud
source /lib/tiny-cloud/init-common
# ensure existence of output directories
[ ! -d "$TINY_CLOUD_LOGS" ] && mkdir -p "$TINY_CLOUD_LOGS"
[ ! -d "$TINY_CLOUD_VAR" ] && mkdir -p "$TINY_CLOUD_VAR"
set_hostname() {
local fqdn=$(imds @hostname)
local host="${fqdn%%\.*}"
echo "$host" > /etc/hostname
hostname -F /etc/hostname
echo -e "127.0.1.1\t$fqdn $host" >> /etc/hosts
}
set_ssh_keys() {
local user="$CLOUD_USER"
local pwent=$(getent passwd "$user")
local group=$(echo "$pwent" | cut -d: -f4)
local ssh_dir="$(echo "$pwent" | cut -d: -f6)/.ssh"
local keys_file="$ssh_dir/authorized_keys"
if [ ! -d "$ssh_dir" ]; then
mkdir -p "$ssh_dir"
chmod 700 "$ssh_dir"
fi
touch "$keys_file"
chmod 600 "$keys_file"
chown -R "$user:$group" "$ssh_dir"
imds @ssh-keys > "$keys_file"
}