Compare commits

..

No commits in common. "4b58f65fa117628c90e0ee2f96fe44ba238b2df3" and "dd2ae9b7205495711fa486fd4ec9c87ff1cdedfd" have entirely different histories.

3 changed files with 39 additions and 78 deletions

View file

@ -57,7 +57,6 @@ in {
linux.programs = { linux.programs = {
docker = { docker = {
services = { services = {
anki-sync.enable = true;
drone.enable = true; drone.enable = true;
forgejo.enable = true; forgejo.enable = true;
jellyfin.enable = true; jellyfin.enable = true;

View file

@ -4,7 +4,6 @@ source "$dir/../../lib/action.fish"
function backupAction -V dir function backupAction -V dir
source "$dir/../../lib/hooks.fish" source "$dir/../../lib/hooks.fish"
source "$dir/../../lib/restoration.fish"
if not type -q getDeploymentScript if not type -q getDeploymentScript
function getDeploymentScript function getDeploymentScript
@ -14,7 +13,45 @@ function backupAction -V dir
end end
set -l deployScript (getDeploymentScript) set -l deployScript (getDeploymentScript)
initConfig --action backup
if [ -z "$VALHALLA_BACKUP_DIR" ]
if fish "$dir/../../../lib/modules/partition/confirm.fish" "Do you wish to store the backup on an SSH server?" n
set -l keyVar VALHALLA_BACKUP_SERVER_KEY
set -l keyPath ~root/.config/port-valhalla/valhalla
read -xP "Please specify the host name of the SSH server: " VALHALLA_BACKUP_SERVER
read -xP "Please specify the port of the SSH server (default 22): " VALHALLA_BACKUP_SERVER_PORT
read -xP "Please specify the name of the user to log in to the SSH server: " VALHALLA_BACKUP_SERVER_USER
set -l host "$VALHALLA_BACKUP_SERVER"
if [ -z "$$keyVar" ]
set -gx "$keyVar" "$keyPath"
sudo mkdir -p (dirname "$keyPath")
sudo ssh-keygen -f "$$keyVar" -N ""
end
if [ -z "$VALHALLA_BACKUP_SERVER_PORT" ]
set -x VALHALLA_BACKUP_SERVER_PORT 22
end
if [ -n "$VALHALLA_BACKUP_SERVER_USER" ]
set host "$VALHALLA_BACKUP_SERVER_USER@$host"
end
echo
echo "$(tput setaf 3)==== WARNING ====$(tput sgr0)"
echo "For a seamless experience, please make sure that you are able to establish an unattended ssh connection using key authentication."
echo
echo "Your public key is:"
sudo cat "$VALHALLA_BACKUP_SERVER_KEY.pub"
echo
echo "$(tput bold)This command should succeed without user interaction:$(tput sgr0)"
echo "sudo ssh -o PasswordAuthentication=no -i $(string escape -- "$VALHALLA_BACKUP_SERVER_KEY") -p $VALHALLA_BACKUP_SERVER_PORT $host true"
read -P "Press enter once you're done: "
echo
end
read -xP "Please specify the path to the directory to save the backup to: " VALHALLA_BACKUP_DIR
end
runHook backupSoftware || begin runHook backupSoftware || begin
echo "Backing up software..." echo "Backing up software..."

View file

@ -1,78 +1,3 @@
set -l dir (status dirname)
function initConfig -V dir -d "Fetches the configuration by prompting the user to "
set -l disabled VALHALLA_BACKUP_DISABLED
if [ -z "$$disabled" ]
if [ -z "$VALHALLA_BACKUP_DIR" ]
argparse -i "action=" -- $argv
set -l index
set -l confirm fish "$dir/../../../lib/modules/partition/confirm.fish"
switch "$_flag_action"
case backup
set index 1
case restore
set index 2
case '*'
set index 3
end
if [ "$_flag_action" != restore ] || $confirm "Do you wish to restore a backup?"
set -l keyVar VALHALLA_BACKUP_SERVER_KEY
set -l keyPath ~/.config/port-valhalla/valhalla
set -l server (string repeat --count 3 (printf "%s\n" "Please specify the host name of the SSH server: "))
set -l port (string repeat --count 3 (printf "%s\n" "Please specify the port of the SSH server (default 22): "))
set -l user (string repeat --count 3 (printf "%s\n" "Please specify the name of the user to log in to the SSH server: "))
set -l ssh \
"Do you wish to store the backup on an SSH server?" \
"Do you wish to restore the backup from an SSH server?" \
"Do you wish to backup or restore files on an SSH server?"
set -l path \
"Please specify the path to the directory to save the backup to: " \
"Please specify the path to the directory to load the backup from: " \
"Please specify the path to the backup directory: "
if [ -z "$$keyVar" ]
set -gx "$keyVar" "$keyPath"
ssh-keygen -f "$keyPath" -N ""
end
if fish $confirm $ssh[$index] n
read -gxP $server[$index] VALHALLA_BACKUP_SERVER
read -gxP $port[$index] VALHALLA_BACKUP_SERVER_PORT
read -gxP $user[$index] VALHALLA_BACKUP_SERVER_USER
end
if [ -n "$VALHALLA_BACKUP_SERVER" ]
set -l sshArgs
if [ -n "$VALHALLA_BACKUP_SERVER_PORT" ]
set -a sshArgs -p "$VALHALLA_BACKUP_SERVER_PORT"
end
echo
echo "$(tput setaf 3)==== WARNING ====$(tput sgr0)"
echo "For a seamless experience, please make sure that you are able to establish an unattended ssh connection using key authentication."
echo
echo "$(tput bold)This command should succeed without user interaction:$(tput sgr0)"
echo "sudo ssh -o PasswordAuthentication=no -i $(string escape -- "$VALHALLA_BACKUP_SERVER_KEY") $sshArgs $VALHALLA_BACKUP_SERVER true"
read -P "Press enter once you're done: "
echo
end
read -gxP $path[$index] VALHALLA_BACKUP_DIR
else
set -gx "$disabled" 1
end
end
end
end
function backupFiles function backupFiles
if [ -n "$VALHALLA_BACKUP_DIR" ] if [ -n "$VALHALLA_BACKUP_DIR" ]
argparse -i "base-directory=" -- $argv argparse -i "base-directory=" -- $argv