Updated post installation script
This commit is contained in:
+31
-18
@@ -1,44 +1,57 @@
|
||||
## Colors ----------------------------
|
||||
|
||||
# Reset
|
||||
Color_Off='\033[0m' # Text Reset
|
||||
|
||||
# Regular Colors
|
||||
Black='\033[0;30m' Red='\033[0;31m' Green='\033[0;32m' Yellow='\033[0;33m'
|
||||
Blue='\033[0;34m' Purple='\033[0;35m' Cyan='\033[0;36m' White='\033[0;37m'
|
||||
|
||||
# Bold
|
||||
BBlack='\033[1;30m' BRed='\033[1;31m' BGreen='\033[1;32m' BYellow='\033[1;33m'
|
||||
BBlue='\033[1;34m' BPurple='\033[1;35m' BCyan='\033[1;36m' BWhite='\033[1;37m'
|
||||
|
||||
# Underline
|
||||
UBlack='\033[4;30m' URed='\033[4;31m' UGreen='\033[4;32m' UYellow='\033[4;33m'
|
||||
UBlue='\033[4;34m' UPurple='\033[4;35m' UCyan='\033[4;36m' UWhite='\033[4;37m'
|
||||
|
||||
# Background
|
||||
On_Black='\033[40m' On_Red='\033[41m' On_Green='\033[42m' On_Yellow='\033[43m'
|
||||
On_Blue='\033[44m' On_Purple='\033[45m' On_Cyan='\033[46m' On_White='\033[47m'
|
||||
|
||||
## -----------------------------------
|
||||
|
||||
## User info
|
||||
_user=`echo ${SUDO_USER:-$(whoami)}`
|
||||
_gid=`echo ${SUDO_GID}`
|
||||
_group=`cat /etc/group | grep ${_gid} | cut -d: -f1 | head -1`
|
||||
_dir="/home/${_user}/.config"
|
||||
_skel='/etc/skel/.config'
|
||||
|
||||
## Packages specific
|
||||
_wmpkg='berry'
|
||||
_wmname='Berry'
|
||||
|
||||
## Colors
|
||||
RED="$(printf '\033[31m')" GREEN="$(printf '\033[32m')" YELLOW="$(printf '\033[33m')" BLUE="$(printf '\033[34m')"
|
||||
MAGENTA="$(printf '\033[35m')" CYAN="$(printf '\033[36m')" WHITE="$(printf '\033[37m')" BLACK="$(printf '\033[30m')"
|
||||
|
||||
## Reset terminal colors
|
||||
reset_color() {
|
||||
tput sgr0 # reset attributes
|
||||
tput op # reset color
|
||||
return
|
||||
}
|
||||
|
||||
## Install Config files
|
||||
install_wm() {
|
||||
echo -e ${BLUE}"\n[*] Copying ${_wmname} config files into ${_dir}..." && reset_color
|
||||
echo -e ${Blue}"\n[*] Copying ${BBlue}${_wmname}${Blue} config files into ${BBlue}${_dir}" ${Color_Off}
|
||||
mkdir -p ${_dir}/${_wmpkg}
|
||||
cp -rf /etc/skel/.config/${_wmpkg}/* ${_dir}/${_wmpkg}/
|
||||
cp -rf ${_skel}/${_wmpkg}/* ${_dir}/${_wmpkg}/
|
||||
chown -R ${_user}:${_group} ${_dir}/${_wmpkg}
|
||||
if [[ -d "${_dir}/${_wmpkg}" ]]; then
|
||||
echo -e ${GREEN}"[*] Configuration files installed successfully!" && reset_color
|
||||
echo -e ${BGreen}"[*] Configuration files installed successfully!\n" ${Color_Off}
|
||||
else
|
||||
echo -e ${RED}"[*] Failed to install configuration files!" && reset_color
|
||||
echo -e ${BRed}"[*] Failed to install configuration files!\n" ${Color_Off}
|
||||
fi
|
||||
}
|
||||
|
||||
## Backup previous files
|
||||
backup_wm() {
|
||||
echo -e ${MAGENTA}"\n[*] Creating a backup of your current ${_wmname} config..." && reset_color
|
||||
echo -e ${Purple}"\n[*] Creating a backup of your current ${BPurple}${_wmname}${Purple} config..." ${Color_Off}
|
||||
BNAME="`echo $RANDOM`"
|
||||
mv ${_dir}/${_wmpkg} ${_dir}/${_wmpkg}_backup_${BNAME}
|
||||
chown -R ${_user}:${_group} ${_dir}/${_wmpkg}_backup_${BNAME}
|
||||
echo -e ${YELLOW}"[*] Your current config files are stored in : ${_dir}/${_wmpkg}_backup_${BNAME} , In case you want to use them." && reset_color
|
||||
echo -e ${Yellow}"[*] Your current config files are stored in : ${BYellow}${_dir}/${_wmpkg}_backup_${BNAME}${Yellow} , In case you want to use them." ${Color_Off}
|
||||
}
|
||||
|
||||
## Main
|
||||
@@ -64,5 +77,5 @@ post_upgrade() {
|
||||
}
|
||||
|
||||
post_remove() {
|
||||
echo -e ${RED}"\n[*] Config files for ${_wmname} are still available in : ${_dir}/${_wmpkg} directory. If you want to remove them, Do it manually." && reset_color
|
||||
echo -e ${BRed}"\n[*] Config files for ${BYellow}${_wmname}${BRed} are still available in : ${BGreen}${_dir}/${_wmpkg}${BRed} directory. If you want to remove them, Do it manually.\n" ${Color_Off}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user