From 8627892bdb1ab7d7e5ee7c018cafe644c39ed4af Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Mon, 11 Apr 2022 16:03:00 +0200 Subject: [PATCH] Add files via upload --- templates/AM-SAMPLE-GitHub-generic | 97 ++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 templates/AM-SAMPLE-GitHub-generic diff --git a/templates/AM-SAMPLE-GitHub-generic b/templates/AM-SAMPLE-GitHub-generic new file mode 100644 index 000000000..1d0d813f2 --- /dev/null +++ b/templates/AM-SAMPLE-GitHub-generic @@ -0,0 +1,97 @@ +#!/bin/sh + +APP=SAMPLE +USER= +REPO= +COMMENT=$(curl https://api.github.com/repos/$USER/$REPO 2>/dev/null | grep description) +FILENAMEBEGIN= +FILENAMEEXTENTION=".AppImage" +URL=https://github.com/$USER/$REPO/releases/latest +APPNAME= +CATEGORIES= +ICONURL= +ICONFILE= +COMMENT=$(curl https://api.github.com/repos/$USER/$REPO 2>/dev/null | grep description | sed 's/"description": "//' | sed 's/",//') + +# CREATE THE FOLDER +mkdir /opt/$APP +cd /opt/$APP + +# ADD THE REMOVER +echo '#!/bin/sh' >> /opt/$APP/remove +echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove +chmod a+x /opt/$APP/remove + +# DOWNLOAD THE APPIMAGE +mkdir tmp +cd ./tmp + +release=$(curl -L -s https://github.com/$USER/$REPO/releases | grep -E AppImage | head -1 | sed 's/^.*'$FILENAMEBEGIN'/'$FILENAMEBEGIN'/' | sed 's/\'$FILENAMEEXTENTION'.*/'$FILENAMEEXTENTION'/') +wget https://github.com/$(wget $URL -O - | egrep '/.*/.*/'$release'' -o) + +version=$(ls /opt/$APP/tmp) +echo "$version" >> /opt/$APP/version + +cd .. +mv ./tmp/*mage ./$APP +chmod a+x /opt/$APP/$APP +rmdir ./tmp + +# LINK +ln -s /opt/$APP/$APP /usr/local/bin/$APP + +# SCRIPT TO UPDATE THE PROGRAM +cat >> /opt/$APP/AM-updater << 'EOF' +#!/usr/bin/env bash +APP=SAMPLE +version0=$(cat /opt/$APP/version) +url=https://github.com/FUNCTION1/FUNCTION2/releases/latest +if curl -L -s $url | grep -ioF "$version0"; then + echo "Update not needed!" +else + notify-send "A new version of $APP is available, please wait" + mkdir /opt/$APP/tmp + cd /opt/$APP/tmp + URL=https://github.com/86Box/86Box/releases/latest + release=$(curl -L -s https://github.com/FUNCTION1/FUNCTION2/releases | grep -E AppImage | head -1 | sed 's/^.*FUNCTION3/FUNCTION3/' | sed 's/\FUNCTION4.*/FUNCTION4/') + wget https://github.com/$(wget $URL -O - | egrep '/.*/.*/'$release'' -o) + version=$(ls /opt/$APP/tmp) + cd .. + if test -f ./tmp/*mage; then rm ./version + fi + echo $version >> ./version + mv --backup=t ./tmp/*mage ./$APP + chmod a+x /opt/$APP/$APP + rm -R -f ./tmp ./*~ +fi +EOF +sed -i s/FUNCTION1/$USER/g /opt/$APP/AM-updater +sed -i s/FUNCTION2/$REPO/g /opt/$APP/AM-updater +sed -i s/FUNCTION3/$FILENAMEBEGIN/g /opt/$APP/AM-updater +sed -i s/FUNCTION4/$FILENAMEEXTENTION/g /opt/$APP/AM-updater +chmod a+x /opt/$APP/AM-updater + +# LAUNCHER +rm /usr/share/applications/AM-$APP.desktop +echo "[Desktop Entry] +Name=$APPNAME +Exec=$APP +Icon=/opt/$APP/$ICONFILE +Type=Application +Terminal=false +Categories=$CATEGORIES; +Comment=$COMMENT" >> /usr/share/applications/AM-$APP.desktop + +# ICON +wget $ICONURL + +# CHANGE THE PERMISSIONS +currentuser=$(who | awk '{print $1}') +chown -R $currentuser /opt/$APP + +# MESSAGE +echo ' + + '$APPNAME' is provided by https://github.com/'$USER'/'$REPO' + +'