tarch-misc/tarch-misc.install
2024-02-21 12:55:18 +03:00

93 lines
3.7 KiB
Bash

#!/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`
HOME_DIR="home/${USER}"
BACKUP_DIR="/home/${HOME_DIR}/.tarch-backups"
CONFIG_DIR_SKEL="/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}/.mplayer ${BACKUP_DIR}/${FILES_NAME}-${BACKUP_NAME}-${BACKUP_RANDOM}
mv ${HOME_DIR}/.Xresources.d ${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}
cp -rf ${HOME_DIR_SKEL}/.mplayer ${HOME_DIR}
cp -rf ${HOME_DIR_SKEL}/.Xresources.d ${HOME_DIR}
cp ${HOME_DIR_SKEL}/.dmrc ${HOME_DIR}
cp ${HOME_DIR_SKEL}/.face ${HOME_DIR}
cp ${HOME_DIR_SKEL}/.gtkrc-2.0 ${HOME_DIR}
cp ${HOME_DIR_SKEL}/.hushlogin ${HOME_DIR}
cp ${HOME_DIR_SKEL}/.p10k.zsh ${HOME_DIR}
cp ${HOME_DIR_SKEL}/.Xresources ${HOME_DIR}
cp ${HOME_DIR_SKEL}/.zshrc ${HOME_DIR}
echo -e ${CYAN}" ==> предоставление разрешений для пользователя: ${PURPLE}${USER}" ${RESET_COLOR}
chown -R ${USER}:${GROUB} ${HOME_DIR}/.mplayer
chown -R ${USER}:${GROUB} ${HOME_DIR}/.Xresources.d
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}/.mplayer" && -d "${HOME_DIR}/.Xresources.d" && -f "${HOME_DIR}/.dmrc" && -f "${HOME_DIR}/.face" && -f "${HOME_DIR}/.fehbg" && -f "${HOME_DIR}/.gtkrc-2.0" && -f "${HOME_DIR}/.hushlogin" && -f "${HOME_DIR}/.p10k.zsh" && -f "${HOME_DIR}/.Xresources" && -f "${HOME_DIR}/.xsettingsd" && -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
}