personal-linux-config/deploy.sh

69 lines
1.5 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
THIS="$(dirname "$(readlink -fm "$0")")"
2021-06-03 15:45:49 +00:00
SERVER=false
FORCE=false
CLEANUP=false
_arguments() {
for PARM in "$@"; do
if [ "${PARM}" = "--server" ]; then
2021-06-03 15:45:49 +00:00
SERVER=true
2021-06-03 15:44:18 +00:00
elif [ "${PARM}" = "--force" ]; then
2021-06-03 15:45:49 +00:00
FORCE=true
elif [ "${PARM}" = "--cleanup" ]; then
2021-06-03 15:45:49 +00:00
CLEANUP=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 : Prints this help message and quits"
echo " --server: Customizes the terminal feel for a server installation"
echo " --cleanup: Removes the source folder after installation"
echo
}
_bash_overrides() {
2021-01-11 14:36:24 +00:00
cp -r bashrc_overrides ~/.bashrc_overrides
echo "#REF:bashrc_overrides:REF" >> ~/.bashrc
echo "if [ -f ~/.bashrc_overrides/_all ]; then" >> ~/.bashrc
2021-03-21 11:27:45 +00:00
echo " . ~/.bashrc_overrides/_all" >> ~/.bashrc
echo "fi" >> ~/.bashrc
}
_cleanup() {
rm -rf ${THIS}
}
_main() {
_arguments "$@"
2021-06-03 15:45:49 +00:00
if [ ! -z "$(grep "#REF:bashrc_overrides:REF" ~/.bashrc)" ] && [ "${FORCE}" = false ]; then
echo "bash overrides already in place"
echo "skipping..."
echo
else
_bash_overrides
echo "bash overrides added"
echo
fi
if [ "${SERVER}" = true ]; then
sed -i 's/terminal_fancyfying/terminal_fancyfying_server/' ~/.bashrc_overrides/_all
fi
if [ "${CLEANUP}" = true ]; then
echo "cleaning up..."
_cleanup
fi
}
_main "$@"