summaryrefslogtreecommitdiff
path: root/init
diff options
context:
space:
mode:
Diffstat (limited to 'init')
-rwxr-xr-xinit18
1 files changed, 11 insertions, 7 deletions
diff --git a/init b/init
index 44f46e3..fd081a8 100755
--- a/init
+++ b/init
@@ -10,7 +10,9 @@ set _REPO_PERMISSIONS /etc/repo-permissions
set _REPO_REGEX "^((?:\/[a-zA-Z-]+)+.git)\$"
function createUser
- set -l user $argv[1]
+ set -l userConfig (string split ':' $argv[1])
+ set -l user $userConfig[1]
+ set -l key $userConfig[2]
echo "Setting up user: $user"
if [ "$user" = git ]
echo "Error: User git is reserved"
@@ -24,7 +26,7 @@ function createUser
# unlock account to allow ssh logins
passwd -u "$user"
mkdir "$HOME/.ssh"
- cp "/var/ssh/clients/$user" "$HOME/.ssh/authorized_keys"
+ echo "$key" > "$HOME/.ssh/authorized_keys"
chown -R $user "$HOME"
chmod -R 700 "$HOME"
end
@@ -74,9 +76,9 @@ if set -q _flag_h
echo -e ""
echo -e "OPTIONS"
echo -e "\t -h, --help \t\t Display this page"
- echo -e "\t -g, --git-uid \t UID of the git user that is used also as ownership for all repos"
- echo -e "\t -u, --user \t\t Setting up a user"
- echo -e "\t -r, --repo \t\t Setting up a repo in form <repo-path>[:user1]+ for each user who should have access to it"
+ echo -e "\t -g, --git-uid \t\t UID of the git user that is used also as ownership for all repos"
+ echo -e "\t -u, --user \t\t User setting in form of <user-name>:<public-key>"
+ echo -e "\t -r, --repo \t\t Repo setting in form of <repo-path>:<allowed-user1>. You can add as many users as you want. Currently if a user is allowed he has all permissions read/write"
echo -e ""
return
end
@@ -97,9 +99,11 @@ if set -q $_flag_g
end
# Setup users
+# git user has read/write access to all repos, set git-shell
+# and no password login allowed -> no ssh login possible
adduser git -u $GIT_UID -D --shell "/usr/bin/git-shell"
-for user in $users
- createUser "$user"
+for userConfig in $users
+ createUser "$userConfig"
end
# Setup repos