fix_installer #3

Merged
narenas merged 4 commits from fix_installer into main 2024-11-13 14:52:58 +01:00
2 changed files with 19 additions and 16 deletions

View File

@ -3,8 +3,8 @@ Description=Gunicorn instance to serve repo_api
After=network.target After=network.target
[Service] [Service]
User=ogrepository User=%%OGREPOSITORY_USER%%
Group=ogrepository Group=%%OGREPOSITORY_USER%%
WorkingDirectory=/opt/opengnsys/ogrepository/api WorkingDirectory=/opt/opengnsys/ogrepository/api
ExecStart=/usr/bin/gunicorn -w 4 -b 0.0.0.0:8006 repo_api:app ExecStart=/usr/bin/gunicorn -w 4 -b 0.0.0.0:8006 repo_api:app

View File

@ -6,8 +6,8 @@ GIT_BRANCH=$1
GIT_REPO=https://ognproject.evlt.uma.es/gitea/opengnsys/ogrepository.git GIT_REPO=https://ognproject.evlt.uma.es/gitea/opengnsys/ogrepository.git
GIT_SSL_NO_VERIFY=true GIT_SSL_NO_VERIFY=true
REPO_IP=${REPO_IP:-"127.0.0.1"} REPO_IP=${REPO_IP:-"127.0.0.1"}
SMBUSER=${SMBUSER:-"ogrepository"} OGUSER=${OGUSER:-"opengnsys"}
SMBPASS=${SMBPASS:-"ogrepository"} OGPASS=${OGPASS:-"og"}
INSTALL_DIR=/opt/opengnsys/ogrepository INSTALL_DIR=/opt/opengnsys/ogrepository
DOWNLOAD_DIR=/tmp/ogrepository DOWNLOAD_DIR=/tmp/ogrepository
DEBIAN_FRONTEND=noninteractive DEBIAN_FRONTEND=noninteractive
@ -18,7 +18,7 @@ clone_repository() {
local BRANCH=$1 local BRANCH=$1
rm -rf $DOWNLOAD_DIR rm -rf $DOWNLOAD_DIR
git clone -b "$BRANCH" $GIT_REPO $DOWNLOAD_DIR git clone -b "$BRANCH" $GIT_REPO $DOWNLOAD_DIR
chown -R ogrepository:ogrepository $DOWNLOAD_DIR chown -R $OGUSER:$OGUSER $DOWNLOAD_DIR
} }
check_root() { check_root() {
@ -30,6 +30,8 @@ check_root() {
install_uftp() { install_uftp() {
apt install uftp -y apt install uftp -y
systemctl stop uftp
systemctl disable uftp
} }
install_updcast () { install_updcast () {
@ -37,13 +39,13 @@ install_updcast () {
} }
add_user_ogrepository() { add_user_ogrepository() {
if ! id "ogrepository" &>/dev/null; then if ! id "$OGUSER" &>/dev/null; then
echo "User ogrepository does not exist, creating it" echo "User ogrepository does not exist, creating it"
useradd -r -s /bin/bash ogrepository useradd -r -s /bin/bash $OGUSER
fi fi
if [ ! -f /etc/sudoers.d/ogrepository ]; then if [ ! -f /etc/sudoers.d/$OGUSER ]; then
echo "User ogrepository does not have sudo permissions, adding it" echo "User $OGUSER does not have sudo permissions, adding it"
echo 'ogrepository ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/ogrepository echo "$OGUSER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/"$OGUSER"
fi fi
} }
@ -51,12 +53,12 @@ add_user_ogrepository() {
create_directories() { create_directories() {
mkdir -p $INSTALL_DIR 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/ 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 chown -R $OGUSER:$OGUSER $INSTALL_DIR
} }
install_dependencies() { install_dependencies() {
apt update -y apt update -y
apt install -y git python3 python3-pip python3-flask python3-paramiko python3-psutil python3-flasgger debian-archive-keyring samba gunicorn apt install -y git python3 python3-pip python3-flask python3-paramiko python3-psutil python3-flasgger debian-archive-keyring samba gunicorn wakeonlan
} }
install_ext_repo() { install_ext_repo() {
@ -70,6 +72,7 @@ install_external_packages() {
install_ogrepo-api_service() { install_ogrepo-api_service() {
cp -r $DOWNLOAD_DIR/installer/files/ogrepo-api.service /etc/systemd/system/ogrepo-api.service cp -r $DOWNLOAD_DIR/installer/files/ogrepo-api.service /etc/systemd/system/ogrepo-api.service
sed -i "s/%%OGREPOSITORY_USER%%/$OGUSER/g" /etc/systemd/system/ogrepo-api.service
systemctl enable --now ogrepo-api systemctl enable --now ogrepo-api
} }
@ -77,18 +80,18 @@ install_files() {
cp -pr $DOWNLOAD_DIR/bin/* $INSTALL_DIR/bin/ cp -pr $DOWNLOAD_DIR/bin/* $INSTALL_DIR/bin/
cp -pr $DOWNLOAD_DIR/etc/* $INSTALL_DIR/etc/ cp -pr $DOWNLOAD_DIR/etc/* $INSTALL_DIR/etc/
cp -pr $DOWNLOAD_DIR/api/* $INSTALL_DIR/api/ cp -pr $DOWNLOAD_DIR/api/* $INSTALL_DIR/api/
chown -R ogrepository:ogrepository $INSTALL_DIR chown -R $OGUSER:$OGUSER $INSTALL_DIR
echo IPlocal="$REPO_IP" > $INSTALL_DIR/etc/ogAdmRepo.cfg echo IPlocal="$REPO_IP" > $INSTALL_DIR/etc/ogAdmRepo.cfg
sudo chown ogrepository:ogrepository $INSTALL_DIR/etc/ogAdmRepo.cfg sudo chown $OGUSER:$OGUSER $INSTALL_DIR/etc/ogAdmRepo.cfg
} }
configure_samba() { configure_samba() {
echo "include = /etc/samba/smb.conf.ogrepository" >> /etc/samba/smb.conf echo "include = /etc/samba/smb.conf.ogrepository" >> /etc/samba/smb.conf
cp $DOWNLOAD_DIR/installer/files/ogrepo-smb.conf /etc/samba/smb.conf.ogrepository 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 sed -i "s/%%OGREPOSITORY_USER%%/$OGUSER/g" /etc/samba/smb.conf.ogrepository
systemctl restart smbd systemctl restart smbd
# Create default user ogrepository # Create default user ogrepository
(echo $SMBPASS; echo $SMBPASS) | smbpasswd -s -a $SMBUSER (echo $OGPASS; echo $OGPASS) | smbpasswd -s -a $OGUSER
} }