Compare commits
9 commits
1d1250a3e0
...
4bea622902
Author | SHA1 | Date | |
---|---|---|---|
4bea622902 | |||
c969deb7b1 | |||
f0082107ef | |||
27c9d64564 | |||
a1b6b40396 | |||
a3f1bace8a | |||
8376b74e88 | |||
07c6503862 | |||
b36e3631ab |
6 changed files with 36 additions and 17 deletions
|
@ -6,7 +6,7 @@ begin
|
||||||
function configureSW -V dir
|
function configureSW -V dir
|
||||||
source "$dir/../bash/profile.fish"
|
source "$dir/../bash/profile.fish"
|
||||||
source "$dir/../fish/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"
|
sudo install -Dm644 "$dir/aliae.yml" "$file"
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -24,7 +24,7 @@ services:
|
||||||
- ./data/forgejo:/data
|
- ./data/forgejo:/data
|
||||||
- config:/data/gitea/conf
|
- config:/data/gitea/conf
|
||||||
- /etc/timezone:/etc/timezone:ro
|
- /etc/timezone:/etc/timezone:ro
|
||||||
- /home/forgejo/.ssh:/data/git/.ssh
|
- /srv/git/.ssh:/data/git/.ssh
|
||||||
db:
|
db:
|
||||||
image: mariadb
|
image: mariadb
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
set -l user forgejo
|
set -l user git
|
||||||
set -l domain git
|
set -l domain git
|
||||||
set -l server "$domain" ""
|
set -l server "$domain" ""
|
||||||
set -l service $user
|
set -l service "forgejo"
|
||||||
source "$dir/../service.fish"
|
source "$dir/../service.fish"
|
||||||
|
|
||||||
function getSSHPortKey -V service
|
function getSSHPortKey -V service
|
||||||
|
@ -48,6 +48,9 @@ begin
|
||||||
set -l port
|
set -l port
|
||||||
set -l file (mktemp)
|
set -l file (mktemp)
|
||||||
set -l root (getServiceRoot $argv)
|
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 dir "$root/data"
|
||||||
set -l bin /usr/local/bin/forgejo
|
set -l bin /usr/local/bin/forgejo
|
||||||
set -l config "$root/docker-compose.base.yml"
|
set -l config "$root/docker-compose.base.yml"
|
||||||
|
@ -60,29 +63,37 @@ begin
|
||||||
--system \
|
--system \
|
||||||
--shell /bin/bash \
|
--shell /bin/bash \
|
||||||
--comment 'Git Version Control' \
|
--comment 'Git Version Control' \
|
||||||
--create-home \
|
|
||||||
$user
|
$user
|
||||||
|
|
||||||
set uid (id -u $user)
|
set uid (id -u $user)
|
||||||
set gid (id -g $user)
|
set gid (id -g $user)
|
||||||
|
and sudo usermod -d "$home" "$user"
|
||||||
|
|
||||||
and yq "$envKey.USER_UID = $uid" "$file" |
|
and yq "$envKey.USER_UID = $uid" "$file" |
|
||||||
yq "$envKey.USER_GID = $gid" |
|
yq "$envKey.USER_GID = $gid" |
|
||||||
sudo tee "$config" >/dev/null
|
sudo tee "$config" >/dev/null
|
||||||
|
|
||||||
sudo mkdir -p "$dir"
|
|
||||||
and sudo chown -R $uid:$gid "$dir"
|
|
||||||
rm "$file"
|
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)
|
set port (yq (getSSHPortKey) "$overrides" | extractPort)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
printf "%s\n" \
|
printf "%s\n" \
|
||||||
"#!/bin/sh" \
|
"#!/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
|
end | sudo tee "$bin" >/dev/null
|
||||||
|
|
||||||
sudo chmod +x "$bin"
|
sudo chmod +x "$bin"
|
||||||
|
sudo ln -s "$bin" "$(dirname "$bin")/gitea"
|
||||||
end
|
end
|
||||||
|
|
||||||
function getServiceServers -V server
|
function getServiceServers -V server
|
||||||
|
|
|
@ -83,6 +83,7 @@ begin
|
||||||
"$_flag_name" / "" (
|
"$_flag_name" / "" (
|
||||||
for app in $servarr
|
for app in $servarr
|
||||||
printf "%s\n" "$app" "/$app" ""
|
printf "%s\n" "$app" "/$app" ""
|
||||||
|
printf "%s\n" "$app" "/$app/signalr" ""
|
||||||
end) \
|
end) \
|
||||||
flood "/flood/"
|
flood "/flood/"
|
||||||
end
|
end
|
||||||
|
@ -107,22 +108,29 @@ begin
|
||||||
'return 302 $scheme://$host$uri/$is_args$args;' \
|
'return 302 $scheme://$host$uri/$is_args$args;' \
|
||||||
"}"
|
"}"
|
||||||
else
|
else
|
||||||
getServiceDefaultProxy $argv --path "$location"
|
getServiceDefaultProxy $argv
|
||||||
end
|
end
|
||||||
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 [ "$s" = "$service" ]
|
||||||
if [ "$location" = / ]
|
if [ "$location" = / ]
|
||||||
printf "%s\n" \
|
printf "%s\n" \
|
||||||
"# Disable buffering when the nginx proxy gets very resource heavy upon streaming" \
|
"# Disable buffering when the nginx proxy gets very resource heavy upon streaming" \
|
||||||
"proxy_buffering off;"
|
"proxy_buffering off;"
|
||||||
else if [ "$location" = /socket ]
|
else if [ "$location" = /socket ]
|
||||||
printf "%s\n" \
|
echo "$wsConfig"
|
||||||
'# Websocket' \
|
end
|
||||||
"proxy_http_version 1.1;" \
|
else if contains "$s" $servarr
|
||||||
'proxy_set_header Upgrade $http_upgrade;' \
|
if string match --regex ".*/signalr^" "$location" >/dev/null
|
||||||
'proxy_set_header Connection "upgrade";'
|
echo "$wsConfig"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ begin
|
||||||
set -l file (mktemp)
|
set -l file (mktemp)
|
||||||
|
|
||||||
if [ -z "$title" ]
|
if [ -z "$title" ]
|
||||||
set -l title "$name"
|
set title "$name"
|
||||||
end
|
end
|
||||||
|
|
||||||
if [ -z "$content" ]
|
if [ -z "$content" ]
|
||||||
|
|
|
@ -73,7 +73,7 @@ begin
|
||||||
set _flag_script $argv[1]
|
set _flag_script $argv[1]
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
function runPSUserConfig
|
function runPSUserConfig
|
||||||
|
|
Loading…
Reference in a new issue