Working on the init script for setting up the remote backup server

This commit is contained in:
Daniel Flanagan 2020-11-07 21:56:10 -06:00
parent 1bbdf01a2e
commit aa2dda3bf7
Signed by: lytedev
GPG Key ID: 5B2020A0F9921EF4
1 changed files with 24 additions and 5 deletions

View File

@ -1,5 +1,8 @@
#!/usr/bin/env sh
head /etc/os-release -n 1 | grep 'NixOS$'; test $? -eq 1; is_nixos=$?
head /etc/os-release -n 1 | grep 'Arch Linux'; test $? -eq 1; is_arch_linux=$?
set -e
# NOTE: run this from inside a Linux installation, not from the live USB/CD
@ -63,11 +66,28 @@ setup_dotfiles() {
./bin/setup-dotfiles
}
distro_specific_root_setup() {
if test $is_nixos -eq 1 then
symlink_nixos "$root_home$dotfiles/env/nix/"
add_unstable_channel
nixos-rebuild switch
elif test $is_arch_linux -eq 1
# TODO: install any necessary packages for remaining setup portion
fi
}
distro_specific_user_setup() {
if test $is_nixos -eq 1 then
FUNC=$(declare -f symlink_nixos)
sudo sh -c "$FUNC; symlink_nixos \"$daniel_home$dotfiles/env/nix/\""
elif test $is_arch_linux -eq 1
# TODO: setup all the things
fi
}
init_for_root() {
clone_dotfiles "$root_home$dotfiles"
symlink_nixos "$root_home$dotfiles/env/nix/"
add_unstable_channel
nixos-rebuild switch
distro_specific_setup
chown daniel:users "$daniel_home"
echo "Re-running as user daniel..."
sudo --user daniel "$root_home$dotfiles/init.sh"
@ -76,8 +96,7 @@ init_for_root() {
init_for_daniel() {
clone_dotfiles "$daniel_home$dotfiles"
generate_ssh_key
FUNC=$(declare -f symlink_nixos)
sudo sh -c "$FUNC; symlink_nixos \"$daniel_home$dotfiles/env/nix/\""
distro_specific_user_setup
setup_wallpaper
# TODO: setup ssh/gpg keys
# TODO: setup password store