Closed GeoBoi254 closed 2 months ago
Alright is ready.
@GeoBoi254 I'm testing an universal template that hopefully will make this easier, however here the success rate was 50%:
#!/bin/sh
# AM INSTALL SCRIPT VERSION 3.
set -u
APP=REPLACETHIS
SITE="REPO/APP"
# CREATE DIRECTORIES AND ADD REMOVER
[ -n "$APP" ] && mkdir -p "/opt/$APP/tmp" "/opt/$APP/icons" && cd "/opt/$APP/tmp" || exit 1
printf "#!/bin/sh\nset -e\nrm -f /usr/local/bin/$APP\nrm -R -f /opt/$APP" > "/opt/$APP/remove"
#printf '\n%s' "rm -f /usr/share/applications/AM-$APP.desktop" >> "/opt/$APP/remove"
chmod a+x "/opt/$APP/remove"
# DOWNLOAD AND PREPARE THE APP, $version is also used for updates
version=$(curl -Ls https://api.github.com/repos/"$SITE"/releases | sed 's/[()",{} ]/\n/g' | grep -oiE "https.*$APP.*(x|d|86_)64.*(z$|ip$|$APP$)" | grep -vi "apple\|windows\|darwin" | head -1)
wget "$version" || exit 1
[ -e ./*7z ] && 7z x ./*7z && rm -f ./*7z
[ -e ./*tar.* ] && tar fx ./*tar.* && rm -f ./*tar.*
[ -e ./*zip ] && unzip -qq ./*zip 1>/dev/null && rm -f ./*zip
cd ..
if [ -d ./tmp/* 2>/dev/null ]; then mv ./tmp/*/* ./; else mv ./tmp/* ./"$APP" 2>/dev/null || mv ./tmp/* ./; fi
rm -R -f ./tmp || exit 1
echo "$version" > ./version
chmod a+x "/opt/$APP/$APP" || exit 1
# LINK TO PATH
ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP"
# SCRIPT TO UPDATE THE PROGRAM
cat >> "/opt/$APP/AM-updater" << 'EOF'
#!/bin/sh
set -u
APP=REPLACETHIS
SITE="REPO/APP"
version0=$(cat "/opt/$APP/version")
version=$(curl -Ls https://api.github.com/repos/"$SITE"/releases | sed 's/[()",{} ]/\n/g' | grep -oiE "https.*$APP.*(x|d|86_)64.*(z$|ip$|$APP$)" | grep -vi "apple\|windows\|darwin" | head -1)
[ -n "$version" ] || { echo "Error getting link"; exit 1; }
if [ "$version" != "$version0" ]; then
mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1
notify-send "A new version of $APP is available, please wait"
wget "$version" || exit 1
[ -e ./*7z ] && 7z x ./*7z && rm -f ./*7z
[ -e ./*tar.* ] && tar fx ./*tar.* && rm -f ./*tar.*
[ -e ./*zip ] && unzip -qq ./*zip 1>/dev/null && rm -f ./*zip
cd ..
if [ -d ./tmp/* 2>/dev/null ]; then mv --backup=t ./tmp/*/* ./; else mv --backup=t ./tmp/* ./"$APP" 2>/dev/null || mv --backup=t ./tmp/* ./; fi
chmod a+x "/opt/$APP/$APP" || exit 1
echo "$version" > ./version
rm -R -f ./tmp ./*~
notify-send "$APP is updated!"
exit 0
fi
echo "Update not needed!"
EOF
chmod a+x "/opt/$APP/AM-updater"
Example for fixit
you only have to replace APP
and SITE
for this:
APP=fixit
SITE="eugene-babichenko/fixit"
And same thing in the updater part:
APP=fixit
SITE="eugene-babichenko/fixit"
You can test this by copying the script to $HOME, and then simply run appman -i ./script
and hopefully it will install, if it does you can PR the script or open an issue with it so that it can be added.
The apps in red were the ones where the script needed extra changes, all those cases was with how the url is gotten, nothing else in the script needed to be changed.
fixit https://github.com/eugene-babichenko/fixit/releases
mdx https://github.com/arimatakao/mdx/releases
spotify-tui https://github.com/Rigellute/spotify-tui/releases
nap https://github.com/maaslalani/nap/releases
mangal https://github.com/metafates/mangal/releases
ollama https://github.com/ollama/ollama/releases
zellij https://github.com/zellij-org/zellij/releases
goto https://github.com/grafviktor/goto/releases
toru https://github.com/sweetbbak/toru/releases
nyaa https://github.com/Beastwick18/nyaa/releases
toipe https://github.com/Samyak2/toipe/releases
gh-eco https://github.com/jrnxf/gh-eco/releases
koboldcpp https://github.com/LostRuins/koboldcpp/releases
genact https://github.com/svenstaro/genact/releases