rewrite scripts from xonsh to bash

This commit is contained in:
Andreas Zweili 2022-01-31 12:42:56 +01:00
parent 190b949585
commit fb3b288e3f
8 changed files with 61 additions and 61 deletions

View File

@ -1,3 +1,4 @@
#!/usr/bin/env bash
nix-shell '<home-manager>' -A install
rm ~/.config/nixpkgs/home.nix
ln -s $(pwd)/.nixos/flake.nix /home/$USER/.config/nixpkgs/flake.nix

12
scripts/install_new_vm.sh Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env bash
read -e -p "Enter a config you want to deploy: " flake
server="nixos@nixos.2li.local"
download_command="curl https://git.2li.ch/Nebucatnetzer/nixos/archive/master.tar.gz | tar xz"
install_command="cd ~/nixos && ./scripts/install_vm.sh $flake"
rsa_key="~/.ssh/id_rsa"
ssh-copy-id $server
ssh -i $rsa_key -t $server $download_command
ssh -i $rsa_key -t $server $install_command

View File

@ -1,12 +0,0 @@
#!/usr/bin/env xonsh
flake = input("Enter a config you want to deploy: ")
server = "nixos@nixos.2li.local"
download_command = "curl https://git.2li.ch/Nebucatnetzer/nixos/archive/master.tar.gz | tar xz"
install_command = "cd ~/nixos && ./scripts/install_vm.sh " + flake
rsa_key = "~/.ssh/id_rsa"
ssh-copy-id @(server)
ssh -i @(rsa_key) -t @(server) @(download_command)
ssh -i @(rsa_key) -t @(server) @(install_command)

24
scripts/remote_switch.sh Executable file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env bash
hosts = (
"nixos-management"
"grav"
"git"
"heimdall"
"mail"
"plex"
"proxy"
"rss-bridge"
"ttrss"
)
rsa_key="~/.nixos/secrets/ssh_keys/ansible/ansible.key"
$NIX_SSHOPTS="-t -i $rsa_key"
for host in $hosts do
fqdn="$host.2li.local"
echo $fqdn
nixos-rebuild switch --use-remote-sudo --build-host localhost --target-host $fqdn --flake ".#$host"
echo
echo
done

View File

@ -1,25 +0,0 @@
#!/usr/bin/env xonsh
hosts = [
"nixos-management",
"grav",
#"git",
"heimdall",
"mail",
"plex",
"proxy",
"rss-bridge",
"ttrss",
]
rsa_key = "~/.nixos/secrets/ssh_keys/ansible/ansible.key"
$NIX_SSHOPTS="-t -i " + rsa_key
for host in hosts:
fqdn = "{}.2li.local".format(host)
print(fqdn)
print("-" * len(fqdn))
nixos-rebuild switch --use-remote-sudo --build-host localhost --target-host @(fqdn) --flake @(".#" + host)
#echo @(fqdn) @(".#" + host)
print("")
print("")

View File

@ -1,4 +1,4 @@
#!/usr/bin/env xonsh
#!/usr/bin/env bash
find ./secrets -type d -print0 | xargs -0 chmod 700
find ./secrets -type f -print0 | xargs -0 chmod 600

23
scripts/update_all_systems.sh Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
hosts = (
"nixos-management"
"grav"
"heimdall"
"mail"
"plex"
"proxy"
"rss-bridge"
"ttrss"
)
update_command='tmux new -s updates "cd ~/.nixos && git pull && sudo nixos-rebuild -j auto switch || bash;"'
rsa_key="~/.nixos/secrets/ssh_keys/ansible/ansible.key"
for host in $hosts do
fqdn="$host.2li.local"
echo $fqdn
ssh -i $rsa_key -t $fqdn $update_command
echo
echo
done

View File

@ -1,23 +0,0 @@
#!/usr/bin/env xonsh
hosts = [
"nixos-management",
"grav",
"heimdall",
"mail",
"plex",
"proxy",
"rss-bridge",
"ttrss",
]
update_command = 'tmux new -s updates "cd ~/.nixos && git pull && sudo nixos-rebuild -j auto switch || bash;"'
rsa_key = "~/.nixos/secrets/ssh_keys/ansible/ansible.key"
for host in hosts:
fqdn = "{}.2li.local".format(host)
print(fqdn)
print("-" * len(fqdn))
ssh -i @(rsa_key) -t @(fqdn) @(update_command)
print("")
print("")