antos-appimage/mkimg.sh
DanyLE e44afc9cb2
All checks were successful
gitea-sync/antos-appimage/pipeline/head This commit looks good
reactivate runners
2023-01-28 10:57:12 +01:00

94 lines
2.2 KiB
Bash
Executable File

#! /bin/bash
set -e
set -x
# modprobe fuse
arch=$1
[ -z $arch ] && arch=amd64
tag=$2
[ -z $tag ] && tag=latest
# download the appimagetools
echo "Downloading the appimage tools"
archname=x86_64
case $arch in
amd64|x86_64)
archname=x86_64
suffix=x86_64
;;
aarch64|arm64)
archname=aarch64
suffix=aarch64
;;
armv7l|arm)
archname=armhf
suffix=armv7l
;;
*)
echo "Unkown architecture"
exit 1
;;
esac
[ -f appimagetool.AppImage ] || wget --no-check-certificate -O appimagetool.AppImage https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
chmod +x appimagetool.AppImage
wget --no-check-certificate https://github.com/AppImage/AppImageKit/releases/download/continuous/runtime-$archname
W="$WORKSPACE/antos/"
[ -d antos.AppDir ] && rm -rf antos.AppDir
echo "Building app image for $arch"
mkdir antos.AppDir
# copy all neccessary file
cp -rf $W/backend/build/$arch/* antos.AppDir/
cp -rf $W/frontend/$tag/build/* antos.AppDir/
# create binary tar.gz
[ ! -d "build/$tag" ] && mkdir -p build/$tag
cd antos.AppDir
tar cvzf ../build/$tag/AntOS_$suffix.tar.gz .
cd ../
cp antd-config.ini antos.AppDir/opt/www/
cp runner.ini antos.AppDir/opt/www/
# AppRun
cat << "EOF" >> antos.AppDir/AppRun
#!/bin/sh
set -e
echo "Runing AntOS"
W=$(realpath $1)
B=$(dirname $0)
cd $B
[ ! -d "$W" ] && echo "$W is not a directory" && exit 1
# start antd-tunnel service
if [ ! -f "$W/antd-config.ini" ]; then
cp ./opt/www/antd-config.ini $W/antd-config.ini
fi
[ ! -f "$W/runner.ini" ] && cp ./opt/www/runner.ini $W/runner.ini
export LD_LIBRARY_PATH="$B/usr/lib/"
echo "Runing Antd in $B with configuration $W/antd-config.ini"
./usr/bin/antd $W/antd-config.ini >/dev/null 2>&1 | ( sleep 2 && ./opt/www/bin/runner $W/runner.ini >/dev/null 2>&1 &)
EOF
chmod +x antos.AppDir/AppRun
# desktop file
cat << "EOF" >> antos.AppDir/antos.desktop
[Desktop Entry]
Name=AntOS
Exec=antd
Icon=antos
Type=Application
Categories=Utility;
Terminal=true
EOF
cp antos.png antos.AppDir
tree antos.AppDir
./appimagetool.AppImage --runtime-file runtime-$archname antos.AppDir build/$tag/AntOS_$suffix.AppImage