tgitzone-shell - gitzone - git-based zone management tool for static and dynamic domains
HTML git clone https://git.parazyd.org/gitzone
DIR Log
DIR Files
DIR Refs
---
tgitzone-shell (1936B)
---
1 #!/bin/sh
2 #
3 # gitzone-shell - restrictive shell for gitzone
4 #
5 # Copyright (C) 2011 - 2019 Dyne.org Foundation
6 #
7 # This program is free software: you can redistribute it and/or modify it under
8 # the terms of the GNU Affero General Public License as published by the Free
9 # Software Foundation, either version 3 of the License, or (at your option) any
10 # later version.
11 #
12 # This program is distributed in the hope that it will be useful, but WITHOUT
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
15 # details.
16 #
17 # You should have received a copy of the GNU Affero General Public License along
18 # with this program. If not, see <http://www.gnu.org/licenses/>.
19
20
21 # only repo allowed for git pull/push
22 repo=$LOGNAME
23 # directory the repo is in, relative to $HOME
24 repo_dir='zones'
25 #repo_dir='.'
26
27 # allow ssh key add/del/list commands if this file exists
28 allow_key_mgmt_file='.ssh/authorized_keys_edit_allowed'
29
30 # paths
31 config=/etc/gitzone.conf
32 gitzone=/usr/bin/gitzone
33 git=/usr/bin/git
34 grep=/bin/grep
35
36 error() {
37 echo "fatal: What do you think I am? A shell?"
38 exit 127
39 }
40
41 if [ "$1" != "-c" ]; then error; fi
42 cmd=$2
43
44 case "$cmd" in
45 git-upload-pack*)
46 $git upload-pack "$repo_dir/$repo"
47 exit $?
48 ;;
49 git-receive-pack*)
50 $git receive-pack "$repo_dir/$repo"
51 exit $?
52 ;;
53 update-record*)
54 cd "$repo_dir/$repo/.git" || exit 1
55 $gitzone "$config" update-record "$cmd"
56 exit $?
57 ;;
58 esac
59
60 if [ -f "$allow_key_mgmt_file" ]; then
61 case "$cmd" in
62 list-keys)
63 cat .ssh/authorized_keys
64 exit $?
65 ;;
66 add-key*)
67 key="$(echo "$cmd" | cut -c9-)"
68 echo "$key" >> .ssh/authorized_keys && echo "key added"
69 exit $?
70 ;;
71 del-key*)
72 key="$(echo "$cmd" | cut -c9-)"
73 $grep -v "$key" .ssh/authorized_keys > .ssh/authorized_keys-new || exit 1
74 mv .ssh/authorized_keys-new .ssh/authorized_keys && echo "key deleted"
75 exit $?
76 ;;
77 esac
78 fi
79
80 error