|
|
@@ -1,32 +1,61 @@
|
|
|
-#!/bin/env sh
|
|
|
+#!/bin/env bash
|
|
|
|
|
|
dyfi_dir=$(dirname "$(realpath "$0")")
|
|
|
install_dir='/opt/dyfi/'
|
|
|
|
|
|
-
|
|
|
-sudo -- sh -c "\
|
|
|
- alias 'cp'='cp --verbose'; \
|
|
|
- alias 'mkdir'='mkdir --verbose'; \
|
|
|
-
|
|
|
- cd "$dyfi_dir"; \
|
|
|
-
|
|
|
- mkdir -p /opt/dyfi; \
|
|
|
- cp ./auth "$install_dir"; \
|
|
|
- cp ./dyfi.py "$install_dir"; \
|
|
|
- cp ./run.sh "$install_dir"; \
|
|
|
- cp ./requirements.txt "$install_dir"; \
|
|
|
- cp ./dyfi-openrc.sh /etc/init.d/dyfi; \
|
|
|
-
|
|
|
- cd "$install_dir"; \
|
|
|
-
|
|
|
- python -m venv ./venv; \
|
|
|
- source ./venv/bin/activate; \
|
|
|
- python -m ensurepip; \
|
|
|
- pip install --upgrade pip; \
|
|
|
- pip install -r ./requirements.txt; \
|
|
|
-"
|
|
|
-
|
|
|
-
|
|
|
-if [ $? != 0 ]; then
|
|
|
- ./uninstall.sh
|
|
|
+copy_service_script=':';
|
|
|
+print_cmd=false;
|
|
|
+
|
|
|
+for arg in $*; do
|
|
|
+ case $arg in
|
|
|
+ '--openrc')
|
|
|
+ copy_service_script='cp ./dyfi-openrc.sh /etc/init.d/dyfi'
|
|
|
+ ;;
|
|
|
+ '--print-cmd')
|
|
|
+ print_cmd=true
|
|
|
+ ;;
|
|
|
+ esac
|
|
|
+done
|
|
|
+
|
|
|
+cmd=''
|
|
|
+read -r -d '' cmd <<-CMD
|
|
|
+ set -e;
|
|
|
+
|
|
|
+ alias 'cp'='cp --verbose';
|
|
|
+ alias 'mkdir'='mkdir --verbose';
|
|
|
+
|
|
|
+ cd "$dyfi_dir";
|
|
|
+
|
|
|
+ mkdir -p /opt/dyfi;
|
|
|
+ cp ./auth "$install_dir";
|
|
|
+ cp ./dyfi.py "$install_dir";
|
|
|
+ cp ./run.sh "$install_dir";
|
|
|
+ cp ./requirements.txt "$install_dir";
|
|
|
+
|
|
|
+ "$copy_service_script";
|
|
|
+
|
|
|
+ cd "$install_dir";
|
|
|
+
|
|
|
+ python -m venv ./venv;
|
|
|
+ . ./venv/bin/activate;
|
|
|
+ python -m ensurepip;
|
|
|
+ pip install --upgrade pip;
|
|
|
+ pip install -r ./requirements.txt;
|
|
|
+
|
|
|
+ ln -sf "$install_dir"/run.sh /usr/bin/dyfi
|
|
|
+CMD
|
|
|
+
|
|
|
+if [ $print_cmd == true ]; then
|
|
|
+ echo "$cmd"
|
|
|
+else
|
|
|
+ sudo -- env bash -e -c "$cmd"
|
|
|
+ if [ $? != 0 ]; then
|
|
|
+ ./uninstall.sh
|
|
|
+ echo ''
|
|
|
+ echo "Installation failed"
|
|
|
+ fi
|
|
|
+
|
|
|
+ echo ''
|
|
|
+ echo "Dyfi installed to "$install_dir""
|
|
|
fi
|
|
|
+
|