106 lines
3.9 KiB
Bash
106 lines
3.9 KiB
Bash
#!/bin/bash
|
|
|
|
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"
|
|
|
|
USER=`echo ${SUDO_USER:-$(whoami)}`
|
|
GID=`echo ${SUDO_GID}`
|
|
GROUB=`cat /etc/group | grep ${GID} | cut -d: -f1 | head -1`
|
|
HOME_DIR="/home/${USER}"
|
|
BACKUP_DIR="${HOME_DIR}/.tarch-backups"
|
|
SKEL_DIR="/etc/skel"
|
|
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}
|
|
mv ${HOME_DIR}/bin ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
|
|
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}
|
|
|
|
echo -e ${CYAN}" ==> перемещяем текущие настройки дял пользователя: ${PURPLE}${USER}" ${RESET_COLOR}
|
|
cp -rf ${SKEL_DIR}/.Xresources.d ${HOME_DIR}
|
|
cp -rf ${SKEL_DIR}/bin ${HOME_DIR}
|
|
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}
|
|
|
|
echo -e ${CYAN}" ==> предоставление разрешений для пользователя: ${PURPLE}${USER}" ${RESET_COLOR}
|
|
chown -R ${USER}:${GROUB} ${HOME_DIR}/.Xresources.d
|
|
chown -R ${USER}:${GROUB} ${HOME_DIR}/bin
|
|
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
|
|
|
|
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
|
|
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
|
|
}
|