104 lines
5.0 KiB
Plaintext
104 lines
5.0 KiB
Plaintext
|
#!/bin/bash
|
||
|
|
||
|
source "$HOME/bin/scripts/system/style"
|
||
|
|
||
|
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}
|
||
|
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}
|
||
|
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}
|
||
|
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}
|
||
|
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}
|
||
|
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
|
||
|
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
|
||
|
|
||
|
|
||
|
if [[ -d "${CONFIG_DIR}/geany" && -d "${CONFIG_DIR}/gtk-2.0" && -d "${CONFIG_DIR}/gtk-3.0" && -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
|
||
|
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
|
||
|
if [[ ! -d "${CONFIG_DIR}/geany" && ! -d "${CONFIG_DIR}/gtk-2.0" && ! -d "${CONFIG_DIR}/gtk-3.0" && ! -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
|
||
|
INSTALL
|
||
|
else
|
||
|
BACKUP
|
||
|
INSTALL
|
||
|
fi
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
|
||
|
post_install() {
|
||
|
RUN_MAIN
|
||
|
}
|
||
|
|
||
|
post_upgrade() {
|
||
|
RUN_MAIN
|
||
|
}
|