personal-linux-config/deploy.sh

79 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
THIS="$(dirname "$(readlink -fm "$0")")"
SERVER=false
DELETE=false
MOVE=false
_arguments() {
for PARM in "$@"; do
if [ "${PARM}" = "--server" ]; then
SERVER=true
elif [ "${PARM}" = "--delete" ]; then
DELETE=true
elif [ "${PARM}" = "--move" ]; then
MOVE=true
elif [ "${PARM}" = "-h" ] || [ "${PARM}" = "--help" ]; then
_help
exit 0
fi
done
}
_help() {
echo "Usage: $(readlink -fm "$0") [-h | --help] [--cleanup]"
echo
echo "Options:"
echo " -h | --help"
echo " Prints this help message and quits"
echo " --force"
echo " Force the reinstallation of the files"
echo " --delete"
echo " Delete the reference in ~/.bashrc"
echo " --move"
echo " Create a new reference if the location of this folder has been changed"
echo " --server"
echo " Customizes the terminal feel for a server installation"
echo
}
_delete() {
sed -i '/REF:bashrc_overrides:REF/{N;d}' ~/.bashrc
}
_bashrc_ref() {
echo "#REF:bashrc_overrides:REF" >> ~/.bashrc
echo ". ${THIS}/bashrc_overrides/_all" >> ~/.bashrc
}
_move() {
_delete
_bashrc_ref
}
_main() {
_arguments "$@"
if [ "${DELETE}" = true ]; then
_delete
elif [ "${MOVE}" = true ]; then
_move
elif [ ! -z "$(grep "#REF:bashrc_overrides:REF" ~/.bashrc)" ]; then
echo "bash overrides already in place"
echo "skipping..."
echo
else
_bashrc_ref
echo "bash overrides added"
echo
fi
if [ "${SERVER}" = true ]; then
sed -i 's/terminal_fancyfying/terminal_fancyfying_server/' ${THIS}/bashrc_overrides/_all
else
sed -i 's/terminal_fancyfying_server/terminal_fancyfying/' ${THIS}/bashrc_overrides/_all
fi
}
_main "$@"