From 88eaea2a266b7c56b9b2b86eb890e6ae7d527719 Mon Sep 17 00:00:00 2001 From: hael Date: Mon, 8 Jan 2024 11:50:02 +0000 Subject: [PATCH] gentooize --- install.sh | 92 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 61 insertions(+), 31 deletions(-) diff --git a/install.sh b/install.sh index 4fc0a44..b13d8d7 100755 --- a/install.sh +++ b/install.sh @@ -182,11 +182,12 @@ check_dirs_and_files() { } check_running() { - - # Custom gentoo docker status check - DOCKERD_STATUS=$($SUDO_CMD rc-status 2>/dev/null | grep docker | grep started | wc -l); - if [ "$DOCKERD_STATUS" == "0" ]; then + DOCKERD_STATUS="0"; + + which systemctl; + + if [ "$?" == "0" ]; then DOCKERD_STATUS=$($SUDO_CMD systemctl status docker | grep running | wc -l) if [ "$DOCKERD_STATUS" == "0" ]; then $SUDO_CMD systemctl start docker @@ -197,6 +198,27 @@ check_running() { exit; fi fi + DEBIAN="true"; + else + echo "systemctl was not found"; + echo "Do you want to continue? (Y/n)"; + read -r ANSWER; + if [ "$ANSWER" == "y" ] || [ "$ANSWER" == "Y" ] || [ "$ANSWER" == "" ] ; then + # Custom gentoo docker status check + DOCKERD_STATUS=$($SUDO_CMD rc-status 2>/dev/null | grep docker | grep started | wc -l); + if [ "$DOCKERD_STATUS" == "0" ]; then + $SUDO_CMD /etc/init.d/docker start + sleep 5; + DOCKERD_STATUS=$($SUDO_CMD rc-status 2>/dev/null | grep docker | grep started | wc -l); + if [ "$DOCKERD_STATUS" == "0" ]; then + echo "Docker daemon not running, please check and execute again the install script"; + exit; + fi + fi; + GENTOO="true"; + else + exit; + fi; fi # bridge check @@ -836,37 +858,40 @@ if [ "$DISCOVERY" == "yes" ] ; then fi; fi; +if [ "$DEBIAN" == "true" ] || [ "$GENTOO" == "true" ] ; then -echo "Do you want to start the discovered and actually started services at the next time when your system restarting? (Y/n)"; -read -r ANSWER; -if [ "$ANSWER" == "y" ] || [ "$ANSWER" == "Y" ] || [ "$ANSWER" == "" ] ; then + echo "Do you want to start the discovered and actually started services at the next time when your system restarting? (Y/n)"; + read -r ANSWER; + if [ "$ANSWER" == "y" ] || [ "$ANSWER" == "Y" ] || [ "$ANSWER" == "" ] ; then - cp $DISCOVERY_CONFIG_FILE $DISCOVERY_CONFIG_FILE".copy"; - cp $DEST_FILE $DEST_FILE".copy"; + cp $DISCOVERY_CONFIG_FILE $DISCOVERY_CONFIG_FILE".copy"; + cp $DEST_FILE $DEST_FILE".copy"; - DISCOVERY_CONFIG_FILENAME=$(basename $DISCOVERY_CONFIG_FILE); - source $DISCOVERY_CONFIG_FILE; - { - echo '#!/bin/bash'; - echo 'SOURCE_DIRS="'$SOURCE_DIRS'"; # separator space or |'; - echo 'DIRNAME="'$DIRNAME'"; # separator space or |'; - echo 'FILENAME="'$FILENAME'"; # separator space or |'; - echo 'KEYS="'$KEYS'"; # separator space or |'; - echo 'DEST_FILE="/usr/local/etc/results.txt";'; - echo 'USE_SUDO=0;'; - } > /tmp/$DISCOVERY_CONFIG_FILENAME + DISCOVERY_CONFIG_FILENAME=$(basename $DISCOVERY_CONFIG_FILE); + source $DISCOVERY_CONFIG_FILE; + { + echo '#!/bin/bash'; + echo 'SOURCE_DIRS="'$SOURCE_DIRS'"; # separator space or |'; + echo 'DIRNAME="'$DIRNAME'"; # separator space or |'; + echo 'FILENAME="'$FILENAME'"; # separator space or |'; + echo 'KEYS="'$KEYS'"; # separator space or |'; + echo 'DEST_FILE="/usr/local/etc/results.txt";'; + echo 'USE_SUDO=0;'; + } > /tmp/$DISCOVERY_CONFIG_FILENAME - $SUDO_CMD mv /tmp/$DISCOVERY_CONFIG_FILENAME /usr/local/etc/$DISCOVERY_CONFIG_FILENAME + $SUDO_CMD mv /tmp/$DISCOVERY_CONFIG_FILENAME /usr/local/etc/$DISCOVERY_CONFIG_FILENAME - { - cat $PWD/.init_services; - cat $DEST_FILE; - } > /tmp/$DEST_FILE + { + cat $PWD/.init_services; + cat $DEST_FILE; + } > /tmp/$DEST_FILE - $SUDO_CMD mv /tmp/$DEST_FILE /usr/local/etc/$DEST_FILE + $SUDO_CMD mv /tmp/$DEST_FILE /usr/local/etc/$DEST_FILE - { - echo " + + if [ "$DEBIAN" == "true" ] ; then + { + echo " [Unit] Description=Discover services @@ -878,10 +903,15 @@ ExecStart=/usr/local/bin/service-files.sh /usr/local/etc/results.txt restart WantedBy=multi-user.target "; - } > /tmp/discovery.service + } > /tmp/discovery.service + $SUDO_CMD mv /tmp/discovery.service /etc/systemd/system/discovery.service + $SUDO_CMD systemctl enable discovery.service - $SUDO_CMD mv /tmp/discovery.service /etc/systemd/system/discovery.service - $SUDO_CMD systemctl enable discovery.service + else if [ "$GENTOO" == "true" ] ; then + $SUDO_CMD echo "/usr/local/bin/service-files.sh /usr/local/etc/results.txt restart" > /etc/local.d/service-file.start; + $SUDO_CMD chmod a+x /etc/local.d/service-file.start; + fi; + fi; fi; rm $PWD/.init_services