#!/bin/bash -f ###################################################################### # Artemis Nebula KeepConf script, (C) 2015-2020 Nosey Nick Waterman, # https://noseynick.org/artemis/nebula/ # All wrong righted, all rights reserved. Licensed under thev GNU # Affero General Public License v3.0 https://www.gnu.org/licenses/agpl.txt # with Commons Clause https://commonsclause.com/ v1.0 ###################################################################### banner Keeping config mkdir -vp ~/logs ln -vs /var/log/cloud-init.log ~/logs/ ln -vs /var/log/cloud-init-output.log ~/logs/ # if [[ -x /usr/bin/gcloud ]]; then # export IP=$(wget -t3 -T3 -qO- --header "Metadata-Flavor: Google" \ # http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/external-ip) # else # export IP=$(wget -t3 -T3 -qO- http://169.254.169.254/latest/meta-data/public-ipv4) # fi # Get a bunch of useful vars from AWS: META () { wget -t3 -T3 -qO- "http://169.254.169.254/latest/$*"; } META_ID=$(META dynamic/instance-identity/document) eval "$(echo "$META_ID" | sed -E 's/[^-_:.A-Za-z0-9]//g; s/^([^:]*):/AWS_\1=/; /=null$|^[^A]/d')" # shellcheck disable=SC2034 # AWS_AMI appears unused but is part of ${!AWS_@} AWS_AMI=$(META meta-data/ami-id) # Ask AWS what my external IP is... IPPAT='^[1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*$' # shellcheck disable=SC2034 # AWS_IP appears unused but is part of ${!AWS_@} IP='' AWS_IP=$(META meta-data/public-ipv4 | grep "$IPPAT") [[ "$IP" ]] || IP=$(wget -t3 -T3 -qO- ipapi.co/ip | grep "$IPPAT") [[ "$IP" ]] || IP=$(wget -t3 -T3 -qO- 4.icanhazip.com | grep "$IPPAT") [[ "$IP" ]] || IP=$(wget -t3 -T3 -qO- ip.seeip.org | grep "$IPPAT") [[ "$IP" ]] || IP=$(wget -t3 -T3 -qO- ifconfig.me | grep "$IPPAT") export IP=${IP:-$AWS_IP} nebula load bash # +++++ COMPARE start.sh list of vars echo 'CONFIG: ##############################################################' echo '#!/bin/bash -f' | install -vDm755 /dev/stdin ~/bin/conf.sh for X in NEBULA TOKEN CHAN TESTCHAN VNCPASS SHUTDOWN \ IP NAME MISSIONS SHIPS RUNTEST \ ${!HERMES@} ${!TS3SERVER@} ${!EE_@} ${!AWS_@} ${!NEB_@}; do echo "$X='${!X}'" | tee -a ~/bin/conf.sh done grep ^PRETTY /etc/os-release | tee -a ~/bin/conf.sh echo '######################################################################' wget -t3 -T3 -qO- --post-file ~/bin/conf.sh "$NEBULA/logs.cgi/$IP.conf" # shellcheck disable=SC2016 # deliberately not expanding $TEST or $TESTCHAN: [[ "$TESTCHAN" ]] && echo '[[ "$TEST" ]] && CHAN=$TESTCHAN' >> ~/bin/conf.sh grep -qE ^tail ~/.bash_history || \ echo 'tail -fn1000 logs/*' >> ~/.bash_history