antos-appimage/mkimg.sh

94 lines
2.2 KiB
Bash
Raw Permalink Normal View History

2022-09-20 11:41:59 +02:00
#! /bin/bash
set -e
set -x
2022-09-20 12:13:53 +02:00
# modprobe fuse
2022-09-20 11:41:59 +02:00
arch=$1
2022-09-20 14:11:17 +02:00
[ -z $arch ] && arch=amd64
tag=$2
[ -z $tag ] && tag=latest
2022-09-20 11:41:59 +02:00
# download the appimagetools
echo "Downloading the appimage tools"
archname=x86_64
case $arch in
amd64|x86_64)
archname=x86_64
suffix=x86_64
2022-09-20 11:41:59 +02:00
;;
aarch64|arm64)
archname=aarch64
suffix=aarch64
2022-09-20 11:41:59 +02:00
;;
armv7l|arm)
archname=armhf
suffix=armv7l
2022-09-20 11:41:59 +02:00
;;
*)
echo "Unkown architecture"
exit 1
;;
esac
2022-09-20 14:11:17 +02:00
[ -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
2022-09-20 11:41:59 +02:00
2022-09-20 14:11:17 +02:00
wget --no-check-certificate https://github.com/AppImage/AppImageKit/releases/download/continuous/runtime-$archname
2022-09-20 12:35:11 +02:00
2022-09-29 23:46:16 +02:00
W="$WORKSPACE/antos/"
2022-09-20 11:41:59 +02:00
[ -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
2022-10-05 20:14:34 +02:00
tar cvzf ../build/$tag/AntOS_$suffix.tar.gz .
cd ../
2022-10-05 20:18:03 +02:00
cp antd-config.ini antos.AppDir/opt/www/
cp runner.ini antos.AppDir/opt/www/
2022-09-20 11:41:59 +02:00
# 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
2022-10-03 16:35:51 +02:00
if [ ! -f "$W/antd-config.ini" ]; then
2022-10-03 16:33:31 +02:00
cp ./opt/www/antd-config.ini $W/antd-config.ini
fi
2022-09-20 11:41:59 +02:00
[ ! -f "$W/runner.ini" ] && cp ./opt/www/runner.ini $W/runner.ini
export LD_LIBRARY_PATH="$B/usr/lib/"
2022-10-03 16:23:24 +02:00
echo "Runing Antd in $B with configuration $W/antd-config.ini"
2023-01-28 10:57:12 +01:00
./usr/bin/antd $W/antd-config.ini >/dev/null 2>&1 | ( sleep 2 && ./opt/www/bin/runner $W/runner.ini >/dev/null 2>&1 &)
2022-09-20 11:41:59 +02:00
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