Summary Files Commits Branches @commit @diff @stats
path: root / scripts
diff options
context:
space:
mode:
8 files changed, 218 insertions, 0 deletions
-rwxr-xr-xscripts/checkout18
-rwxr-xr-xscripts/desc25
-rwxr-xr-xscripts/h20
-rwxr-xr-xscripts/homepage37
-rwxr-xr-xscripts/logo37
-rwxr-xr-xscripts/new20
-rwxr-xr-xscripts/private28
-rwxr-xr-xscripts/public33
diff --git a/scripts/checkout b/scripts/checkout
new file mode 100755
index 0000000..26a36b0
--- /dev/null
+++ b/scripts/checkout
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+if [ -z "$1" ]
+then
+ printf 'Repository: '
+ read
+ set "$REPLY"
+fi
+
+if [ -z "$2" ]
+then
+ printf 'Branch : '
+ read
+ set "$1" "$REPLY"
+fi
+
+cd "$1" && \
+git symbolic-ref HEAD refs/heads/"$2"
diff --git a/scripts/desc b/scripts/desc
new file mode 100755
index 0000000..ee7c13b
--- /dev/null
+++ b/scripts/desc
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+if [ -z "$1" ]
+then
+ printf 'Repository : '
+ read
+ set "$REPLY"
+fi
+
+if [ ! -f "$1/HEAD" ]
+then
+ echo 'Not a repository!'
+ exit 1
+fi
+
+if [ -z "$2" ]
+then
+ printf 'Description: '
+ read
+ set "$1" "$REPLY"
+fi
+
+# Beware of https://stackoverflow.com/questions/53465980/how-to-keep-parameter-with-spaces-when-running-remote-script-file-with-ssh
+cd "$1" && \
+git config set --file ./config gitweb.description "$2"
diff --git a/scripts/h b/scripts/h
new file mode 100755
index 0000000..5bdf467
--- /dev/null
+++ b/scripts/h
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+cat <<HELP
+h Print this message
+list Show all repositories (short format)
+list -l Show all repositories (long format)
+
+new <DIR/REPO> Create a repository
+public <DIR/REPO> Make repository publicly accessible
+private <DIR/REPO> Make repository publicly inaccessible
+
+checkout <DIR/REPO> <BRANCH> Set remote's active (default) branch
+desc <DIR/REPO> <DESCRIPTION> Set repository description
+logo <DIR/REPO> <URL> Set repository logo URL
+
+
+Standard tools: cat ed git ln ls mkdir mv new
+Delete : To remove a repository, move it to /trash
+Reorder : To change order of repositories, edit /public_repos
+HELP
diff --git a/scripts/homepage b/scripts/homepage
new file mode 100755
index 0000000..c72c91a
--- /dev/null
+++ b/scripts/homepage
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+if [ -z "$1" ]
+then
+ printf 'Repository : '
+ read
+ set "$REPLY"
+fi
+
+if [ ! -f "$1/HEAD" ]
+then
+ echo 'Not a repository!'
+ exit 1
+fi
+
+if [ ! -w "$1/HEAD" ]
+then
+ echo 'Read-only repository!'
+ exit 2
+fi
+
+if [ -z "$2" ]
+then
+ printf 'Homepage URL: '
+ read
+ set "$1" "$REPLY"
+fi
+
+if cd "$1"
+then
+ if [ "$2" = 'initial' ]
+ then
+ git config unset --file ./config gitweb.homepage
+ else
+ git config set --file ./config gitweb.homepage "$2"
+ fi
+fi
diff --git a/scripts/logo b/scripts/logo
new file mode 100755
index 0000000..d380e00
--- /dev/null
+++ b/scripts/logo
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+if [ -z "$1" ]
+then
+ printf 'Repository: '
+ read
+ set "$REPLY"
+fi
+
+if [ ! -f "$1/HEAD" ]
+then
+ echo 'Not a repository!'
+ exit 1
+fi
+
+if [ ! -w "$1/HEAD" ]
+then
+ echo 'Read-only repository!'
+ exit 2
+fi
+
+if [ -z "$2" ]
+then
+ printf 'Logo URL : '
+ read
+ set "$1" "$REPLY"
+fi
+
+if cd "$1"
+then
+ if [ "$2" = 'initial' ]
+ then
+ git config unset --file ./config cgit.logo
+ else
+ git config set --file ./config cgit.logo "$2"
+ fi
+fi
diff --git a/scripts/new b/scripts/new
new file mode 100755
index 0000000..65e677a
--- /dev/null
+++ b/scripts/new
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+while [ -z "$1" ]
+do
+ printf 'Repository: '
+ read
+ set "$REPLY"
+done
+
+set "${1##/}"
+
+root_dir="${1%%/*}"
+repo_dir="${1#*/}"
+
+cd "$root_dir"
+if git init --bare "$repo_dir"
+then
+ echo -e "\nClone repo with:\n\tgit clone git@syndamia.com:$1"
+ echo -e "\nUpload local repo with:\n\tgit push git@syndamia.com:$1 '*:*'"
+fi
diff --git a/scripts/private b/scripts/private
new file mode 100755
index 0000000..7035c19
--- /dev/null
+++ b/scripts/private
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+if [ -z "$1" ]
+then
+ printf 'Repository: '
+ read
+ set "$REPLY"
+fi
+
+if [ ! -f "$1/HEAD" ]
+then
+ echo 'Repository has been deleted or moved!'
+fi
+
+set "${1##/}"
+
+if echo -e "?^$1\$?" | ed -s /public_repos >/dev/null 2>&1
+then
+ echo -e "g|^$1$|d\nw" | ed -s /public_repos
+ echo "'$1' is now private!"
+elif [ -f "$1/HEAD" ]
+then
+ echo "Already private!"
+else
+ clue="$(echo -e "?$1?" | ed -s /public_repos 2>/dev/null)"
+ [ "$clue" != '?' ] && echo "Perhaps you wanted: $clue"
+ exit 1
+fi
diff --git a/scripts/public b/scripts/public
new file mode 100755
index 0000000..155a81e
--- /dev/null
+++ b/scripts/public
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+if [ -z "$1" ]
+then
+ printf 'Repository: '
+ read
+ set "$REPLY"
+fi
+
+if [ ! -f "$1/HEAD" ]
+then
+ echo 'Not a repository!'
+ exit 1
+fi
+
+set "${1##/}"
+
+# If repo is in file
+if echo -e "?^$1\$?" | ed -s /public_repos >/dev/null 2>&1
+then
+ echo "Already public!"
+# If repo root dir is in file
+elif echo -e "?^${1%%/*}?" | ed -s /public_repos >/dev/null 2>&1
+then
+ echo -e "?^${1%%/*}?a\n$1\n.\nw" | ed -s /public_repos
+ echo "'$1' is now public!"
+# Repo and repo root dir are not anywhere in file
+else
+ echo -e "\$a\n$1\n.\nw" | ed -s /public_repos
+ echo "'$1' is now public!"
+fi
+
+echo "https://git.syndamia.com/$1"