tarch-misc/tarch-misc.install

106 lines
3.9 KiB
Plaintext
Raw Normal View History

2024-02-21 12:55:18 +03:00
#!/bin/bash
2024-03-10 13:30:01 +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 12:55:18 +03:00
USER=`echo ${SUDO_USER:-$(whoami)}`
GID=`echo ${SUDO_GID}`
GROUB=`cat /etc/group | grep ${GID} | cut -d: -f1 | head -1`
2024-03-10 13:30:01 +03:00
HOME_DIR="/home/${USER}"
BACKUP_DIR="${HOME_DIR}/.tarch-backups"
SKEL_DIR="/etc/skel"
2024-02-21 12:55:18 +03:00
PKG_NAME="tarch-misc"
BACKUP (){
local FILES_NAME="tarch-misc-backup"
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}" ==> перемещаем текущий конфиг в backup дирректорию." ${RESET_COLOR}
mv ${HOME_DIR}/.Xresources.d ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
2024-03-10 13:58:36 +03:00
mv ${HOME_DIR}/bin ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
2024-02-21 12:55:18 +03:00
mv ${HOME_DIR}/.dmrc ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
mv ${HOME_DIR}/.face ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
mv ${HOME_DIR}/.gtkrc-2.0 ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
mv ${HOME_DIR}/.hushlogin ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
mv ${HOME_DIR}/.p10k.zsh ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
mv ${HOME_DIR}/.Xresources ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
mv ${HOME_DIR}/.zshrc ${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 ${HOME_DIR}
2024-03-10 13:58:36 +03:00
echo -e ${CYAN}" ==> перемещяем текущие настройки дял пользователя: ${PURPLE}${USER}" ${RESET_COLOR}
2024-03-10 13:30:01 +03:00
cp -rf ${SKEL_DIR}/.Xresources.d ${HOME_DIR}
2024-03-10 13:58:36 +03:00
cp -rf ${SKEL_DIR}/bin ${HOME_DIR}
2024-03-10 13:30:01 +03:00
cp ${SKEL_DIR}/.dmrc ${HOME_DIR}
cp ${SKEL_DIR}/.face ${HOME_DIR}
cp ${SKEL_DIR}/.gtkrc-2.0 ${HOME_DIR}
cp ${SKEL_DIR}/.hushlogin ${HOME_DIR}
cp ${SKEL_DIR}/.p10k.zsh ${HOME_DIR}
cp ${SKEL_DIR}/.Xresources ${HOME_DIR}
cp ${SKEL_DIR}/.zshrc ${HOME_DIR}
2024-02-21 12:55:18 +03:00
echo -e ${CYAN}" ==> предоставление разрешений для пользователя: ${PURPLE}${USER}" ${RESET_COLOR}
chown -R ${USER}:${GROUB} ${HOME_DIR}/.Xresources.d
2024-03-10 13:58:36 +03:00
chown -R ${USER}:${GROUB} ${HOME_DIR}/bin
2024-02-21 12:55:18 +03:00
chown -R ${USER}:${GROUB} ${HOME_DIR}/.dmrc
chown -R ${USER}:${GROUB} ${HOME_DIR}/.face
chown -R ${USER}:${GROUB} ${HOME_DIR}/.gtkrc-2.0
chown -R ${USER}:${GROUB} ${HOME_DIR}/.hushlogin
chown -R ${USER}:${GROUB} ${HOME_DIR}/.p10k.zsh
chown -R ${USER}:${GROUB} ${HOME_DIR}/.Xresources
chown -R ${USER}:${GROUB} ${HOME_DIR}/.zshrc
2024-03-10 13:58:36 +03:00
if [[ -d "${HOME_DIR}/.Xresources.d" && -d "${HOME_DIR}/bin" && -f "${HOME_DIR}/.dmrc" && -f "${HOME_DIR}/.face" && -f "${HOME_DIR}/.gtkrc-2.0" && -f "${HOME_DIR}/.hushlogin" && -f "${HOME_DIR}/.p10k.zsh" && -f "${HOME_DIR}/.Xresources" && -f "${HOME_DIR}/.zshrc" ]]; then
2024-02-21 12:55:18 +03:00
echo -e ${BOLD}${GREEN}"[✔] конфигурационные файлы установлены..." ${RESET_COLOR}
echo -e "\n"
else
echo -e ${BOLD}${RED}"[✘] ошибка установки..." ${RESET_COLOR}
fi
echo -e "\n"
}
RUN_MAIN (){
if [[ "${GROUB}" == 'liveuser' ]]; then
exit
else
if [[ ! -d "${CONFIG_DIR}/${FILES_NAME}" ]]; then
INSTALL
else
BACKUP
INSTALL
fi
fi
}
post_install() {
RUN_MAIN
}
post_upgrade() {
RUN_MAIN
}