Compare commits

...

9 commits

6 changed files with 36 additions and 17 deletions

View file

@ -6,7 +6,7 @@ begin
function configureSW -V dir
source "$dir/../bash/profile.fish"
source "$dir/../fish/profile.fish"
set -l file (pwsh -CommandWithArgs '. $args[0]; Get-GlobalConfigPath' "$dir/Constants.ps1")
set -l file (pwsh -NoProfile -CommandWithArgs '. $args[0]; Get-GlobalConfigPath' "$dir/Constants.ps1")
sudo install -Dm644 "$dir/aliae.yml" "$file"
begin

View file

@ -24,7 +24,7 @@ services:
- ./data/forgejo:/data
- config:/data/gitea/conf
- /etc/timezone:/etc/timezone:ro
- /home/forgejo/.ssh:/data/git/.ssh
- /srv/git/.ssh:/data/git/.ssh
db:
image: mariadb
restart: unless-stopped

View file

@ -1,10 +1,10 @@
#!/bin/env fish
begin
set -l dir (status dirname)
set -l user forgejo
set -l user git
set -l domain git
set -l server "$domain" ""
set -l service $user
set -l service "forgejo"
source "$dir/../service.fish"
function getSSHPortKey -V service
@ -48,6 +48,9 @@ begin
set -l port
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"
@ -60,29 +63,37 @@ begin
--system \
--shell /bin/bash \
--comment 'Git Version Control' \
--create-home \
$user
set uid (id -u $user)
set gid (id -g $user)
and sudo usermod -d "$home" "$user"
and yq "$envKey.USER_UID = $uid" "$file" |
yq "$envKey.USER_GID = $gid" |
sudo tee "$config" >/dev/null
sudo mkdir -p "$dir"
and sudo chown -R $uid:$gid "$dir"
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 "$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)
begin
printf "%s\n" \
"#!/bin/sh" \
"ssh -p $port -o StrictHostKeyChecking=no git@127.0.0.1 \"SSH_ORIGINAL_COMMAND=\\\"$SSH_ORIGINAL_COMMAND\\\" \$0 \$@\""
"ssh -p $port -o StrictHostKeyChecking=no git@127.0.0.1 \"SSH_ORIGINAL_COMMAND=\\\"\$SSH_ORIGINAL_COMMAND\\\" \$0 \$@\""
end | sudo tee "$bin" >/dev/null
sudo chmod +x "$bin"
sudo ln -s "$bin" "$(dirname "$bin")/gitea"
end
function getServiceServers -V server

View file

@ -83,6 +83,7 @@ begin
"$_flag_name" / "" (
for app in $servarr
printf "%s\n" "$app" "/$app" ""
printf "%s\n" "$app" "/$app/signalr" ""
end) \
flood "/flood/"
end
@ -107,22 +108,29 @@ begin
'return 302 $scheme://$host$uri/$is_args$args;' \
"}"
else
getServiceDefaultProxy $argv --path "$location"
getServiceDefaultProxy $argv
end
end
function getExtraLocationSettings -a domain s location -V service
function getExtraLocationSettings -a domain s location -V service -V servarr
set -l wsConfig (
printf "%s\n" \
'# Websocket' \
"proxy_http_version 1.1;" \
'proxy_set_header Upgrade $http_upgrade;' \
'proxy_set_header Connection "upgrade";')
if [ "$s" = "$service" ]
if [ "$location" = / ]
printf "%s\n" \
"# Disable buffering when the nginx proxy gets very resource heavy upon streaming" \
"proxy_buffering off;"
else if [ "$location" = /socket ]
printf "%s\n" \
'# Websocket' \
"proxy_http_version 1.1;" \
'proxy_set_header Upgrade $http_upgrade;' \
'proxy_set_header Connection "upgrade";'
echo "$wsConfig"
end
else if contains "$s" $servarr
if string match --regex ".*/signalr^" "$location" >/dev/null
echo "$wsConfig"
end
end
end

View file

@ -8,7 +8,7 @@ begin
set -l file (mktemp)
if [ -z "$title" ]
set -l title "$name"
set title "$name"
end
if [ -z "$content" ]

View file

@ -73,7 +73,7 @@ begin
set _flag_script $argv[1]
end
pwsh -CommandWithArgs '& $args[0] $args[1] @{ name=$args[2]; }' "$_flag_script" "$_flag_action" "$_flag_user"
pwsh -NoProfile -CommandWithArgs '& $args[0] $args[1] @{ name=$args[2]; }' "$_flag_script" "$_flag_action" "$_flag_user"
end
function runPSUserConfig