diff --git a/scripts/Common/Software/docker/services/forgejo/main.fish b/scripts/Common/Software/docker/services/forgejo/main.fish index 6d3f3d36..ca72f19e 100755 --- a/scripts/Common/Software/docker/services/forgejo/main.fish +++ b/scripts/Common/Software/docker/services/forgejo/main.fish @@ -49,6 +49,8 @@ begin set -l file (mktemp) set -l root (getServiceRoot $argv) set -l home /srv/git + set -l sshDir "$home/.ssh" + set -l keyFile "$sshDir/id_rsa" set -l dir "$root/data" set -l bin /usr/local/bin/forgejo set -l config "$root/docker-compose.base.yml" @@ -71,12 +73,16 @@ begin yq "$envKey.USER_GID = $gid" | sudo tee "$config" >/dev/null + rm "$file" + and sudo mkdir -p "$dir" and sudo mkdir -p "$home" and sudo chown -R $uid:$gid "$dir" and sudo chown -R $uid:$gid "$home" - and sudo -u "#$uid" mkdir -p ~"$user"/.ssh - rm "$file" + and sudo -u "#$uid" mkdir -p "$sshDir" + and sudo -u "#$uid" ssh-keygen -t rsa -b 4096 -C "Forgejo Host Key" -f "$keyFile" -N "" + and sudo -u "#$uid" cat "$keyFile.pub" | sudo -u "#$uid" tee -a "$sshDir/authorized_keys" + and sudo chmod 600 "$sshDir/authorized_keys" set port (yq (getSSHPortKey) "$overrides" | extractPort)