lokinet/osx-setup/scripts/postinstall
2019-10-29 00:20:11 -07:00

30 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
echo "Running postinstall" > /tmp/lokinet_postinstall.log
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
rm $HOME/.lokinet/*.signed >> /tmp/lokinet_postinstall.log
rm $HOME/.lokinet/*.key >> /tmp/lokinet_postinstall.log
rm $HOME/.lokinet/*.private >> /tmp/lokinet_postinstall.log
rm -fr $HOME/.lokinet/netdb >> /tmp/lokinet_postinstall.log
/usr/local/bin/lokinet -g >> /tmp/lokinet_postinstall.log
url="https://seed.lokinet.org/bootstrap.signed"
echo "downloading $url" >> /tmp/lokinet_postinstall.log
echo "to $HOME/.lokinet/bootstrap.signed" >> /tmp/lokinet_postinstall.log
# use temp file to not overrwrite existing bootstrap file on fail
tmp=/tmp/bootstrap.tmp
# MacOS does not have wget without homebrew but does have curl
# Rick also had indicated most BSDs have curl too
curl "$url" > "$tmp" && \
(mv "$tmp" "$HOME/.lokinet/bootstrap.signed" && echo "${GREEN}lokinet successfully bootstrapped${NC}" >> /tmp/lokinet_postinstall.log) \
|| echo "${RED}failed to download bootstrap from $url${NC}" >> /tmp/lokinet_postinstall.log
rm -f "$tmp"
exit 0 # all good