Aether/Makefile

85 lines
3.4 KiB
Makefile
Raw Normal View History

SHELL := /bin/bash
2016-11-09 22:29:17 -06:00
BACKUPDIR := /usr/local/backup
2017-06-19 13:16:04 -05:00
INSTALLER != curl -s https://aninix.net/foundation/installer-test.bash
2016-09-21 21:43:35 -05:00
compile:
2017-06-19 13:16:04 -05:00
${INSTALLER} -S openssl gzip tar openssh
2016-09-21 21:43:35 -05:00
2017-06-19 13:16:04 -05:00
install: compile
@echo You must specify client or server in a call to make.
client: user aether.bash
cp aether.bash /home/aether/aether.bash
/home/aether/aether.bash
2017-06-19 13:16:04 -05:00
sudo -u aether crontab -l > /tmp/cronie
grep aether.bash /tmp/cronie || echo '0 1 * * * /home/aether/aether.bash &>> /var/log/aether.log' >> /tmp/cronie
2017-06-19 13:16:04 -05:00
sudo -u aether crontab /tmp/cronie
rm /tmp/cronie
touch /var/log/aether.log
chown aether:aether /var/log/aether.log
2017-06-19 13:16:04 -05:00
make checkperm
2017-06-19 13:16:04 -05:00
server: keys scripts user ./aether-gen.bash ./aether.pub ./server-backup
bash ./aether-gen.bash
cp ./aether.pub /home/aether/.ssh/authorized_keys
2017-06-19 13:16:04 -05:00
cp ./aether-gen.bash /root/bin/aether-gen.bash
mkdir /usr/local/etc/Aether
touch /usr/local/etc/Aether/nodeslist
2017-06-19 13:16:04 -05:00
mkdir -p ${BACKUPDIR};
make checkperm
@echo You have the files. Add aether-gen.bash and server-backup to root\'s crontab.
@echo Track client nodes in /usr/local/etc/Aether/nodeslist
user: aether make-user.bash
/bin/bash ./make-user.bash
node-command:
2017-06-19 13:16:04 -05:00
@echo USE THE FOLLOWING COMMANDS TO SET UP A NODE.
@echo -ne 'git clone https://aninix.net/foundation/Aether;'
@echo
@echo -ne 'cd Aether; cat > aether # Paste the private key'
@echo
@echo -ne 'make client'
@echo
2017-06-19 13:16:04 -05:00
@echo MAKE SURE TO ADD THE NODE TO /usr/local/etc/Aether/nodes.list
keys:
2017-06-19 13:16:04 -05:00
if [ ! -f ./aether ]; then ssh-keygen -t rsa -P "" -f aether
2016-09-21 21:43:35 -05:00
scripts: ./server-backup ./remote-backup
cp ./server-backup /root/bin
cp ./remote-backup /root/bin
2017-06-19 13:16:04 -05:00
make checkperm
2016-09-21 21:43:35 -05:00
reverse:
2017-06-19 13:16:04 -05:00
if [ -f /root/bin/server-backup ]; then cp /root/bin/server-backup .; fi
if [ -f /root/bin/remote-backup ]; then cp /root/bin/remote-backup .; fi
if [ -f /root/bin/aether-gen.bash ]; then cp /root/bin/aether-gen.bash .; fi
if [ -f /home/aether/aether.bash ]; then cp /home/aether/aether.bash .; fi
diff:
if [ -f /root/bin/server-backup ]; then diff ./server-backup /root/bin/server-backup; fi
if [ -f /root/bin/remote-backup ]; then diff ./remote-backup /root/bin/remote-backup; fi
if [ -f /root/bin/aether-gen.bash ]; then diff ./aether-gen.bash /root/bin/aether-gen.bash; fi
if [ -f /home/aether/aether.bash ]; then diff ./aether.bash /home/aether/aether.bash; fi
2016-11-09 22:29:17 -06:00
checkperm:
2017-06-19 13:16:04 -05:00
id aether;
if [ -d /home/aether ]; then chmod 0600 /home/aether/.ssh/authorized_keys; chmod 0700 /home/aether/.ssh /home/aether; chown -R aether:aether /home/aether; fi
if [ -f /root/bin/remote-backup ]; then chmod 0700 /root/bin/remote-backup; chown root:root /root/bin/remote-backup; fi
if [ -f /root/bin/server-backup ]; then chmod 0700 /root/bin/server-backup; chown root:root /root/bin/server-backup; fi
if [ -d /usr/local/etc/Aether ]; then chmod -R 0700 /usr/local/etc/Aether; chown -R aether:aether /usr/local/etc/Aether; fi
if [ -d ${BACKUPDIR} ]; then chmod 0770 ${BACKUPDIR}; chown postgres:root ${BACKUPDIR}; fi
if [ -f /var/log/aether.log ]; then chown aether:aether /var/log/aether.log; chmod 0750 /var/log/aether.log; fi
2016-11-09 22:29:17 -06:00
2017-06-19 13:16:04 -05:00
clean:
@bash -c 'printf "This will irreversibly destroy all backups. Confirm? [YES/no] " ; read answer; [ "$$answer" == "YES" ] && exit 0; exit 1'
for i in `ls /home/aether/aether*`; do shred $$i; done
rm -Rf /home/aether
userdel aether
find /usr/local/backup -type f -exec shred {} \;
rm -Rf /usr/local/backup; fi
2016-11-09 22:29:17 -06:00
2017-06-19 13:16:04 -05:00
test:
echo bye | sftp -o IdentityFile=/home/aether/.ssh/aether aether@aninix.net