-
-
Save green-leader/862d0ccfc5cf82fc650da54fe14d5ff5 to your computer and use it in GitHub Desktop.
Obsidian Sync Code
This file contains hidden or 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
| # update and upgrade installed packages | |
| apt update && apt upgrade | |
| # install cronie and termux-services | |
| pkg install cronie termux-services | |
| # enable the crond service | |
| sv-enable crond | |
| # install and enable vim | |
| pkg install vim | |
| export EDITOR=vim | |
| # install git and openssh | |
| apt install git openssh | |
| # set git username and email | |
| git config --global user.name "<name>" | |
| git config --global user.email "<email>" | |
| # create your ssh keys | |
| ssh-keygen -t rsa -C "<email>" | |
| # create symlinks to access your device storage via termux | |
| termux-setup-storage | |
| # move your public ssh key to somewhere more easily accessible | |
| mv ~/.ssh/id_rsa.pub ~/storage/shared/documents/id_rsa.pub | |
| # clone your vault | |
| git clone [email protected]:<user>/<repo> ~/storage/shared/documents/my-vault | |
| # install wget and download zk_sync.sh | |
| pkg install wget | |
| cd ~/storage/shared/documents | |
| wget https://gist.github.com/green-leader/862d0ccfc5cf82fc650da54fe14d5ff5/raw/e4136f26393f7352354da9d6ffec3751a5aefe97/sync.sh | |
| # -e: edit your crontab file i.e. your list of cronjobs | |
| crontab -e | |
| # My Cron Job: | |
| # */30 * * * * bash ~/storage/shared/documents/zk_sync.sh |
This file contains hidden or 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
| #!/bin/bash | |
| set -o nounset | |
| set -o errexit | |
| # Check if the WORKDIR environmental variable is set | |
| if [[ -z "${WORKDIR+x}" ]]; then | |
| # If not set, use the current directory | |
| cd . | |
| else | |
| # Otherwise, use the directory specified by WORKDIR | |
| cd "$WORKDIR" | |
| fi | |
| git pull --rebase --autostash | |
| git add --all | |
| git commit --message "autosync: $(date +"%Y-%m-%d %H:%M:%S")" | |
| git push --quiet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment