-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' | ||
' |