2024-02-21 10:26:43 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-03-10 13:30:59 +03:00
|
|
|
RESET_COLOR="\033[0m"
|
|
|
|
BOLD="\033[1m"
|
|
|
|
ITALIC="\033[3m"
|
|
|
|
|
|
|
|
BLACK="\033[30m"
|
|
|
|
RED="\033[31m"
|
|
|
|
GREEN="\033[32m"
|
|
|
|
YELLOW="\033[33m"
|
|
|
|
BLUE="\033[34m"
|
|
|
|
MAGENTA="\033[35m"
|
|
|
|
CYAN="\033[36m"
|
|
|
|
WHITE="\033[37m"
|
|
|
|
PURPLE="\033[35m"
|
2024-02-21 10:26:43 +03:00
|
|
|
|
|
|
|
USER=`echo ${SUDO_USER:-$(whoami)}`
|
|
|
|
GID=`echo ${SUDO_GID}`
|
|
|
|
GROUB=`cat /etc/group | grep ${GID} | cut -d: -f1 | head -1`
|
|
|
|
CONFIG_DIR="/home/${USER}/.config"
|
|
|
|
BACKUP_DIR="/home/${USER}/.tarch-backups"
|
|
|
|
CONFIG_DIR_SKEL="/etc/skel/.config"
|
|
|
|
PKG_NAME="tarch-configs"
|
|
|
|
|
|
|
|
BACKUP (){
|
|
|
|
local FILES_NAME="tarch-configs"
|
|
|
|
echo -e ${BOLD}${GREEN}"\n[*] создаем backup текущего конфига для: ${CYAN}${PKG_NAME}${GREEN} ..." ${RESET_COLOR}
|
|
|
|
BACKUP_NAME=`date +%m-%d`
|
|
|
|
BACKUP_RANDOM="`echo $RANDOM`"
|
|
|
|
mkdir -p ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
|
|
|
|
|
|
|
|
echo -e ${CYAN}" ==> перемещаем текущий конфиг ${PURPLE}${FILES_NAME} ${CYAN} в backup дирректорию." ${RESET_COLOR}
|
2024-03-10 13:30:59 +03:00
|
|
|
mv ${CONFIG_DIR}/bspwm ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
|
|
|
|
mv ${CONFIG_DIR}/nvim ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
|
2024-02-21 10:26:43 +03:00
|
|
|
mv ${CONFIG_DIR}/geany ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
|
|
|
|
mv ${CONFIG_DIR}/gtk-2.0 ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
|
|
|
|
mv ${CONFIG_DIR}/gtk-3.0 ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
|
2024-02-21 11:31:24 +03:00
|
|
|
mv ${CONFIG_DIR}/jgmenu ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
|
2024-02-21 10:26:43 +03:00
|
|
|
mv ${CONFIG_DIR}/kitty ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
|
|
|
|
mv ${CONFIG_DIR}/lazygit ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
|
|
|
|
mv ${CONFIG_DIR}/neofetch ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
|
|
|
|
mv ${CONFIG_DIR}/networkmanager-dmenu ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
|
|
|
|
mv ${CONFIG_DIR}/nitrogen ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
|
|
|
|
mv ${CONFIG_DIR}/qt5ct ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
|
|
|
|
mv ${CONFIG_DIR}/rofi ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
|
|
|
|
mv ${CONFIG_DIR}/Thunar ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
|
|
|
|
mv ${CONFIG_DIR}/xfce4 ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
|
|
|
|
mv ${CONFIG_DIR}/mimeapps.list ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
|
|
|
|
|
|
|
|
echo -e ${CYAN}" ==> предоставление разрешений для пользователя: ${PURPLE}${USER}" ${RESET_COLOR}
|
|
|
|
chown -R ${USER}:${GROUB} ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
|
|
|
|
echo -e ${BOLD}${GREEN}"[✔] backup завершен ..." ${RESET_COLOR}
|
|
|
|
}
|
|
|
|
|
|
|
|
INSTALL (){
|
|
|
|
echo -e ${BOLD}${GREEN}"\n[*] устанавливаем пакет: ${CYAN}${PKG_NAME}${GREEN} ..." ${RESET_COLOR}
|
|
|
|
|
|
|
|
mkdir -p ${CONFIG_DIR}
|
2024-03-10 13:30:59 +03:00
|
|
|
cp -rf ${CONFIG_DIR_SKEL}/bspwm ${CONFIG_DIR}
|
|
|
|
cp -rf ${CONFIG_DIR_SKEL}/nvim ${CONFIG_DIR}
|
2024-02-21 10:26:43 +03:00
|
|
|
cp -rf ${CONFIG_DIR_SKEL}/geany ${CONFIG_DIR}
|
|
|
|
cp -rf ${CONFIG_DIR_SKEL}/gtk-2.0 ${CONFIG_DIR}
|
|
|
|
cp -rf ${CONFIG_DIR_SKEL}/gtk-3.0 ${CONFIG_DIR}
|
2024-02-21 11:31:24 +03:00
|
|
|
cp -rf ${CONFIG_DIR_SKEL}/jgmenu ${CONFIG_DIR}
|
2024-02-21 10:26:43 +03:00
|
|
|
cp -rf ${CONFIG_DIR_SKEL}/kitty ${CONFIG_DIR}
|
|
|
|
cp -rf ${CONFIG_DIR_SKEL}/lazygit ${CONFIG_DIR}
|
|
|
|
cp -rf ${CONFIG_DIR_SKEL}/neofetch ${CONFIG_DIR}
|
|
|
|
cp -rf ${CONFIG_DIR_SKEL}/networkmanager-dmenu ${CONFIG_DIR}
|
|
|
|
cp -rf ${CONFIG_DIR_SKEL}/nitrogen ${CONFIG_DIR}
|
|
|
|
cp -rf ${CONFIG_DIR_SKEL}/qt5ct ${CONFIG_DIR}
|
|
|
|
cp -rf ${CONFIG_DIR_SKEL}/rofi ${CONFIG_DIR}
|
|
|
|
cp -rf ${CONFIG_DIR_SKEL}/Thunar ${CONFIG_DIR}
|
|
|
|
cp -rf ${CONFIG_DIR_SKEL}/xfce4 ${CONFIG_DIR}
|
|
|
|
cp ${CONFIG_DIR_SKEL}/mimeapps.list ${CONFIG_DIR}
|
|
|
|
|
|
|
|
echo -e ${CYAN}" ==> предоставление разрешений для пользователя: ${PURPLE}${USER}" ${RESET_COLOR}
|
2024-03-10 13:30:59 +03:00
|
|
|
chown -R ${USER}:${GROUB} ${CONFIG_DIR}/bspwm
|
|
|
|
chown -R ${USER}:${GROUB} ${CONFIG_DIR}/nvim
|
2024-02-21 10:26:43 +03:00
|
|
|
chown -R ${USER}:${GROUB} ${CONFIG_DIR}/geany
|
|
|
|
chown -R ${USER}:${GROUB} ${CONFIG_DIR}/gtk-2.0
|
|
|
|
chown -R ${USER}:${GROUB} ${CONFIG_DIR}/gtk-3.0
|
2024-02-21 11:31:24 +03:00
|
|
|
chown -R ${USER}:${GROUB} ${CONFIG_DIR}/jgmenu
|
2024-02-21 10:26:43 +03:00
|
|
|
chown -R ${USER}:${GROUB} ${CONFIG_DIR}/kitty
|
|
|
|
chown -R ${USER}:${GROUB} ${CONFIG_DIR}/lazygit
|
|
|
|
chown -R ${USER}:${GROUB} ${CONFIG_DIR}/neofetch
|
|
|
|
chown -R ${USER}:${GROUB} ${CONFIG_DIR}/networkmanager-dmenu
|
|
|
|
chown -R ${USER}:${GROUB} ${CONFIG_DIR}/nitrogen
|
|
|
|
chown -R ${USER}:${GROUB} ${CONFIG_DIR}/qt5ct
|
|
|
|
chown -R ${USER}:${GROUB} ${CONFIG_DIR}/rofi
|
|
|
|
chown -R ${USER}:${GROUB} ${CONFIG_DIR}/Thunar
|
|
|
|
chown -R ${USER}:${GROUB} ${CONFIG_DIR}/xfce4
|
|
|
|
chown -R ${USER}:${GROUB} ${CONFIG_DIR}/mimeapps.list
|
|
|
|
|
2024-03-10 13:30:59 +03:00
|
|
|
if [[ -d "${CONFIG_DIR}/bspwm" && -d "${CONFIG_DIR}/nvim" && -d "${CONFIG_DIR}/geany" && -d "${CONFIG_DIR}/gtk-2.0" && -d "${CONFIG_DIR}/gtk-3.0" && -d "${CONFIG_DIR}/jgmenu" && -d "${CONFIG_DIR}/kitty" && -d "${CONFIG_DIR}/lazygit" && -d "${CONFIG_DIR}/neofetch" && -d "${CONFIG_DIR}/networkmanager-dmenu" && -d "${CONFIG_DIR}/nitrogen" && -d "${CONFIG_DIR}/qt5ct" && -d "${CONFIG_DIR}/rofi" && -d "${CONFIG_DIR}/Thunar" && -d "${CONFIG_DIR}/xfce4" && -f "${CONFIG_DIR}/mimeapps.list" ]]; then
|
2024-02-21 10:26:43 +03:00
|
|
|
echo -e ${BOLD}${GREEN}"[✔] конфигурационные файлы установлены..." ${RESET_COLOR}
|
|
|
|
else
|
|
|
|
echo -e ${BOLD}${RED}"[✘] ошибка установки..." ${RESET_COLOR}
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -e "\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
RUN_MAIN (){
|
|
|
|
if [[ "${GROUB}" == 'liveuser' ]]; then
|
|
|
|
exit
|
|
|
|
else
|
2024-03-10 13:30:59 +03:00
|
|
|
if [[ ! -d "${CONFIG_DIR}/bspwm" && ! -d "${CONFIG_DIR}/nvim" && ! -d "${CONFIG_DIR}/geany" && ! -d "${CONFIG_DIR}/gtk-2.0" && ! -d "${CONFIG_DIR}/gtk-3.0" && ! -d "${CONFIG_DIR}/jgmenu" && ! -d "${CONFIG_DIR}/kitty" && ! -d "${CONFIG_DIR}/lazygit" && ! -d "${CONFIG_DIR}/neofetch" && ! -d "${CONFIG_DIR}/networkmanager-dmenu" && ! -d "${CONFIG_DIR}/nitrogen" && ! -d "${CONFIG_DIR}/qt5ct" && ! -d "${CONFIG_DIR}/rofi" && ! -d "${CONFIG_DIR}/Thunar" && ! -d "${CONFIG_DIR}/xfce4" && ! -f "${CONFIG_DIR}/mimeapps.list" ]]; then
|
2024-02-21 10:26:43 +03:00
|
|
|
INSTALL
|
|
|
|
else
|
|
|
|
BACKUP
|
|
|
|
INSTALL
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
post_install() {
|
|
|
|
RUN_MAIN
|
|
|
|
}
|
|
|
|
|
|
|
|
post_upgrade() {
|
|
|
|
RUN_MAIN
|
|
|
|
}
|