73 lines
1.7 KiB
Bash
73 lines
1.7 KiB
Bash
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
GIT_BRANCH=$1
|
|
GIT_REPO=https://ognproject.evlt.uma.es/gitea/opengnsys/ogrepository.git
|
|
GIT_SSL_NO_VERIFY=true
|
|
INSTALL_DIR=/opt/opengnsys/ogrepository
|
|
DEBIAN_FRONTEND=noninteractive
|
|
export DEBIAN_FRONTEND
|
|
export GIT_SSL_NO_VERIFY
|
|
|
|
clone_repository() {
|
|
local BRANCH=$1
|
|
git clone -b "$BRANCH" $GIT_REPO /tmp/ogrepository
|
|
chown -R ogrepository:ogrepository /tmp/ogrepository
|
|
}
|
|
|
|
check_root() {
|
|
if [ "$(id -u)" != "0" ]; then
|
|
echo "This script must be run as root" 1>&2
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
add_user_ogrepository() {
|
|
useradd -r -s /bin/bash ogrepository
|
|
}
|
|
|
|
create_directories() {
|
|
mkdir -p $INSTALL_DIR
|
|
mkdir -p $INSTALL_DIR/images $INSTALL_DIR/images_trash/ $INSTALL_DIR/bin/ $INSTALL_DIR/etc/ $INSTALL_DIR/log/
|
|
chown -R ogrepository:ogrepository $INSTALL_DIR
|
|
}
|
|
|
|
install_dependencies() {
|
|
apt update -y
|
|
apt install -y git python3 python3-pip python3-flask python3-paramiko python3-psutil python3-flasgger debian-archive-keyring samba gunicorn
|
|
}
|
|
|
|
install_ext_repo() {
|
|
cp installer/files/ctorrent.sources /etc/apt/sources.list.d/ctorrent.sources
|
|
apt update -y
|
|
}
|
|
|
|
install_external_packages() {
|
|
apt install -y bittorrent bittornado ctorrent
|
|
}
|
|
|
|
install_ogrepo-api_service() {
|
|
cp -r installer/files/ogrepo-api.service /etc/systemd/system/ogrepo-api.service
|
|
systemctl enable --now ogrepo-api
|
|
systemctl start ogrepository
|
|
}
|
|
|
|
install_files() {
|
|
install bin/* /opt/opengnsys/bin/
|
|
install bin/clients/* /opt/opengnsys/bin/clients
|
|
install etc/* /opt/opengnsys/etc/
|
|
install api/* /opt/opengnsys/api
|
|
}
|
|
|
|
## Main program
|
|
check_root
|
|
install_dependencies
|
|
add_user_ogrepository
|
|
clone_repository "$GIT_BRANCH"
|
|
create_directories
|
|
install_ogrepo-api_service
|
|
|
|
|
|
|