personal-linux-config/deploy.sh

79 lines
1.7 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2022-02-10 15:08:13 +00:00
THIS="$(dirname "$(readlink -fm "$0")")"
2021-06-03 15:45:49 +00:00
SERVER=false
2022-02-10 15:02:35 +00:00
DELETE=false
MOVE=false
_arguments() {
for PARM in "$@"; do
if [ "${PARM}" = "--server" ]; then
2021-06-03 15:45:49 +00:00
SERVER=true
2022-02-10 15:02:35 +00:00
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"
2022-02-10 15:02:35 +00:00
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
}
2022-02-10 15:02:35 +00:00
_delete() {
sed -i '/REF:bashrc_overrides:REF/{N;d}' ~/.bashrc
}
_bashrc_ref() {
echo "#REF:bashrc_overrides:REF" >> ~/.bashrc
echo ". ${THIS}/bashrc_overrides/_all" >> ~/.bashrc
}
2022-02-10 15:02:35 +00:00
_move() {
_delete
_bashrc_ref
}
_main() {
_arguments "$@"
2022-02-10 15:02:35 +00:00
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
2022-02-10 15:33:07 +00:00
sed -i 's/terminal_fancyfying/terminal_fancyfying_server/' ${THIS}/bashrc_overrides/_all
else
2022-02-10 15:33:07 +00:00
sed -i 's/terminal_fancyfying_server/terminal_fancyfying/' ${THIS}/bashrc_overrides/_all
fi
}
_main "$@"