48 lines
1.0 KiB
Bash
Executable File
48 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# File: aether.bash
|
|
#
|
|
# Description: Copy the aether.enc to local
|
|
#
|
|
# Package: AniNIX/Aether
|
|
# Copyright: WTFPL
|
|
#
|
|
# Author: DarkFeather <ircs://aninix.net:6697/DarkFeather>
|
|
|
|
# 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
|
|
|
|
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
|
|
|
|
cd /home/aether
|
|
|
|
# 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"
|
|
printf "get /aether/aether.enc %s\nbye\n" $TARGET | sftp -o IdentityFile=./.ssh/aether "$aetherremote"
|
|
|
|
echo "Aether copy populated from $aetherremote. Today\'s was saved to $TARGET"
|
|
exit
|