From 67c2c0f6f62f19b0feedf13f991891ddcf1dbf6b Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 30 Aug 2024 09:41:44 -0600 Subject: add fossil init helper funciton --- bash/.bashrc | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'bash') diff --git a/bash/.bashrc b/bash/.bashrc index 51ee105..421ce28 100644 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -394,5 +394,57 @@ if [[ $(type -t __git_ps1) == function ]]; then # DISABLED because this doesn't work with $(show_virtualenv) #export PROMPT_COMMAND="__git_ps1 '${PS1}' '${END_PS1}'; ${PROMPT_COMMAND}" fi + +# Helper Functions +at-finit() { + local OPTIND name adminuser password + while getopts "n:u:" opt; do + case $opt in + n) + name=$OPTARG + ;; + u) + adminuser=$OPTARG + ;; + \?) + # quit on arg error + return 1 + ;; + esac + done + + if [ -z "$name" ]; then + echo "-n required" + return 1 + fi + if [ -z "$adminuser" ]; then + echo "-u required" + return 1 + fi + + repopath="$HOME/Code/Museum/$name.fossil" + printf "path is: $repopath\n" + + stty -echo + printf "Set admin password: " + read password + stty echo + printf "\n" + + fossil init --template $HOME/Sync/Files/template-repo-v1.fossil --admin-user "$adminuser" "$repopath" > /dev/null + fossil user -R $repopath password $adminuser $password + + chmod 0664 $repopath + rsync --perms $repopath jason@depot.waldorf._.antitech.org:/var/www/htdocs/depot.antitech.org + chmod 0644 $repopath + + urluser=$(echo $adminuser | jq "@uri" -jRr) + urlpasswd=$(echo $password | jq "@uri" -jRr) + echo "Defining remote..." + fossil remote-url -R $repopath https://$urluser:$urlpasswd@depot.antitech.org/$name + + printf "\nSuccess. View your public repository at https://depot.antitech.org/${name}/\n" +} + # Close off the PS1 with the $ PS1=${PS1}${END_PS1} -- cgit v1.2.1