v0.1.0
working version (for now)
This commit is contained in:
commit
35034ad496
58
deploy.sh
58
deploy.sh
@ -1,16 +1,58 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
THIS="$(pwd)"
|
THIS="$(dirname "$(readlink -fm "$0")")"
|
||||||
|
CLEANUP=true
|
||||||
|
|
||||||
_cleanup() {
|
_arguments() {
|
||||||
echo -e "#!/usr/bin/env bash" >> /tmp/deploy_cleanup.sh
|
for PARM in "$@"; do
|
||||||
echo -e "rm -rf ${THIS}" >> /tmp/deploy_cleanup.sh
|
if [ "${PARM}" = "--no-cleanup" ]; then
|
||||||
echo -e "crontab -l | sed '/# REF:deploy_cleanup:REF/Q' | crontab -" >> /tmp/deploy_cleanup.sh
|
CLEANUP=false
|
||||||
chmod +x /tmp/deploy_cleanup.sh
|
elif [ "${PARM}" = "-h" ] || [ "${PARM}" = "--help" ]; then
|
||||||
echo -e "$(crontab -l)\n# REF:deploy_cleanup:REF\n* * * * *\t/tmp/deploy_cleanup.sh" | crontab -
|
_help
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
_help() {
|
||||||
|
echo "Usage: $(readlink -fm "$0") [-h | --help] [--no-cleanup]"
|
||||||
|
echo
|
||||||
|
echo "Options:"
|
||||||
|
echo " -h | --help : Prints this help message and quits"
|
||||||
|
echo " --no-cleanup: Does not clean the source folder after adding the bash overrides"
|
||||||
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash_overrides() {
|
_bash_overrides() {
|
||||||
cp -r bashrc_overrides ~/.bashrc_overrides
|
cp -r bashrc_overrides ~/.bashrc_overrides
|
||||||
echo -e "if [ -f ~/.bashrc_overrides/_all ]; then\n . ~/.bashrc_overrides/_all\nfi" >> ~/.bashrc
|
echo "#REF:bashrc_overrides:REF" >> ~/.bashrc
|
||||||
|
echo "if [ -f ~/.bashrc_overrides/_all ]; then" >> ~/.bashrc
|
||||||
|
echo " . ~/.bashrc_overrides/_all" >> ~/.bashrc
|
||||||
|
echo "fi" >> ~/.bashrc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_cleanup() {
|
||||||
|
rm -rf ${THIS}
|
||||||
|
>>>>>>> master
|
||||||
|
}
|
||||||
|
|
||||||
|
_main() {
|
||||||
|
_arguments "$@"
|
||||||
|
|
||||||
|
if [ ! -z "$(grep "#REF:bashrc_overrides:REF" ~/.bashrc)" ]; then
|
||||||
|
echo "bash overrides already in place"
|
||||||
|
echo "skipping..."
|
||||||
|
echo
|
||||||
|
else
|
||||||
|
_bash_overrides
|
||||||
|
echo "bash overrides added"
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${CLEANUP}" = true ]; then
|
||||||
|
echo "cleaning up..."
|
||||||
|
_cleanup
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_main "$@"
|
||||||
|
Loading…
Reference in New Issue
Block a user