oginstaller/non_graf_installer/python-installer/opengnsys_installer-v2.sh

76 lines
1.7 KiB
Bash

#!/bin/bash
# Setup installer environment
BRANCH=${BRANCH:-main}
GIT_SSL_NO_VERIFY=1
GIT_REPO="https://ognproject.evlt.uma.es/gitea/api/v1/repos/opengnsys/oginstaller/archive/$BRANCH.zip"
export GIT_SSL_NO_VERIFY
DEVEL=$1
if [ "$DEVEL" == "devel" ]; then
INSTALL_DEVEL=1
elif [ "$DEVEL" == "nightly" ]; then
INSTALL_NIGHTLY=1
else
INSTALL_STABLE=1
fi
install_packages() {
apt-get update
apt-get install -y curl jq unzip python3 python3-git
}
create_python_venv() {
apt-get install -y python3-venv
python3 -m venv /tmp/oginstall/venv
source /tmp/oginstall/venv/bin/activate
pip install -r /tmp/oginstall/requirements.txt
}
download_installer() {
rm -f /tmp/oginstaller.zip
rm -rf /tmp/oginstaller-$BRANCH
rm -rf /tmp/oginstaller
curl -q -k $GIT_REPO -H 'accept: application/json' -o /tmp/oginstaller.zip
unzip /tmp/oginstaller.zip -d /tmp
mv /tmp/oginstaller /tmp/oginstaller-$BRANCH
}
extract_installer() {
rm -rf /tmp/oginstall
mkdir -p /tmp/oginstall
cp -r /tmp/oginstaller-$BRANCH/non_graf_installer/python-installer/* /tmp/oginstall/
chmod 755 /tmp/oginstall/*.py
}
create_questions() {
echo "Creating questions..."
if [ $INSTALL_DEVEL ] ; then
python3 /tmp/oginstall/oginstaller-v3.py devel
elif [ $INSTALL_NIGHTLY ] ; then
python3 /tmp/oginstall/oginstaller-v3.py nightly
else
python3 /tmp/oginstall/oginstaller-v3.py
fi
deactivate
}
clean_tmp() {
rm -rf /tmp/oginstall
rm -rf /tmp/oginstaller-$BRANCH
rm -f /tmp/oginstaller.zip
}
install_packages
download_installer
extract_installer
create_python_venv
create_questions
clean_tmp