pango-install.sh
· 3.3 KiB · Bash
Surowy
# pango.install: $app_domain $app_port
pango.install(){
# Config #
app_name="pango" # App Name
app_repo_url="https://github.com/fosrl/pangolin" # App Codebase
app_version="latest"
app_domain="${1:-"$app_name.$org_domain"}" # Unique app domain
app_port="${2:-"3030"}" # App Port
api_port="$((app_port + 1))"
api2_port="$((app_port + 2))"
container_name="$app_name-$app_port"
app_name_domain="$(echo $app_domain | tr "." "-")"
app_path="/data/${app_name_domain}"
app_container_config="$app_path/docker-compose.yml"
# Setup paths #
mkdir -p "$app_path"
echo cd "$app_path"
cd "$app_path"
if [ ! $? == "0" ];then
err "Failed to cd \"$app_path\""
return 1
fi
# if file exists
if [[ ! -e "installer" ]];then
# not exists
echo Downloading Installer
curl -fsSL https://static.pangolin.net/get-installer.sh | bash
fi
if [[ ! -d "config" ]];then
echo Running Installer
./installer
fi
# Write docker-compose config
tee "$app_container_config" > /dev/null <<EOF
name: $app_name
services:
$app_name:
container_name: $container_name
image: docker.io/fosrl/pangolin:1.20.0
restart: always
deploy:
resources:
limits:
memory: 2g
reservations:
memory: 512m
ports:
- $app_port:3002
- $api_port:3000
- $api2_port:3001
volumes:
- ./config:/app/config
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3001/api/v1/"]
interval: "10s"
timeout: "10s"
retries: 15
extra_hosts:
- "host.docker.internal:host-gateway"
gerbil:
image: docker.io/fosrl/gerbil:1.4.2
container_name: gerbil
restart: always
depends_on:
$app_name:
condition: service_healthy
command:
- --reachableAt=http://gerbil:3004
- --generateAndSaveKeyTo=/var/config/key
- --remoteConfig=http://$app_name:3001/api/v1/
volumes:
- ./config/:/var/config
cap_add:
- NET_ADMIN
- SYS_MODULE
ports:
- 21820:21820/udp
- 51800:51800/udp
#- 443:443
#- 443:443/udp # For http3 QUIC if desired
#- 80:80
networks:
default:
driver: bridge
name: pangolin_frontend
EOF
caddy_domain="domain.com"
caddy_email="your@email.com"
caddy_ip="your_ip"
cat <<EOF
# Caddy Config:
$caddy_domain {
encode gzip
tls $caddy_email
# 3030 Web
handle {
reverse_proxy $caddy_ip:3030
}
# 3031 API
handle_path /api/* {
rewrite * /api{uri}
reverse_proxy $caddy_ip:3031
}
# 3032 API Docs
handle_path /api2/* {
rewrite * /api2{uri}
reverse_proxy $caddy_ip:3032
}
}
# ---
EOF
#dasel -i yaml --root 'app.telemetry.anonymous_usage = false' < config.yml > config.yml
#dasel -i yaml --root 'gerbil.start_port = 51800' < config.yml > config.yml
dasel.edit yaml 'app.telemetry.anonymous_usage = false' "$app_path/config/config.yml"
dasel.edit yaml 'gerbil.start_port = 51800' "$app_path/config/config.yml"
dasel.edit yaml '{$root..., "flags": {flags..., "disable_enterprise_features": true}}' "$app_path/config/config.yml"
# Run App. LIVE!
echo Running $app_name container in the background.
echo sudo docker-compose pull
sudo docker-compose pull
echo sudo docker-compose down
sudo docker-compose down
echo sudo docker-compose up -d
sudo docker-compose up -d
echo open http://$(host.ip):$app_port
}
# ---
| 1 | # pango.install: $app_domain $app_port |
| 2 | pango.install(){ |
| 3 | |
| 4 | # Config # |
| 5 | app_name="pango" # App Name |
| 6 | app_repo_url="https://github.com/fosrl/pangolin" # App Codebase |
| 7 | app_version="latest" |
| 8 | |
| 9 | app_domain="${1:-"$app_name.$org_domain"}" # Unique app domain |
| 10 | app_port="${2:-"3030"}" # App Port |
| 11 | api_port="$((app_port + 1))" |
| 12 | api2_port="$((app_port + 2))" |
| 13 | |
| 14 | container_name="$app_name-$app_port" |
| 15 | app_name_domain="$(echo $app_domain | tr "." "-")" |
| 16 | app_path="/data/${app_name_domain}" |
| 17 | app_container_config="$app_path/docker-compose.yml" |
| 18 | |
| 19 | # Setup paths # |
| 20 | mkdir -p "$app_path" |
| 21 | |
| 22 | echo cd "$app_path" |
| 23 | cd "$app_path" |
| 24 | if [ ! $? == "0" ];then |
| 25 | err "Failed to cd \"$app_path\"" |
| 26 | return 1 |
| 27 | fi |
| 28 | |
| 29 | # if file exists |
| 30 | if [[ ! -e "installer" ]];then |
| 31 | # not exists |
| 32 | echo Downloading Installer |
| 33 | curl -fsSL https://static.pangolin.net/get-installer.sh | bash |
| 34 | fi |
| 35 | |
| 36 | if [[ ! -d "config" ]];then |
| 37 | echo Running Installer |
| 38 | ./installer |
| 39 | fi |
| 40 | |
| 41 | # Write docker-compose config |
| 42 | tee "$app_container_config" > /dev/null <<EOF |
| 43 | name: $app_name |
| 44 | services: |
| 45 | $app_name: |
| 46 | container_name: $container_name |
| 47 | image: docker.io/fosrl/pangolin:1.20.0 |
| 48 | restart: always |
| 49 | deploy: |
| 50 | resources: |
| 51 | limits: |
| 52 | memory: 2g |
| 53 | reservations: |
| 54 | memory: 512m |
| 55 | ports: |
| 56 | - $app_port:3002 |
| 57 | - $api_port:3000 |
| 58 | - $api2_port:3001 |
| 59 | volumes: |
| 60 | - ./config:/app/config |
| 61 | healthcheck: |
| 62 | test: ["CMD", "curl", "-f", "http://localhost:3001/api/v1/"] |
| 63 | interval: "10s" |
| 64 | timeout: "10s" |
| 65 | retries: 15 |
| 66 | extra_hosts: |
| 67 | - "host.docker.internal:host-gateway" |
| 68 | |
| 69 | gerbil: |
| 70 | image: docker.io/fosrl/gerbil:1.4.2 |
| 71 | container_name: gerbil |
| 72 | restart: always |
| 73 | depends_on: |
| 74 | $app_name: |
| 75 | condition: service_healthy |
| 76 | command: |
| 77 | - --reachableAt=http://gerbil:3004 |
| 78 | - --generateAndSaveKeyTo=/var/config/key |
| 79 | - --remoteConfig=http://$app_name:3001/api/v1/ |
| 80 | volumes: |
| 81 | - ./config/:/var/config |
| 82 | cap_add: |
| 83 | - NET_ADMIN |
| 84 | - SYS_MODULE |
| 85 | ports: |
| 86 | - 21820:21820/udp |
| 87 | - 51800:51800/udp |
| 88 | #- 443:443 |
| 89 | #- 443:443/udp # For http3 QUIC if desired |
| 90 | #- 80:80 |
| 91 | networks: |
| 92 | default: |
| 93 | driver: bridge |
| 94 | name: pangolin_frontend |
| 95 | EOF |
| 96 | |
| 97 | caddy_domain="domain.com" |
| 98 | caddy_email="your@email.com" |
| 99 | caddy_ip="your_ip" |
| 100 | |
| 101 | cat <<EOF |
| 102 | # Caddy Config: |
| 103 | $caddy_domain { |
| 104 | encode gzip |
| 105 | tls $caddy_email |
| 106 | |
| 107 | # 3030 Web |
| 108 | handle { |
| 109 | reverse_proxy $caddy_ip:3030 |
| 110 | } |
| 111 | |
| 112 | # 3031 API |
| 113 | handle_path /api/* { |
| 114 | rewrite * /api{uri} |
| 115 | reverse_proxy $caddy_ip:3031 |
| 116 | } |
| 117 | |
| 118 | # 3032 API Docs |
| 119 | handle_path /api2/* { |
| 120 | rewrite * /api2{uri} |
| 121 | reverse_proxy $caddy_ip:3032 |
| 122 | } |
| 123 | } |
| 124 | # --- |
| 125 | EOF |
| 126 | |
| 127 | #dasel -i yaml --root 'app.telemetry.anonymous_usage = false' < config.yml > config.yml |
| 128 | #dasel -i yaml --root 'gerbil.start_port = 51800' < config.yml > config.yml |
| 129 | dasel.edit yaml 'app.telemetry.anonymous_usage = false' "$app_path/config/config.yml" |
| 130 | dasel.edit yaml 'gerbil.start_port = 51800' "$app_path/config/config.yml" |
| 131 | dasel.edit yaml '{$root..., "flags": {flags..., "disable_enterprise_features": true}}' "$app_path/config/config.yml" |
| 132 | |
| 133 | # Run App. LIVE! |
| 134 | echo Running $app_name container in the background. |
| 135 | |
| 136 | echo sudo docker-compose pull |
| 137 | sudo docker-compose pull |
| 138 | |
| 139 | echo sudo docker-compose down |
| 140 | sudo docker-compose down |
| 141 | |
| 142 | echo sudo docker-compose up -d |
| 143 | sudo docker-compose up -d |
| 144 | |
| 145 | echo open http://$(host.ip):$app_port |
| 146 | |
| 147 | } |
| 148 | # --- |