Add more structure to script
This commit is contained in:
parent
e3696e134b
commit
345fe85069
@ -1,8 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
#ANY CHANGES TO THE INSTALLATION PROCEDURE SHOULD BE MADE HERE
|
############################################################
|
||||||
|
###################### INSTALL CONFIG ######################
|
||||||
|
############################################################
|
||||||
|
|
||||||
# function to select theme
|
# function to select theme
|
||||||
function func_seltheme {
|
function func_seltheme {
|
||||||
@ -24,15 +25,19 @@ function func_seltheme {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
########################################
|
||||||
|
################ Setup ################
|
||||||
|
########################################
|
||||||
|
|
||||||
# check if user is root
|
# check if user is root
|
||||||
if [ "$EUID" -ne 0 ]; then
|
if [ "$EUID" -ne 0 ]; then
|
||||||
sudo -l > /dev/null
|
sudo -l > /dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#change to home (does not show in terminal)
|
# change to home
|
||||||
cd "$HOME"
|
cd "$HOME"
|
||||||
|
|
||||||
#remove old installs
|
# remove old installs
|
||||||
rm -rf ~/config
|
rm -rf ~/config
|
||||||
|
|
||||||
echo "Checking config file"
|
echo "Checking config file"
|
||||||
@ -57,9 +62,10 @@ if [[ ! -f "$HOME/.seltheme" ]]; then
|
|||||||
func_seltheme
|
func_seltheme
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##############################
|
####################
|
||||||
##### arguments #####
|
#### Arguments ####
|
||||||
##############################
|
####################
|
||||||
|
|
||||||
# handle arguments
|
# handle arguments
|
||||||
if [[ "$#" -eq 1 ]]; then
|
if [[ "$#" -eq 1 ]]; then
|
||||||
# -t/--theme to change theme
|
# -t/--theme to change theme
|
||||||
@ -74,12 +80,24 @@ elif [[ "$#" -gt 1 ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
########################################
|
||||||
|
################ Backup ################
|
||||||
|
########################################
|
||||||
|
|
||||||
|
####################
|
||||||
|
##### Cleaning #####
|
||||||
|
####################
|
||||||
|
|
||||||
#delete previous backups
|
#delete previous backups
|
||||||
echo Removing old backup
|
echo Removing old backup
|
||||||
if [[ -d ~/old_dat ]]; then
|
if [[ -d ~/old_dat ]]; then
|
||||||
rm -rf ~/old_dat
|
rm -rf ~/old_dat
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
####################
|
||||||
|
##### Creating #####
|
||||||
|
####################
|
||||||
|
|
||||||
# make new backup
|
# make new backup
|
||||||
echo Creating backup
|
echo Creating backup
|
||||||
mkdir -p ~/old_dat/.config
|
mkdir -p ~/old_dat/.config
|
||||||
@ -92,9 +110,6 @@ mkdir -p ~/old_dat/.elvish
|
|||||||
# make subdirectories
|
# make subdirectories
|
||||||
mkdir -p ~/old_dat/.local/share
|
mkdir -p ~/old_dat/.local/share
|
||||||
|
|
||||||
##############################
|
|
||||||
# back stuff up
|
|
||||||
##############################
|
|
||||||
#config folders
|
#config folders
|
||||||
if [[ -d ~/.config/MangoHud ]]; then
|
if [[ -d ~/.config/MangoHud ]]; then
|
||||||
rsync -ah ~/.config/MangoHud ~/old_dat/.config/
|
rsync -ah ~/.config/MangoHud ~/old_dat/.config/
|
||||||
@ -159,6 +174,10 @@ if [[ -d ~/.config/Vorlagen ]]; then
|
|||||||
rm -r ~/.config/Vorlagen
|
rm -r ~/.config/Vorlagen
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
########################################
|
||||||
|
########### Copy New Config ###########
|
||||||
|
########################################
|
||||||
|
|
||||||
#copy folders
|
#copy folders
|
||||||
cp -r ~/config/.config/ ~/
|
cp -r ~/config/.config/ ~/
|
||||||
cp -r ~/config/.local/ ~/
|
cp -r ~/config/.local/ ~/
|
||||||
@ -174,7 +193,6 @@ cp -r ~/config/.bashrc ~/
|
|||||||
cp -r ~/config/.face ~/
|
cp -r ~/config/.face ~/
|
||||||
cp -r ~/config/.gtkrc-2.0 ~/
|
cp -r ~/config/.gtkrc-2.0 ~/
|
||||||
cp -r ~/config/.gitconfig ~/
|
cp -r ~/config/.gitconfig ~/
|
||||||
#cp -r ~/config/.fehbg ~/
|
|
||||||
cp -r ~/config/.tmux.conf ~/
|
cp -r ~/config/.tmux.conf ~/
|
||||||
cp -r ~/config/.xinitrc ~/
|
cp -r ~/config/.xinitrc ~/
|
||||||
echo Copied files
|
echo Copied files
|
||||||
@ -210,8 +228,9 @@ if [ "$distro" == "ID=arch" ]; then
|
|||||||
sudo mv /etc/arch-pacman.conf /etc/pacman.conf
|
sudo mv /etc/arch-pacman.conf /etc/pacman.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# NOTE only for webkit2gtk version of lightdm
|
||||||
#copy old lightdm themes (and maybe other stuff, idk)
|
#copy old lightdm themes (and maybe other stuff, idk)
|
||||||
sudo cp -r ~/config/var /
|
#sudo cp -r ~/config/var /
|
||||||
|
|
||||||
#copy usr stuff
|
#copy usr stuff
|
||||||
sudo cp -r ~/config/usr /
|
sudo cp -r ~/config/usr /
|
||||||
@ -219,6 +238,10 @@ sudo cp -r ~/config/usr /
|
|||||||
# copy xresources
|
# copy xresources
|
||||||
cp ~/config/.Xresources ~/
|
cp ~/config/.Xresources ~/
|
||||||
|
|
||||||
|
####################
|
||||||
|
###### Theme ######
|
||||||
|
####################
|
||||||
|
|
||||||
# remove old themes folder
|
# remove old themes folder
|
||||||
rm -rf ./themes
|
rm -rf ./themes
|
||||||
|
|
||||||
@ -244,44 +267,45 @@ rm -rf ./themes
|
|||||||
# make fehbg executable
|
# make fehbg executable
|
||||||
chmod +x ~/.fehbg
|
chmod +x ~/.fehbg
|
||||||
|
|
||||||
|
####################
|
||||||
|
##### Bash Cat #####
|
||||||
|
####################
|
||||||
|
|
||||||
# download cat as cat
|
# download cat as cat
|
||||||
echo "Installing bash cat"
|
echo "Installing bash cat"
|
||||||
git clone https://github.com/RealStickman/bash-cat-with-cat.git &>/dev/null
|
git clone https://github.com/RealStickman/bash-cat-with-cat.git &>/dev/null
|
||||||
cp ./bash-cat-with-cat/cat.sh "$HOME/scripts/pieces/cat.sh"
|
cp ./bash-cat-with-cat/cat.sh "$HOME/scripts/pieces/cat.sh"
|
||||||
rm -rf ./bash-cat-with-cat
|
rm -rf ./bash-cat-with-cat
|
||||||
|
|
||||||
|
####################
|
||||||
|
##### PSIPCalc #####
|
||||||
|
####################
|
||||||
|
|
||||||
# download ip-calculator with powershell
|
# download ip-calculator with powershell
|
||||||
echo "Installing powershell ip calculator"
|
echo "Installing powershell ip calculator"
|
||||||
git clone https://github.com/RealStickman/PSipcalc &>/dev/null
|
git clone https://github.com/RealStickman/PSipcalc &>/dev/null
|
||||||
cp ./PSipcalc/PSipcalc.ps1 "$HOME/scripts/in_path/sc-psipcalc"
|
cp ./PSipcalc/PSipcalc.ps1 "$HOME/scripts/in_path/sc-psipcalc"
|
||||||
rm -rf ./PSipcalc
|
rm -rf ./PSipcalc
|
||||||
|
|
||||||
|
####################
|
||||||
|
####### Gimp #######
|
||||||
|
####################
|
||||||
|
|
||||||
#gimp plugins
|
#gimp plugins
|
||||||
#mkdir ~/.config/GIMP/ || echo Not creating directory
|
#mkdir ~/.config/GIMP/ || echo Not creating directory
|
||||||
#mkdir ~/.config/GIMP/2.10/ || echo Not creating directory
|
#mkdir ~/.config/GIMP/2.10/ || echo Not creating directory
|
||||||
mkdir -p ~/.config/GIMP/2.10/plug-ins/ || echo Not creating directory
|
mkdir -p ~/.config/GIMP/2.10/plug-ins/ || echo Not creating directory
|
||||||
rsync -ah ~/config/gimp-plugins/* ~/.config/GIMP/2.10/plug-ins/
|
rsync -ah ~/config/gimp-plugins/* ~/.config/GIMP/2.10/plug-ins/
|
||||||
|
|
||||||
# set systemd and group for vmware (only if installed)
|
########################################
|
||||||
|
############### Services ###############
|
||||||
|
########################################
|
||||||
|
|
||||||
|
# set systemd services for vmware (only if installed)
|
||||||
if [[ $(pacman -Q | grep vmware-workstation) ]]; then
|
if [[ $(pacman -Q | grep vmware-workstation) ]]; then
|
||||||
sudo systemctl enable --now vmware-networks-server.service
|
sudo systemctl enable --now vmware-networks-server.service
|
||||||
echo "Setting up group for vmware"
|
|
||||||
sudo groupadd -f vmware
|
|
||||||
sudo gpasswd -a "$USER" vmware 1>/dev/null
|
|
||||||
sudo chgrp vmware /dev/vmnet*
|
|
||||||
sudo chmod g+rw /dev/vmnet*
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# add group for corectrl
|
|
||||||
echo "Setting up group for corectrl"
|
|
||||||
sudo groupadd -f corectrl
|
|
||||||
sudo gpasswd -a "$USER" corectrl 1>/dev/null
|
|
||||||
|
|
||||||
# group for controlling backlight
|
|
||||||
echo "Setting group for backlight"
|
|
||||||
sudo groupadd -f video
|
|
||||||
sudo gpasswd -a "$USER" video 1>/dev/null
|
|
||||||
|
|
||||||
# enable fstrim timer
|
# enable fstrim timer
|
||||||
sudo systemctl enable fstrim.timer
|
sudo systemctl enable fstrim.timer
|
||||||
|
|
||||||
@ -292,15 +316,51 @@ if [[ $(pacman -Q | grep btrfsmaintenance) ]]; then
|
|||||||
sudo systemctl enable btrfs-scrub.timer
|
sudo systemctl enable btrfs-scrub.timer
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# set permissions for sudoers.d to root only
|
########################################
|
||||||
sudo chown root:root -R /etc/sudoers.d/
|
################ Groups ################
|
||||||
sudo chmod 600 -R /etc/sudoers.d/
|
########################################
|
||||||
|
|
||||||
|
# set systemd and group for vmware (only if installed)
|
||||||
|
if [[ $(pacman -Q | grep vmware-workstation) ]]; then
|
||||||
|
echo "Setting up group for vmware"
|
||||||
|
sudo groupadd -f vmware
|
||||||
|
sudo gpasswd -a "$USER" vmware 1>/dev/null
|
||||||
|
sudo chgrp vmware /dev/vmnet*
|
||||||
|
sudo chmod g+rw /dev/vmnet*
|
||||||
|
fi
|
||||||
|
|
||||||
|
# set group for wireshark (only if installed)
|
||||||
|
if [[ $(pacman -Q | grep wireshark-qt) ]]; then
|
||||||
|
echo "Setting up group for wireshark"
|
||||||
|
sudo groupadd -f wireshark
|
||||||
|
sudo gpasswd -a "$USER" wireshark 1>/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
# add group for corectrl
|
||||||
|
if [[ $(pacman -Q | grep corectrl) ]]; then
|
||||||
|
echo "Setting up group for corectrl"
|
||||||
|
sudo groupadd -f corectrl
|
||||||
|
sudo gpasswd -a "$USER" corectrl 1>/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
# group for controlling backlight
|
||||||
|
echo "Setting group for backlight"
|
||||||
|
sudo groupadd -f video
|
||||||
|
sudo gpasswd -a "$USER" video 1>/dev/null
|
||||||
|
|
||||||
# group for monitoring wireguard
|
# group for monitoring wireguard
|
||||||
echo "Setting group for wireguard"
|
echo "Setting group for wireguard"
|
||||||
sudo groupadd -f wireguard
|
sudo groupadd -f wireguard
|
||||||
sudo gpasswd -a "$USER" wireguard 1>/dev/null
|
sudo gpasswd -a "$USER" wireguard 1>/dev/null
|
||||||
|
|
||||||
|
########################################
|
||||||
|
############# Misc Config #############
|
||||||
|
########################################
|
||||||
|
|
||||||
|
# set permissions for sudoers.d to root only
|
||||||
|
sudo chown root:root -R /etc/sudoers.d/
|
||||||
|
sudo chmod 600 -R /etc/sudoers.d/
|
||||||
|
|
||||||
# unzip gimp plugins
|
# unzip gimp plugins
|
||||||
echo Unzipping gimp plugins
|
echo Unzipping gimp plugins
|
||||||
unzip -o ~/.config/GIMP/2.10/plug-ins/export_layers-3.3.1.zip -d ~/.config/GIMP/2.10/plug-ins/ > /dev/null
|
unzip -o ~/.config/GIMP/2.10/plug-ins/export_layers-3.3.1.zip -d ~/.config/GIMP/2.10/plug-ins/ > /dev/null
|
||||||
@ -324,6 +384,10 @@ bash ~/config/scripts/nemo-config.sh
|
|||||||
#remove downloaded folder
|
#remove downloaded folder
|
||||||
rm -rf ~/config
|
rm -rf ~/config
|
||||||
|
|
||||||
|
########################################
|
||||||
|
############## Reloading ##############
|
||||||
|
########################################
|
||||||
|
|
||||||
# reload applications
|
# reload applications
|
||||||
update-desktop-database ~/.local/share/applications/
|
update-desktop-database ~/.local/share/applications/
|
||||||
|
|
||||||
@ -341,7 +405,7 @@ fi
|
|||||||
# execute feh
|
# execute feh
|
||||||
"$HOME/.fehbg"
|
"$HOME/.fehbg"
|
||||||
|
|
||||||
# TODO make this only run if i3 is actually active
|
# NOTE working now
|
||||||
# if [[ "$(ps aux | grep "FIXME")" ]]; then ...
|
# if [[ "$(ps aux | grep "FIXME")" ]]; then ...
|
||||||
# ps aux | grep "\si3\s" breaks if i3 hasn't been restarted yet
|
# ps aux | grep "\si3\s" breaks if i3 hasn't been restarted yet
|
||||||
# ps aux | grep "\si3" works for both, not certain if other stuff could be detected as well
|
# ps aux | grep "\si3" works for both, not certain if other stuff could be detected as well
|
||||||
@ -350,6 +414,10 @@ if ps aux | grep -E "\si3(\s|$)" &>/dev/null; then
|
|||||||
i3-msg restart 1>/dev/null
|
i3-msg restart 1>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
########################################
|
||||||
|
############### Finished ###############
|
||||||
|
########################################
|
||||||
|
|
||||||
#output
|
#output
|
||||||
echo -e "\033[38;2;20;200;20mFinished updating everything!\033[0m"
|
echo -e "\033[38;2;20;200;20mFinished updating everything!\033[0m"
|
||||||
echo Launching new shell!
|
echo Launching new shell!
|
||||||
@ -367,4 +435,5 @@ fi
|
|||||||
# reload user default shell
|
# reload user default shell
|
||||||
exec "$(getent passwd $LOGNAME | cut -d: -f7)"
|
exec "$(getent passwd $LOGNAME | cut -d: -f7)"
|
||||||
|
|
||||||
exit 0
|
# exit successfully
|
||||||
|
$(exit 0); echo "$?"
|
||||||
|
Loading…
Reference in New Issue
Block a user