Created
October 6, 2022 14:35
-
-
Save guentur/95004a6dfeb0878effff22266da44bc6 to your computer and use it in GitHub Desktop.
To run it automatically when computer turns off past this file to /etc/init.d/ folder and create a symbol link to it in /etc/rc0.d and /etc/rc6.d. At least that what I have red in this [article](https://askubuntu.com/questions/83473/how-to-execute-script-on-shutdown)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
REPO_PATH='/media/user/Documents/Repo_folder' | |
BRANCH_NAME='laptop_dell_vostro_3590' | |
if [ -d '/media/user/Documents/Repo_folder' ] | |
then | |
DATE=$(date) | |
cd '/media/user/Documents/Repo_folder' | |
EXISTS=`git show-ref refs/heads/$BRANCH_NAME` | |
if [ -n "$EXISTS" ] | |
then | |
git checkout $BRANCH_NAME | |
else | |
git checkout master | |
git checkout -b $BRANCH_NAME | |
fi | |
git pull | |
git add . | |
git commit -m "Changes added on $DATE" | |
git push --set-upstream origin $BRANCH_NAME | |
else | |
FAILURE_MESSAGE="Directory $REPO_PATH DOES NOT exists." | |
echo $FAILURE_MESSAGE | |
exit 9999 # die with error code 9999 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment