Skip to content

Instantly share code, notes, and snippets.

@p4p1
Last active August 17, 2020 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save p4p1/e40e6d298e347574b84650a537bf871f to your computer and use it in GitHub Desktop.
Save p4p1/e40e6d298e347574b84650a537bf871f to your computer and use it in GitHub Desktop.
🍋🍋🍋🍋
#/bin/bash
# ubuntu_install.sh
# Created on: Fri, 27 March 2020
# https://p4p1.github.io/#config
# ____ __ ____ __
# ( _ \ /. |( _ \/ )
# )___/(_ _))___/ )(
# (__) (_)(__) (__)
#
# Description:
# Installation script to install and configure the softwares I used the
# most. I also propose a list of packages for different working environements.
#
# Dependencies:
# This script will only work on ubuntu
#
# Usage:
# ./install.sh -b # base install
# ./install.sh -u $(whoami) # basic installation
# ./install.sh -u $(whoami) -a # install all
# ./install.sh -u $(whoami) -p # basic installation w/ programming tools
# ./install.sh -u $(whoami) -s # basic installation w/ pentesting tools
# dmenu settings:
L_NO="5"
L_HEIGHT="25"
BG_COLOR="#222222"
FG_COLOR="#bbbbbb"
SBG_COLOR="#ff9d14"
SFG_COLOR="#222222"
BRD_WIDTH="5"
# versions
DWM_VERSION=6.2
ST_VERSION=0.8.2
# values for install
defaults=(vim emacs tmux git openvpn tor ssh docker-compose curl net-tools tar adb fastboot gparted neofetch nmap thefuck feh compton libx11-dev libxinerama-dev libxft-dev libx11-xcb-dev libxcb-res0-dev gcc make gcc i3lock ranger irssi tig imagemagick blueman libnotify-bin notify-osd pavucontrol)
programming=(npm python2 python3 gcc valgrind g++ nasm php nodejs python-pip python3-pip clang gdb ghc mingw-w64 fritzing arduino audacity xserver-xephyr golang-go ruby)
pentest=(aircrack-ng fping exiftool radare2 nikto hydra wireshark dfu-programmer dfu-util whois proxychains traceroute smbclient hashcat sqlmap binwalk steghide)
base=(base linux linux-firmware networkmanager grub xorg)
webbrowser="https://vivaldi.com/download/"
config="https:/leosmith.xyz/rice/backup.tar.xz"
# values for arguments
p=false
s=false
a=false
# Usage
function usage () {
echo -e "\e[1;31mUsage:\e[m" 1>&2
echo "$0 -b -> Base install" 1>&2
echo "$0 -u \$(whoami) -> default install" 1>&2
echo "$0 -u \$(whoami) -p -> programming install" 1>&2
echo "$0 -u \$(whoami) -s -> pentest install" 1>&2
echo "$0 -u \$(whoami) -a -> programming and pentest install" 1>&2
echo "$0 -u \$(whoami) -c -> Change bash config file" 1>&2
exit 84
}
function install_dwm_st() {
SAVED_PWD=$(pwd)
WD=/home/$1/.source
SOURCES=($(ls $WD))
echo "Installing source projects"
for item in ${SOURCES[*]}; do
FILE=$WD/$item
if [ -d "$FILE" ]; then
cd $FILE
echo -n "Running make install on $item -> "
make install &> /dev/null && echo -e "\e[1;34m:)\e[m" ||
echo -e "\e[1;31m:(\e[m"
fi
done
cd $SAVED_PWD
}
# function to install different packages
function package_install() {
for item in $@; do
echo -n "Checking $item -> "
if hash $item &> /dev/null; then
echo -e "\e[1;34m:)\e[m"
else
echo -e "\e[1;31m:(\e[m"
apt install -y $item
fi
done
}
# function to install the default webbrowser
function webbrowser_install() {
echo -e "Download vivaldi in the \e[1;31msame\e[m directory as this script..."
echo $(pwd)
su $1 -c "firefox '$webbrowser'"
apt install -y ./vivaldi*
}
# function to install my config files
function config_install() {
curl $config --output ./backup.tar.xz
tar xf ./backup.tar.xz
for item in $(ls -a ./backup/ | sed 1,2d); do
echo -e "\e[1;34mAdding\e[m $item in /home/$1/ directory"
[ -f /home/$1/$item ] && rm -rf /home/$1/$item
[ -d /home/$1/$item ] && rm -rf /home/$1/$item
cp -r ./backup/$item /home/$1/$item
chown $1 -R /home/$1/$item
done
rm -rf ./backup.tar.xz
rm -rf ./backup/
}
# function to choose bash config
function pick_bashrc() {
VAL=$(echo -e "My bashrc\nKali linux\nParrot OS\nUbuntu" | dmenu -nb \
$BG_COLOR -nf $FG_COLOR -sb $SBG_COLOR -sf $SFG_COLOR -c -bw \
$BRD_WIDTH -h $L_HEIGHT -l $L_NO)
if [ "$VAL" = "Kali linux" ]; then
cp -r /home/$1/.bash_configs/.bashrc_kali /home/$1/.bashrc
elif [ "$VAL" = "Parrot OS" ]; then
cp -r /home/$1/.bash_configs/.bashrc_parot /home/$1/.bashrc
elif [ "$VAL" = "Ubuntu" ]; then
cp -r /home/$1/.bash_configs/.bashrc_ubuntu /home/$1/.bashrc
fi
chown $1 /home/$1/.bashrc
}
function emacs_conf() {
echo -e "Downloading \e[1;31mDoom Emacs\e[m..."
su $1 -c "git clone --depth 1 https://github.com/hlissner/doom-emacs ~/.emacs.d"
su $1 -c "~/.emacs.d/bin/doom install"
echo -e "Setting up apache for webdav syncing"
a2enmod dav
a2enmod dav_fs
systemctl restart apache2
mkdir -p /var/www/webdav
chown www-data /var/www/webdav
echo -e "NameVirtualHost *\n<VirtualHost *:80>\nServerAdmin webmaster@domain\n\nDocumentRoot /var/www/webdav/\n<Directory /var/www/webdav/>\nOptions Indexes MultiViews\nAllowOverride None\nOrder allow,deny\nallow from all\n</Directory>\n\n</VirtualHost>\nAlias /webdav /var/www/webdav\n<Location /webdav>\nDAV On\nAuthType Basic\nAuthName \"webdav\"\nAuthUserFile /var/www/webdav/passwd.dav\nRequire valid-user\n</Location>" > /etc/apache2/sites-available/webdav.conf
a2ensite webdav.conf
echo "Set webdav password for $1"
htpasswd -c /var/www/webdav/passwd.dav $1
chown root:www-data /var/www/webdav/passwd.dav
chmod 640 /var/www/webdav/passwd.dav
systemctl restart apache2
a2enmod ssl
systemctl restart apache2
openssl genrsa -out ca.key 2048
openssl req -nodes -new -key ca.key -out ca.csr
openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt
mkdir -p /etc/apache2/ssl
mv ca.crt /etc/apache2/ssl
mv ca.key /etc/apache2/ssl
mv ca.crs /etc/apache2/ssl
echo -e "<VirtualHost *:443>\n\tServerAdmin webmaster@localhost\n\tDocumentRoot /var/www/html\n\tErrorLog \${APACHE_LOG_DIR}/error.log\n\tCustomLog \${APACHE_LOG_DIR}/access.log combined\n\tSSLEngine on\n\tSSLCertificateFile /etc/apache2/ssl/ca.crt\n\tSSLCertificateKeyFile /etc/apache2/ssl/ca.key\n</VirtualHost>" > /etc/apache2/sites-enabled/000-default.conf
}
function ranger_conf() {
RANGER_CONF=/home/$1/.config/ranger
[ ! -d $RANGER_CONF ] && mkdir $RANGER_CONF
[ ! -d $RANGER_CONF/colorschemes ] && mkdir $RANGER_CONF/colorschemes
cp -r /home/$1/.source/ranger/rc.conf $RANGER_CONF
cp -r /home/$1/.source/ranger/zenburn-theme.py $RANGER_CONF/colorschemes
chown $1:$1 $RANGER_CONF/
chown $1:$1 $RANGER_CONF/*
pip3 install ueberzug
}
function grub_conf() {
GRUB_CONF=/home/$1/.source/grub_theme/install.sh
su $u -c "bash $GRUB_CONF"
}
# OS installer for arch
function base_install() {
echo -e "Arch linux installer \e[95m<3\e[m"
echo "This will not partition the disk so please partition in before hand"
echo -e "\tcmd list: cfdisk mkfs.ext4 mkswap swapon"
timedatectl set-ntp true
pacstrap /mnt ${base[*]}
genfstab -U /mnt >> /mnt/etc/fstab
}
# Command parser
while getopts "u::psacb" o; do
case "${o}" in
u)
u=${OPTARG}
;;
p)
p=true
;;
s)
s=true
;;
a)
a=true
;;
c)
[ -z "${u}" ] && usage
pick_bashrc $u
install_dwm_st $u
exit 0
;;
b)
base_install
exit 0
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
if [ -z "${u}" ]; then
usage
fi
# Do the basic checks to see if root and on supported systems and if the user exitsts
if [ "$EUID" -ne 0 ]; then
echo -e "\e[1;31mPlease run as root\e[m"
exit 84
fi
if [ ! -d /home/$1 ]; then
echo -e "\e[1;31mError: /home/$1. Folder not found!\e[m"
exit 84
fi
# beginning of script
echo "Installing Leo's Stuff :)"
apt update
apt -y upgrade
package_install ${defaults[*]}
if $a; then
package_install ${programming[*]}
package_install ${pentest[*]}
elif $p; then
package_install ${programming[*]}
elif $s; then
package_install ${pentest[*]}
fi
webbrowser_install $u
config_install $u
echo "Now run PlugInstall in vim"
echo "Press [Enter]"
read a
su $u -c "vim /home/$u/.vimrc"
echo -n "Checking for shh key -> "
if [ -f /home/$u/.ssh/id_rsa.pub -a -f /home/$u/.ssh/id_rsa ]; then
echo -e "\e[1;34m:)\e[m"
else
echo -e "\e[1;31m:(\e[m"
su $u -c "ssh-keygen"
fi
install_dwm_st $u
pick_bashrc $u
emacs_conf $u
ranger_conf $u
grub_conf $u
OS=$(neofetch | grep "OS" | awk -F":" '{print $2}' | awk -F' ' '{print $2}')
if [ "$OS" = "Ubuntu" ]; then
# Desktop entry for dwm
echo "[Desktop Entry]" > /usr/share/xsessions/dwm.desktop
echo "Encoding=UTF-8" >> /usr/share/xsessions/dwm.desktop
echo "Name=Dwm" >> /usr/share/xsessions/dwm.desktop
echo "Comment=Dynamic window manager" >> /usr/share/xsessions/dwm.desktop
echo "Exec=$(whereis dwm | cut -d ":" -f2 | cut -c 2-)" >> /usr/share/xsessions/dwm.desktop
echo "Type=XSession" >> /usr/share/xsessions/dwm.desktop
# Touchpad config for ubuntu
[ ! -d /etc/X11/xorg.conf.d] && mkdir -p /etc/X11/xorg.conf.d
echo -e "Section \"InputClass\"" > /etc/X11/xorg.conf.d/90-touchpad.conf
echo -e "\tIdentifier \"touchpad\"" >> /etc/X11/xorg.conf.d/90-touchpad.conf
echo -e "\tMatchIsTouchpad \"on\"" >> /etc/X11/xorg.conf.d/90-touchpad.conf
echo -e "\tDriver \"libinput\"" >> /etc/X11/xorg.conf.d/90-touchpad.conf
echo -e "\tOption \"Tapping\" \"on\"" >> /etc/X11/xorg.conf.d/90-touchpad.conf
echo -e "\tOption \"TappingButtonMap\" \"lrm\"" >> /etc/X11/xorg.conf.d/90-touchpad.conf
echo -e "\tOption \"ScrollMethod\" \"twofinger\"" >> /etc/X11/xorg.conf.d/90-touchpad.conf
echo -e "EndSection" >> /etc/X11/xorg.conf.d/90-touchpad.conf
fi
[ ! -f /home/$u/.xinitrc ] && echo "exec dwm" > /home/$u/.xinitrc
echo -n "You are going to reboot in: "
let i=5
while [ $i -gt 0 ]; do
echo -ne "\b\b\b\b\b\b(${i}sec)"
notify-send "rebooting in: ${i}sec" -u critical -t 1000
sleep 1
let i=$i-1
done
echo "All done :)"
reboot now
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment