2 fdbb3c73 2025-06-03 xs # shellcheck disable=SC1091
8 fdbb3c73 2025-06-03 xs state_uname() {
16 fdbb3c73 2025-06-03 xs state_mount() {
24 fdbb3c73 2025-06-03 xs state_hostname() {
28 fdbb3c73 2025-06-03 xs install_root_profile() {
29 fdbb3c73 2025-06-03 xs groupinstall -o root:wheel -m 644 "root.profile.$(uname)" /root/.profile
32 fdbb3c73 2025-06-03 xs install_motd() {
33 fdbb3c73 2025-06-03 xs motd_content="Welcome on $(nodename)"
34 fdbb3c73 2025-06-03 xs case $(uname) in
36 fdbb3c73 2025-06-03 xs printf %s\\n "$motd_content" >motd
37 fdbb3c73 2025-06-03 xs install -o root:wheel -m 644 motd /etc/motd
40 fdbb3c73 2025-06-03 xs printf %s\\n "$motd_content" >motd.template
41 fdbb3c73 2025-06-03 xs install -o root:wheel -m 644 motd.template /etc && service motd restart
46 fdbb3c73 2025-06-03 xs install_ssh_authorized_keys() {
47 fdbb3c73 2025-06-03 xs for file in "$(nodedir)"/ssh/authorized_keys_*; do
48 fdbb3c73 2025-06-03 xs node "$file" || {
49 fdbb3c73 2025-06-03 xs error "missing authorized_keys file in $(nodedir)/ssh/"
52 fdbb3c73 2025-06-03 xs user=${file##*_}
53 fdbb3c73 2025-06-03 xs id -u "$user" >/dev/null || return 1
54 fdbb3c73 2025-06-03 xs home=$(getent passwd "$user" | awk -F: '{ print $6 }')
55 fdbb3c73 2025-06-03 xs sshdir=$home/.ssh
56 fdbb3c73 2025-06-03 xs mkdir -p "$sshdir"
57 fdbb3c73 2025-06-03 xs chmod 700 "$sshdir"
58 fdbb3c73 2025-06-03 xs install -m 600 -o "$(id -u "$user"):$(id -g "$user")" "$file" "$sshdir/authorized_keys"
59 fdbb3c73 2025-06-03 xs chown -R "$(id -u "$user"):$(id -g "$user")" "$sshdir"