Skip to content

Instantly share code, notes, and snippets.

@mckartha
Last active December 5, 2024 22:40
Show Gist options
  • Save mckartha/6fc94c72d517ad80c9c42d67b8e5ea1d to your computer and use it in GitHub Desktop.
Save mckartha/6fc94c72d517ad80c9c42d67b8e5ea1d to your computer and use it in GitHub Desktop.
Initialize Linux Server instance
echo "### This script wgets the logexec.sh script & makes it eexcutable, runs apt/yum/dnf update & upgrade, gets .screenrc and does other setup tasks ###"
# https://gist.github.com/mckartha/7e0241c29cc018647954b20de68c35b9/raw/1fe6699deafde6098c5d7e4b9651d6faeb19bccd/logexec.sh
# wget https://gist.github.com/mckartha/7e0241c29cc018647954b20de68c35b9/raw/1fe6699deafde6098c5d7e4b9651d6faeb19bccd/logexec.sh
wget https://gist.githubusercontent.com/mckartha/7e0241c29cc018647954b20de68c35b9/raw/38afcb31390cb4ca1425da2f75aeb770420102d8/logexec.sh
chmod +x logexec.sh
mkdir -p /usr/local/bin
echo "### Move the logexec.sh script to /usr/local/bin by executing sudo - enter password to continue: ###"
sudo mv logexec.sh /usr/local/bin
echo "## Running updates using apt/yum/dnf update & upgrade, logging output via logexec.sh ... ##"
APT=`which apt`
YUM=`which yum`
DNF=`which dnf`
ZYP=`which zypper`
if [[ "$APT" == *"apt"* ]] ; then PKGMGR = "apt"
elif [[ "$YUM" == *"yum"* ]] ; then PKGMGR = "yum"
elif [[ "$DNF" == *"dnf"* ]] ; then PKGMGR = "dnf"
elif [[ "$ZYP" == *"zypper"* ]] ; then PKGMGR = "zypper"
else PKGMGR = "NoPkgManager"
fi
if [[ "$APT" == *"apt"* ]] ; then
sudo logexec.sh apt update
sudo logexec.sh apt list --upgradable
sudo logexec.sh apt upgrade -y
echo "## Install other useful linux apps/tools ... ##"
sudo logexec.sh apt -y install net-tools
elif [[ "$YUM" == *"yum"* ]] ; then
sudo logexec.sh yum check-update
sudo logexec.sh yum list updates
sudo logexec.sh yum -y update
echo "## Install other useful linux apps/tools ... ##"
sudo logexec.sh yum -y install net-tools
elif [[ "$DNF" == *"dnf"* ]] ; then
sudo logexec.sh dnf check-update
sudo logexec.sh dnf -y upgrade
echo "## Install other useful linux apps/tools ... ##"
sudo logexec.sh dnf -y install net-tools
fi
echo "## Add public keys ##"
logexec.sh cp -p ~/.ssh/authorized_keys ~/.ssh/authorized_keys.orig
echo "
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIL8M4AOZEPCKnJBqoxNVjxEFL+BSgVaaY4zuih98PWnL mck@ronin
" >> ~/.ssh/authorized_keys
#ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINBVvrccEdJ+QgLGkC/q+6wp2gl6i2CI/nAgI3UWEIG0 chris@hplaptop
#ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOH5LxK+uststiES1JqCBHLrQlzQOo4kKho3Rhk5QTO4 [email protected]
wget https://gist.github.com/mckartha/6428665/raw/7151dfa6b02d97ef9fbb47a9d1cabe68b3348f36/.screenrc
sudo cp -p .screenrc /root/
echo "## Install ZeroTier SDN client ... ##"
# The ZeroTier One client can be downloaded here: https://www.zerotier.com/download/
logexec.sh wget 'https://raw.githubusercontent.com/zerotier/ZeroTierOne/master/doc/contact%40zerotier.com.gpg'
logexec.sh gpg --import [email protected]
curl -s 'https://install.zerotier.com/' | gpg -d > install.zerotier.com.sh
#if z=$(curl -s 'https://install.zerotier.com/' | gpg); then echo "$z" > install.zerotier.com.sh ; fi
chmod +x install.zerotier.com.sh
# this script uses `sudo` and prompts for a password if necessary
logexec.sh ./install.zerotier.com.sh
echo "## Connect to ArcaSea SDN by joining the ZeroTier SDN ##"
# In this case we want to join the _arcasea_ ZeroTier SDN 52b337794f49b92f
echo " ... by doing the following (or join another ZT SDN):"
echo "As root, execute: logexec.sh zerotier-cli join 52b337794f49b92f"
echo "____"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment