Merge pull request 'ogrepository_installer' (#1) from ogrepository_installer into add_python_scripts working on ticket #1132
Reviewed-on: #1pull/2/head
commit
f98d290ea3
|
@ -0,0 +1,6 @@
|
||||||
|
Types: deb
|
||||||
|
URIs: http://ftp.de.debian.org/debian
|
||||||
|
Suites: buster
|
||||||
|
Components: main
|
||||||
|
Signed-By: /usr/share/keyrings/debian-archive-buster-stable.gpg
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Gunicorn instance to serve repo_api
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=ogrepository
|
||||||
|
Group=ogrepository
|
||||||
|
WorkingDirectory=/opt/opengnsys/ogrepository/api
|
||||||
|
ExecStart=/usr/bin/gunicorn -w 4 -b 0.0.0.0:8006 repo_api:app
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
|
@ -0,0 +1,8 @@
|
||||||
|
[ogimages]
|
||||||
|
comment = OpenGnsys Repository
|
||||||
|
browseable = no
|
||||||
|
writeable = yes
|
||||||
|
locking = no
|
||||||
|
path = /opt/opengnsys/ogrepository/images
|
||||||
|
guest ok = no
|
||||||
|
valid users = %%OGREPOSITORY_USER%%
|
|
@ -0,0 +1,109 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
GIT_BRANCH=$1
|
||||||
|
GIT_REPO=https://ognproject.evlt.uma.es/gitea/opengnsys/ogrepository.git
|
||||||
|
GIT_SSL_NO_VERIFY=true
|
||||||
|
REPO_IP=${REPO_IP:-"127.0.0.1"}
|
||||||
|
SMBUSER=${SMBUSER:-"ogrepository"}
|
||||||
|
SMBPASS=${SMBPASS:-"ogrepository"}
|
||||||
|
INSTALL_DIR=/opt/opengnsys/ogrepository
|
||||||
|
DOWNLOAD_DIR=/tmp/ogrepository
|
||||||
|
DEBIAN_FRONTEND=noninteractive
|
||||||
|
export DEBIAN_FRONTEND
|
||||||
|
export GIT_SSL_NO_VERIFY
|
||||||
|
|
||||||
|
clone_repository() {
|
||||||
|
local BRANCH=$1
|
||||||
|
rm -rf $DOWNLOAD_DIR
|
||||||
|
git clone -b "$BRANCH" $GIT_REPO $DOWNLOAD_DIR
|
||||||
|
chown -R ogrepository:ogrepository $DOWNLOAD_DIR
|
||||||
|
}
|
||||||
|
|
||||||
|
check_root() {
|
||||||
|
if [ "$(id -u)" != "0" ]; then
|
||||||
|
echo "This script must be run as root" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
install_uftp() {
|
||||||
|
apt install uftp -y
|
||||||
|
}
|
||||||
|
|
||||||
|
install_updcast () {
|
||||||
|
apt install $DOWNLOAD_DIR/packets/udpcast_20230924_amd64.deb
|
||||||
|
}
|
||||||
|
|
||||||
|
add_user_ogrepository() {
|
||||||
|
if ! id "ogrepository" &>/dev/null; then
|
||||||
|
echo "User ogrepository does not exist, creating it"
|
||||||
|
useradd -r -s /bin/bash ogrepository
|
||||||
|
fi
|
||||||
|
if [ ! -f /etc/sudoers.d/ogrepository ]; then
|
||||||
|
echo "User ogrepository does not have sudo permissions, adding it"
|
||||||
|
echo 'ogrepository ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/ogrepository
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
create_directories() {
|
||||||
|
mkdir -p $INSTALL_DIR
|
||||||
|
mkdir -p $INSTALL_DIR/images $INSTALL_DIR/images_trash/ $INSTALL_DIR/bin/ $INSTALL_DIR/etc/ $INSTALL_DIR/log/ $INSTALL_DIR/api/
|
||||||
|
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 $DOWNLOAD_DIR/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 $DOWNLOAD_DIR/installer/files/ogrepo-api.service /etc/systemd/system/ogrepo-api.service
|
||||||
|
systemctl enable --now ogrepo-api
|
||||||
|
}
|
||||||
|
|
||||||
|
install_files() {
|
||||||
|
cp -pr $DOWNLOAD_DIR/bin/* $INSTALL_DIR/bin/
|
||||||
|
cp -pr $DOWNLOAD_DIR/etc/* $INSTALL_DIR/etc/
|
||||||
|
cp -pr $DOWNLOAD_DIR/api/* $INSTALL_DIR/api/
|
||||||
|
chown -R ogrepository:ogrepository $INSTALL_DIR
|
||||||
|
echo IPlocal="$REPO_IP" > $INSTALL_DIR/etc/ogAdmRepo.cfg
|
||||||
|
sudo chown ogrepository:ogrepository $INSTALL_DIR/etc/ogAdmRepo.cfg
|
||||||
|
}
|
||||||
|
|
||||||
|
configure_samba() {
|
||||||
|
echo "include = /etc/samba/smb.conf.ogrepository" >> /etc/samba/smb.conf
|
||||||
|
cp $DOWNLOAD_DIR/installer/files/ogrepo-smb.conf /etc/samba/smb.conf.ogrepository
|
||||||
|
sed -i "s/%%OGREPOSITORY_USER%%/$SMBUSER/g" /etc/samba/smb.conf.ogrepository
|
||||||
|
systemctl restart smbd
|
||||||
|
# Create default user ogrepository
|
||||||
|
(echo $SMBPASS; echo $SMBPASS) | smbpasswd -s -a $SMBUSER
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
## Main program
|
||||||
|
check_root
|
||||||
|
install_dependencies
|
||||||
|
add_user_ogrepository
|
||||||
|
clone_repository "$GIT_BRANCH"
|
||||||
|
install_ext_repo
|
||||||
|
install_external_packages
|
||||||
|
install_uftp
|
||||||
|
install_updcast
|
||||||
|
create_directories
|
||||||
|
install_files
|
||||||
|
install_ogrepo-api_service
|
||||||
|
configure_samba
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue