forked from dokku-alt/dokku-alt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommands
More file actions
executable file
·102 lines (82 loc) · 2.59 KB
/
Copy pathcommands
File metadata and controls
executable file
·102 lines (82 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
source "$(dirname $0)/vars"
case "$1" in
access:add)
verify_max_args 1 "$@"
add_ssh_key "admin"
info "$FINGERPRINT added as an admin"
;;
access:remove)
verify_fingerprint "$2"
verify_max_args 2 "$@"
remove_fingerprint "$FINGERPRINT"
for APP in $(ls -d $DOKKU_ROOT/*/ 2>/dev/null); do
if is_fingerprint_allowed "$1"
then
sed --in-place "/^$FINGERPRINT\$/d" "$DOKKU_ROOT/$APP/$DEPLOY_ALLOWED"
fi
done
info "$FINGERPRINT removed!"
;;
access:list)
verify_max_args 1 "$@"
sed -n -e 's/^command="FINGERPRINT=\(.*\) NAME=\(.*\) `.*ssh-\(rsa\|dsa\).*$/\2\t\1/p' "$AUTHORIZED_KEYS"
;;
access:info)
verify_fingerprint "$2"
verify_max_args 2 "$@"
if ! grep "FINGERPRINT=$FINGERPRINT " "$AUTHORIZED_KEYS" # | sed 's/^command="FINGERPRINT=.* NAME=\(.*\) `.*\(ssh-rsa.*$\)/\1\n\2/p'
then
fail "$FINGERPRINT: key not found"
fi
for APP in $(ls -d $DOKKU_ROOT/*/ 2>/dev/null); do
if is_fingerprint_allowed "$1"
then
echo "Push-access to $APP."
fi
done
;;
deploy:allow)
verify_app_name "$2"
verify_max_args 2 "$@"
add_ssh_key "deploy" "deploy"
if ! is_fingerprint_allowed "$FINGERPRINT"
then
echo "$FINGERPRINT" >> "$APP_DIR/$DEPLOY_ALLOWED"
info "$FINGERPRINT added to $APP as an deployment key"
else
info "$FINGERPRINT is already added to $APP as an deployment key"
fi
;;
deploy:list)
verify_app_name "$2"
verify_max_args 2 "$@"
cat "$APP_DIR/$DEPLOY_ALLOWED" 2>/dev/null || true
;;
deploy:revoke)
verify_app_name "$2"
verify_fingerprint "$3"
verify_max_args 3 "$@"
if is_fingerprint_allowed "$FINGERPRINT"
then
sed --in-place "/^$FINGERPRINT\$/d" "$APP_DIR/$DEPLOY_ALLOWED"
info "$FINGERPRINT removed from an $APP as an deployment key"
else
info "$FINGERPRINT is not added to $APP as an deployment key"
fi
;;
help)
cat && cat<<EOF
access:add Add admin user
access:list List all SSH keys: admins and deployments
access:info <fingeprint> Show information about the key
access:remove <fingerprint> Revoke all permissions for specific SSH key
deploy:allow <app> Allow push-access (aka. deployment) to an app
deploy:list <app> List all push-acccesses for an application
deploy:revoke <app> <fingerprint> Revoke push-access for an application
EOF
;;
*)
exit $DOKKU_NOT_IMPLEMENTED_EXIT
;;
esac