Skip to content

Instantly share code, notes, and snippets.

@p4p1
Last active November 4, 2021 16:40
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/4f9737dbb09d69879884612b4e0216bc to your computer and use it in GitHub Desktop.
Save p4p1/4f9737dbb09d69879884612b4e0216bc to your computer and use it in GitHub Desktop.
🍊🍊🍊🍊
#/bin/bash
# arch_install.sh
# Created on: Tue, 16 Jun 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 archlinux
#
# Usage:
# ./install.sh -u $(whoami) -s # basic installation w/ pentesting tools
config="https://leosmith.xyz/rice/backup.tar.xz"
function usage () {
echo -e "\e[1;31mUsage:\e[m" 1>&2
echo "$0 -u \$(whoami) -> default install" 1>&2
exit 84
}
# install the AUR helper
function install_AUR() {
TMP_DIR=$(pwd)
if ! hash yay &> /dev/null; then
cd /tmp/
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
cd $TMP_DIR
fi
}
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 the configuration
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 ] && cp -r ./backup/$item /home/$1/$item
[ ! -d /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 install fonts
function font_install() {
cp -r /home/$1/.dwm/font/* /usr/share/fonts/
# Emoji support
echo "<?xml version=1.0?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<alias>
<family>sans-serif</family>
<prefer>
<family>Noto Sans</family>
<family>Noto Color Emoji</family>
<family>Noto Emoji</family>
<family>DejaVu Sans</family>
</prefer>
</alias>
<alias>
<family>serif</family>
<prefer>
<family>Noto Serif</family>
<family>Noto Color Emoji</family>
<family>Noto Emoji</family>
<family>DejaVu Serif</family>
</prefer>
</alias>
<alias>
<family>monospace</family>
<prefer>
<family>Noto Mono</family>
<family>Noto Color Emoji</family>
<family>Noto Emoji</family>
<family>DejaVu Sans Mono</family>
</prefer>
</alias>
</fontconfig>" > /etc/fonts/local.conf
fc-cache -vf
}
# Command parser
while getopts "u:" o; do
case "${o}" in
u)
u=${OPTARG}
;;
*)
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 :)"
pacman -Syy
pacman -Syu
install_AUR
config_install $u
cat /home/$u/.packages | cut -d' ' -f1 | xargs -L 1 pacman -S --noconfirm
install_dwm_st $u
font_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
[ ! -f /home/$u/.xinitrc ] && echo "exec dwm" > /home/$u/.xinitrc
echo "All done :)"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment