Skip to content

Commit

Permalink
Restart casaos-gateway.service to support v0.4.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Cp0204 committed Sep 2, 2024
1 parent 2b12e6a commit 9f484cd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,22 @@ www_dir="/var/lib/casaos/www"
index_html="${www_dir}/index.html"
index_html_bak="${index_html}.bak"

casaos_framework="gin"

host_exec() {
nsenter -m -u -i -n -p -t 1 sh -c "$1"
}

start() {
echo "Starting..."

# v0.4.10+ migrate gin to echo
casaos_ver=$(host_exec "casaos -v | tr -d 'v'")
if [[ $(printf "%s\n" "$casaos_ver" "0.4.9" | sort -V | tail -n1) == "$casaos_ver" ]]; then
casaos_framework="echo"
echo "CasaOS v$casaos_ver"
fi

# Copy mod_store
if [[ ! -d "$mod_store_dir" ]]; then
echo "Creating directory ${mod_store_dir}"
Expand Down Expand Up @@ -88,6 +101,12 @@ start() {
sed -i "s|<\/body>|${js_tags}<\/body>|" "$index_html"
echo "Modified index.html"

# Restart gateway
if [[ $casaos_framework == "echo" ]]; then
host_exec "systemctl restart casaos-gateway.service"
echo "Restarted casaos-gateway.service"
fi

echo "Keep Running..."
while true; do
sleep 1
Expand All @@ -100,6 +119,10 @@ stop() {
cp "$index_html_bak" "$index_html"
rm "$index_html_bak"
echo "Restored index.html"
if [[ $casaos_framework == "echo" ]]; then
host_exec "systemctl restart casaos-gateway.service"
echo "Restarted casaos-gateway.service"
fi
else
echo "Backup file not found, cannot restore index.html"
fi
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ services:
volumes:
- /DATA/AppData/casamod:/DATA/AppData/casamod
- /var/lib/casaos/www:/var/lib/casaos/www
pid: host
privileged: true
network_mode: bridge
restart: unless-stopped
deploy:
Expand Down

0 comments on commit 9f484cd

Please sign in to comment.