diff --git a/biscd/config_example.yaml b/biscd/config_example.yaml deleted file mode 100644 index 081a894..0000000 --- a/biscd/config_example.yaml +++ /dev/null @@ -1,12 +0,0 @@ -flask_development_server: - # Options: production, development - flask_env: production - # Options: 127.0.0.1 , 0.0.0.0 - server_host: 127.0.0.1 - port: 5000 - -logging: - log_to_sdout: true - logfile: info.log - -message: Hoi \ No newline at end of file diff --git a/biscd/projects_example.yaml b/biscd/projects_example.yaml deleted file mode 100644 index 065e1ad..0000000 --- a/biscd/projects_example.yaml +++ /dev/null @@ -1,16 +0,0 @@ -projects: - - The Hunt: - url: thehunt - git_repo: https://git.sciuro.org/Burathar/The-Hunt - branch: master - secret: thisissecret - requirements-file: requirements.txt - tests: tests.py - - - Foo: - url: bar - git_repo: https://git.sciuro.org/Burathar/The-Hunt - branch: master - secret: thisissecret - requirements-file: requirements.txt - tests: tests.py \ No newline at end of file diff --git a/biscd/requirements.txt b/biscd/requirements.txt index 253bad7..4c93020 100644 --- a/biscd/requirements.txt +++ b/biscd/requirements.txt @@ -1,15 +1,20 @@ -aniso8601==8.1.0 -certifi==2020.12.5 -chardet==4.0.0 +astroid==2.5 click==7.1.2 +confuse==1.4.0 +dominate==2.6.0 Flask==1.1.2 -Flask-RESTful==0.3.8 -idna==2.10 +Flask-Bootstrap==3.3.7.1 +isort==5.7.0 itsdangerous==1.1.0 -Jinja2==2.11.2 +Jinja2==2.11.3 +lazy-object-proxy==1.5.2 MarkupSafe==1.1.1 -pytz==2020.5 -requests==2.25.1 -six==1.15.0 -urllib3==1.26.3 +mccabe==0.6.1 +pkg-resources==0.0.0 +pylint==2.7.1 +PyYAML==5.4.1 +toml==0.10.2 +typed-ast==1.4.2 +visitor==0.1.3 Werkzeug==1.0.1 +wrapt==1.12.1 diff --git a/install.sh b/install.sh index dd77ad2..3d69de4 100755 --- a/install.sh +++ b/install.sh @@ -4,6 +4,7 @@ script_dir="$(dirname $(readlink -f $0))" install_dir_parent="/opt" default_app_name='biscd' +flask_module_name='biscd' start_script='run.sh' # exit when any command fails @@ -110,24 +111,26 @@ fi echo_header "Copy over application files" mkdir -vp "$install_dir" cp -rv "$script_dir/$default_app_name/." "$install_dir" -sed -i "s+^app_name=.*+app_name='${flask_app_name}'+g" "$install_dir/run.sh" +sed -i "s+^app_name=.*+app_name='${flask_module_name}'+g" "$install_dir/run.sh" +sed -i "s+confuse.Configuration(*, __name__)+confuse.Configuration('$app_name', __name__)'+g" "$install_dir/{$flask_module_name}/__init__.py" -cp -v "$script_dir/$default_app_name/config_example.yml" "$install_dir/config.yml" -sed -i "s/^port =.*/port = $internal_port/g" "$install_dir/config.yml" -sed -i "s+^logfile :.*+logfile : $logging_dir/reports.log+g" "$install_dir/config.yml" -sed -i "s+^errorfile :.*+errorfile : $logging_dir/error.log+g" "$install_dir/config.yml" - -cp -v "$script_dir/bin/uninstall.sh" "$install_dir" +cp -v "$script_dir/installation-files/uninstall.sh" "$install_dir" sed -i "s+^app_name=.*+app_name='${app_name}'+g" "$install_dir/uninstall.sh" sed -i "s+^install_dir=.*+install_dir='${install_dir}'+g" "$install_dir/uninstall.sh" cp -v "$script_dir/version" "$install_dir" cp -v "$script_dir/README.md" "$install_dir" +mkdir -vp "/etc/$app_name" +cp -v "$script_dir/$default_app_name/config_example.yaml" "/etc/$app_name/config.yaml" +sed -i "s/^port =.*/port = $internal_port/g" "$install_dir/config.yaml" +sed -i "s+^logfile :.*+logfile : $logging_dir/reports.log+g" "$install_dir/config.yaml" +sed -i "s+^errorfile :.*+errorfile : $logging_dir/error.log+g" "$install_dir/config.yaml" + echo_header "Copy over and enable apache vhost" if [ "$use_wsgi" = 'true' ]; then - cp -v "$script_dir/bin/$default_app_name-wsgi.conf" "/etc/apache2/sites-available/$app_name.conf" + cp -v "$script_dir/installation-files/$default_app_name-wsgi.conf" "/etc/apache2/sites-available/$app_name.conf" sed -i "s/APPNAME/$app_name/g" "/etc/apache2/sites-available/$app_name.conf" sed -i "s/USER/$app_name/g" "/etc/apache2/sites-available/$app_name.conf" sed -i "s/GROUP/$app_name/g" "/etc/apache2/sites-available/$app_name.conf" @@ -136,11 +139,11 @@ if [ "$use_wsgi" = 'true' ]; then echo_header "Installing wsgi-script" mkdir -vp "/var/www/wsgi-scripts" - cp -v "$script_dir/bin/$default_app_name.wsgi" "/var/www/wsgi-scripts/app_name.wsgi" + cp -v "$script_dir/installation-files/$default_app_name.wsgi" "/var/www/wsgi-scripts/app_name.wsgi" sed -i "s+INSTALLDIR+$install_dir+g" "/var/www/wsgi-scripts/$app_name.wsgi" - sed -i "s/APPNAME/$flask_app_name/g" "/var/www/wsgi-scripts/$app_name.wsgi" + sed -i "s/APPNAME/$flask_module_name/g" "/var/www/wsgi-scripts/$app_name.wsgi" else - cp -v "$script_dir/bin/$default_app_name-proxy.conf" "/etc/apache2/sites-available/$app_name.conf" + cp -v "$script_dir/installation-files/$default_app_name-proxy.conf" "/etc/apache2/sites-available/$app_name.conf" sed -i "s/PORT/$internal_port/g" "/etc/apache2/sites-available/$app_name.conf" ln -sfv "/etc/apache2/sites-available/$app_name.conf" "/etc/apache2/sites-enabled/$app_name.conf" @@ -160,11 +163,6 @@ touch "$logging_dir/reports.log" chown -v --from=root:root "$app_name":"$app_name" "$logging_dir/reports.log" -echo_header "Install Logrotate config" -cp -v "$script_dir/bin/logrotate-conf" "/etc/logrotate.d/$app_name" -sed -i "s/log-dir/$logging_dir/g" "/etc/logrotate.d/$app_name" - - echo_header "Make sure python3 and virtualenv are installed" python3 --version || apt-get install -y python3 @@ -179,7 +177,7 @@ pip install setuptools wheel pip install -r "$script_dir/$default_app_name/requirements.txt" python_version=`ls "$install_dir/venv/lib" | grep python3 | head -1` -echo "$install_dir/" > "$install_dir/venv/lib/$python_version/site-packages/$flask_app_name.pth" +echo "$install_dir/" > "$install_dir/venv/lib/$python_version/site-packages/$flask_module_name.pth" [ "$use_wsgi" = 'true' ] && sed -i "s/PYTHON_VERSION/$python_version/g" "/var/www/wsgi-scripts/$default_app_name.wsgi" @@ -189,12 +187,11 @@ chown -v root:"$app_name" "$install_dir" chmod -v 775 "$install_dir" chmod -v 754 "$install_dir/run.sh" "$install_dir/runserver.py" chmod -v 744 "$install_dir/uninstall.sh" -#chmod -v 660 "$install_dir/config.yml" if [ "$use_wsgi" != 'true' ] && [ "$use_systemd" = 'true' ]; then echo_header "Enable as systemd service" - cp "$script_dir/bin/$default_app_name.service" "/etc/systemd/system/$app_name.service" + cp "$script_dir/installation-files/$default_app_name.service" "/etc/systemd/system/$app_name.service" sed -i "s+^ExecStart=.*+ExecStart=${install_dir}/${start_script}+g" "/etc/systemd/system/$app_name.service" sed -i "s+^User=.*+User=${app_name}+g" "/etc/systemd/system/$app_name.service" systemctl daemon-reload diff --git a/installation-files/logrotate-conf b/installation-files/logrotate-conf deleted file mode 100644 index 8cb7caa..0000000 --- a/installation-files/logrotate-conf +++ /dev/null @@ -1,13 +0,0 @@ -log-dir/info.log { - size 100k - rotate 2 - compress - missingok -} - -log-dir/error.log { - size 100k - rotate 2 - compress - missingok -} \ No newline at end of file diff --git a/installation-files/uninstall.sh b/installation-files/uninstall.sh index 086d740..009a7bb 100755 --- a/installation-files/uninstall.sh +++ b/installation-files/uninstall.sh @@ -83,10 +83,10 @@ deluser -q "$app_name" delgroup -q "$app_name" && echo "group $app_name is removed, ignore previous warning" || true echo_header "Removing application files" -rm -v "/etc/logrotate.d/$app_name" rm -v "/etc/apache2/sites-available/$app_name.conf" rm -v "/var/www/wsgi-scripts/$app_name.wsgi" || true rm -vd "/var/www/wsgi-scripts/" || true +rm -vrf "/etc/$app_name" rm -rf "$install_dir" && echo "removed '$install_dir'" if [ "$delete_logs" = 'true' ]; then