Skip to content

Instantly share code, notes, and snippets.

@imyousuf
Last active November 2, 2020 19:58
Show Gist options
  • Save imyousuf/defec89073a0b0af4557a18225015115 to your computer and use it in GitHub Desktop.
Save imyousuf/defec89073a0b0af4557a18225015115 to your computer and use it in GitHub Desktop.
Add nohup when spawning the process
#!/bin/sh
latest_release=$(curl "https://api.github.com/repos/imyousuf/fs-image-manager/releases/latest" -H "Accept: application/json" -L)
(
mkdir -p dist/
cd dist/
version=$(echo "$latest_release" | grep "tag_name" | cut -d '"' -f 4)
fe="false"
test -f version.txt && fe="true"
test -f fs-image-manager.pid && kill -2 $(cat fs-image-manager.pid) && echo "Existing fs-image-manager shutdown"
download_new="true"
if [ $fe = "true" ]
then
if [ $version = $(cat version.txt) ]
then
download_new="false"
fi
fi
if [ $download_new = "true" ]
then
echo "Downloading new version"
wget $(echo "$latest_release" | grep "browser_download_url" | cut -d '"' -f 4) && echo "$version" > version.txt
fi
) && (
filename=$(echo "$latest_release" | grep "\"name\":.*bz2\"," | cut -d '"' -f 4)
tar xvf "dist/$filename"
nohup ./fs-image-manager > log/image-manager.out 2>&1 &
echo "$!" > dist/fs-image-manager.pid
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment