antos-appimage/mkimg.sh
Dany LE 1259e37c7c
All checks were successful
gitea-sync/antos-appimage/pipeline/head This commit looks good
create tmp path for db
2022-10-03 16:35:51 +02:00

93 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
;;
aarch64|arm64)
archname=aarch64
;;
armv7l|arm)
archname=armhf
;;
*)
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
# 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
mkdir -p $W/db
chmod 700 $W/db
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"
# TODO this is not good
touch /tmp/.antos_pkgcache
ln -sf $W/db /tmp/antos-db
./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
# copy all neccessary file
cp antos.png antos.AppDir
cp -rf $W/backend/build/$arch/* antos.AppDir/
cp -rf $W/frontend/$tag/build/* antos.AppDir/
cp antd-config.ini antos.AppDir/opt/www/
cp runner.ini antos.AppDir/opt/www/
ln -sf /tmp/.antos_pkgcache antos.AppDir/opt/www/htdocs/os/packages/packages.json
tree antos.AppDir
./appimagetool.AppImage --runtime-file runtime-$archname antos.AppDir build/AntOS_$archname-$tag.AppImage