MIT app inventor offline server [ Centos 8 ]

##==================system==============
$ cat /etc/redhat-release
CentOS Linux release 8.1.1911 (Core)
$ whoami
t1
$ pwd
/home/t1
##===================================

sudo yum -y update
sudo yum -y install wget zip unzip git nano ant glibc.i686 zlib.i686 libstdc++.i686
sudo yum -y install google-cloud-sdk google-cloud-sdk-app-engine-java
sudo gcloud components update
sudo yum makecache && sudo yum update google-cloud-sdk-skaffold kubectl google-cloud-sdk-anthos-auth google-cloud-sdk-minikube google-cloud-sdk google-cloud-sdk-app-engine-grpc google-cloud-sdk-kind google-cloud-sdk-pubsub-emulator google-cloud-sdk-app-engine-go google-cloud-sdk-firestore-emulator google-cloud-sdk-cloud-build-local google-cloud-sdk-datastore-emulator google-cloud-sdk-kpt google-cloud-sdk-app-engine-python google-cloud-sdk-spanner-emulator google-cloud-sdk-cbt google-cloud-sdk-bigtable-emulator google-cloud-sdk-app-engine-python-extras google-cloud-sdk-datalab google-cloud-sdk-app-engine-java
sudo firewall-cmd --permanent --zone=public --add-port=8888/tcp
sudo firewall-cmd --reload

##===================Check==================
$ java -version
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)
$ git --version
git version 2.18.2
$ ant -version
Apache Ant(TM) version 1.10.5 compiled on June 24 2019
##================$pwd /home/t1 ===================

cd ~
git clone GitHub - mit-cml/appinventor-sources: MIT App Inventor Public Open Source
cd appinventor-sources
cp sample-.gitignore .gitignore
git submodule update --init

cd /appinventor
ant clean
ant MakeAuthKey
ant

======$pwd /home/t1/appinventor-sources =======Test=====
/usr/lib64/google-cloud-sdk/bin/java_dev_appserver.sh --port=8888 --address=0.0.0.0 --disable_update_check appengine/build/war/

=======================Ctrl+c==================

cd ..
cd ..
mkdir ai2server
cd ai2server
cp -R /home/t1/appinventor-sources/appinventor/appengine/build/war ./
cp -R /home/t1/appinventor-sources/appinventor/buildserver/build/run/lib ./
mkdir pid

========================/home/t1/ai2server =================

nano runai2.sh

#!/usr/bin/bash

export JAVA_HOME=/etc/alternatives/java_sdk
export JRE_HOME=/etc/alternatives/jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:/usr/lib64/google-cloud-sdk/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib

exec nohup /usr/lib64/google-cloud-sdk/bin/java_dev_appserver.sh --port=8888 --address=0.0.0.0 --disable_update_check /home/t1/ai2server/war/ &> /home/t1/ai2server/pid/ai2d.log &
echo $! > /home/t1/ai2server/pid/ai2d.pid

cd /home/t1/ai2server/lib
exec nohup java -cp "*" -Dfile.encoding=UTF-8 com.google.appinventor.buildserver.BuildServer --dexCacheDir /tmp/ &> /home/t1/ai2server/pid/ai2b.log &
echo $! > /home/t1/ai2server/pid/ai2b.pid

chmod +x runai2.sh
nano stopai2.sh

#!/usr/bin/bash

read PID < /home/ai2/ai2server/pid/ai2d.pid
kill -15 $PID

read PID < /home/ai2/ai2server/pid/ai2b.pid
kill -15 $PID

chmod +x stopai2.sh

cd /usr/lib/systemd/system
sudo nano ai2.service

[Unit]
Description=app inventor 2
After=network.target

[Service]
Type=forking
ExecStart=/usr/bin/bash -c '/home/t1/ai2server/runai2.sh'
ExecStop=/usr/bin/bash -c '/home/t1/ai2server/stopai2.sh'
PrivateTmp=true
User=t1
Group=t1

[Install]
WantedBy=multi-user.target

sudo systemctl enable ai2.service
sudo systemctl start ai2

cd ~
cd appinventor-sources

======$pwd /home/t1/appinventor-sources ======

nano update.sh

#!/usr/bin/bash

git reset --hard
git pull
git submodule update --init

cd appinventor
ant clean
ant
cd ../../ai2server/

./stopai2.sh
sleep 10s

\cp -Rf ./war/WEB-INF/appengine-generated ./
rm -rf war
\cp -Rf /home/t1/appinventor-sources/appinventor/appengine/build/war ./
\cp -Rf ./appengine-generated ./war/WEB-INF/

rm -fr lib
\cp -Rf /home/t1/appinventor-sources/appinventor/buildserver/build/run/lib ./

sleep 10s
./runai2.sh

chmod +x update.sh

1 Like