Aether/aether.bash

48 lines
1.0 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
2023-12-07 12:37:40 -06:00
#
# File: aether.bash
#
# Description: Copy the aether.enc to local
#
# Package: AniNIX/Aether
# Copyright: WTFPL
#
# Author: DarkFeather <ircs://aninix.net:6697/DarkFeather>
2023-12-07 12:37:40 -06:00
# Usage
if [ "$1" == "-h" ]; then
cat <<EOM
Usage: $0 # Will get the aether.enc from the remote to the aether user's home.
EOM
exit 0
2023-12-07 12:37:40 -06:00
fi
# Seed remote
aetherremote="$1"
if [ -z "$aetherremote" ]; then
aetherremote=aether@aninix.net
fi
aethercount="$2"
if [ -z "$aethercount" ]; then
aethercount=7
fi
# Sanity check
if [ ! -f /home/aether/.ssh/aether ]; then
echo "Need to have the aether key to run."
exit
fi
2023-12-07 12:37:40 -06:00
cd /home/aether
2023-12-07 12:37:40 -06:00
# Logrotate off oldest aether include
if [ $(ls ./aether-*.enc | wc -l) -gt "$aethercount" ]; then
rm $(ls -tr ./aether-*.enc | head -n 1);
fi
export TARGET="aether-"$(date +%F)".enc"
2023-12-07 12:37:40 -06:00
printf "get /aether/aether.enc %s\nbye\n" $TARGET | sftp -o IdentityFile=./.ssh/aether "$aetherremote"
2023-12-07 12:37:40 -06:00
echo "Aether copy populated from $aetherremote. Today\'s was saved to $TARGET"
exit