From 76ca8ced90c9b693fe1bb419514fe54ae9a5989e Mon Sep 17 00:00:00 2001 From: BoHung Chiu Date: Fri, 17 Feb 2023 16:42:38 +0800 Subject: [PATCH] Fix bug. --- install_nginx.sh | 2 +- install_orbit_environment.sh | 4 +- orbit_service.sh | 129 ++++++++++++++++++++++------------- 3 files changed, 84 insertions(+), 51 deletions(-) diff --git a/install_nginx.sh b/install_nginx.sh index a24d1bd..ccd99ba 100644 --- a/install_nginx.sh +++ b/install_nginx.sh @@ -136,7 +136,7 @@ if [[ ! -f /etc/init.d/nginx ]]; then sudo wget http://gitlab.tp.rulingcom.com/erictyl/install_r45_on_ubuntu_1804lts_doc/-/raw/master/nginx.service -O /lib/systemd/system/nginx.service sudo chown root:root /lib/systemd/system/nginx.service sudo chmod 644 /lib/systemd/system/nginx.service - sudo chmod +x /lib/systemd/system/nginx.service + sudo chmod -x /lib/systemd/system/nginx.service sudo systemctl daemon-reload sudo systemctl unmask nginx sudo systemctl enable nginx diff --git a/install_orbit_environment.sh b/install_orbit_environment.sh index aefcb79..16e1f19 100644 --- a/install_orbit_environment.sh +++ b/install_orbit_environment.sh @@ -18,9 +18,7 @@ if [[ ! -e "/usr/lib/x86_64-linux-gnu/librt.so" ]]; then sudo ln -s /usr/lib/x86_64-linux-gnu/librt.so.1 /usr/lib/x86_64-linux-gnu/librt.so fi org_pwd=$(pwd) -if [[ $ubuntu_version =~ '14' ]]; then - sudo apt install libgmp-dev -y -fi +sudo apt install -y libncurses5-dev libgmp-dev echo "postfix postfix/mailname string $USER" | sudo debconf-set-selections echo "postfix postfix/main_mailer_type string 'Local only'" | sudo debconf-set-selections sudo apt-get install -y postfix diff --git a/orbit_service.sh b/orbit_service.sh index b549ddf..b248d6e 100644 --- a/orbit_service.sh +++ b/orbit_service.sh @@ -42,8 +42,11 @@ sig () { get_orbit_root () { if [ ! -f $NGINX_ORBIT_SITES/$1 ]; then echo "Site $1 not found" && exit 0; fi ORBIT_ROOT=`cat $NGINX_ORBIT_SITES/$1 | grep 'root' | grep -v '#' | xargs | awk '{print $2}'`; - ORBIT_ROOT=${ORBIT_ROOT//"/public;"/""}; - if [ ! -d $ORBIT_ROOT ]; then echo "Site folder $ORBIT_ROOT not fount"; fi + ORBIT_ROOT="${ORBIT_ROOT//"/public;"/""}"; + if [ ! -d "$ORBIT_ROOT" ]; then + echo "Site folder $ORBIT_ROOT not found"; + ORBIT_ROOT=""; + fi } start_orbit () { @@ -61,15 +64,23 @@ bundle_orbit () { case $1 in install) if [ ! -z "$2" ]; then - get_orbit_root $2 - bundle_orbit - else - closed_sites="$(cat /home/$ORBIT_USER/closed_sites.txt)" - for APP in `ls -1 $NGINX_ORBIT_SITES`; do - get_orbit_root $APP; - if [[ ! "$closed_sites" =~ "$ORBIT_ROOT" ]]; then + get_orbit_root $2; + if [ ! -z "$ORBIT_ROOT" ]; then bundle_orbit; - fi + fi + else + if [ -e "/home/$ORBIT_USER/closed_sites.txt" ]; then + closed_sites="$(cat /home/$ORBIT_USER/closed_sites.txt)"; + else + closed_sites=""; + fi + for APP in `ls -1 $NGINX_ORBIT_SITES`; do + get_orbit_root $APP; + if [ ! -z "$ORBIT_ROOT" ]; then + if [[ ! "$closed_sites" =~ "$ORBIT_ROOT" ]]; then + bundle_orbit; + fi + fi done fi @@ -77,18 +88,26 @@ install) ;; start) if [ ! -z "$2" ]; then - get_orbit_root $2 - start_orbit - else - closed_sites="$(cat /home/$ORBIT_USER/closed_sites.txt)" - for APP in `ls -1 $NGINX_ORBIT_SITES`; do - get_orbit_root $APP; - if [[ "$closed_sites" =~ "$ORBIT_ROOT" ]]; then - echo "Stopping $ORBIT_ROOT"; - sig QUIT && continue; - else + get_orbit_root $2; + if [ ! -z "$ORBIT_ROOT" ]; then start_orbit; - fi + fi + else + if [ -e "/home/$ORBIT_USER/closed_sites.txt" ]; then + closed_sites="$(cat /home/$ORBIT_USER/closed_sites.txt)"; + else + closed_sites=""; + fi + for APP in `ls -1 $NGINX_ORBIT_SITES`; do + get_orbit_root $APP; + if [ ! -z "$ORBIT_ROOT" ]; then + if [[ "$closed_sites" =~ "$ORBIT_ROOT" ]]; then + echo "Stopping $ORBIT_ROOT"; + sig QUIT && continue; + else + start_orbit; + fi + fi done fi @@ -108,14 +127,18 @@ stop) esac done if [ ! -z "$2" ]; then - get_orbit_root $2 - echo "Stopping $ORBIT_ROOT" - sig QUIT + get_orbit_root $2; + if [ ! -z "$ORBIT_ROOT" ]; then + echo "Stopping $ORBIT_ROOT"; + sig QUIT; + fi else for APP in `ls -1 $NGINX_ORBIT_SITES`; do - get_orbit_root $APP; - echo "Stopping $ORBIT_ROOT"; - sig QUIT && continue; + get_orbit_root $APP; + if [ ! -z "$ORBIT_ROOT" ]; then + echo "Stopping $ORBIT_ROOT"; + sig QUIT && continue; + fi done fi exit 0; @@ -134,36 +157,48 @@ force-stop) esac done if [ ! -z "$2" ]; then - get_orbit_root $2 - echo "Stopping $ORBIT_ROOT" - sig TERM + get_orbit_root $2; + if [ ! -z "$ORBIT_ROOT" ]; then + echo "Stopping $ORBIT_ROOT"; + sig TERM; + fi else for APP in `ls -1 $NGINX_ORBIT_SITES`; do - get_orbit_root $APP; - echo "Stopping $ORBIT_ROOT"; - sig TERM && continue; + get_orbit_root $APP; + if [ ! -z "$ORBIT_ROOT" ]; then + echo "Stopping $ORBIT_ROOT"; + sig TERM && continue; + fi done fi exit 0; ;; restart|reload) if [ ! -z "$2" ]; then - get_orbit_root $2 - sig USR2 && echo "$ORBIT_ROOT reloaded OK" && exit 0 - echo >&2 "Couldn't reload $ORBIT_ROOT, starting instead" - start_orbit - else - closed_sites="$(cat /home/$ORBIT_USER/closed_sites.txt)" - for APP in `ls -1 $NGINX_ORBIT_SITES`; do - get_orbit_root $APP; - if [[ "$closed_sites" =~ "$ORBIT_ROOT" ]]; then - echo "Stopping $ORBIT_ROOT"; - sig QUIT && continue; - else - sig USR2 && echo "$ORBIT_ROOT reloaded OK" && continue; + get_orbit_root $2; + if [ ! -z "$ORBIT_ROOT" ]; then + sig USR2 && echo "$ORBIT_ROOT reloaded OK" && exit 0; echo >&2 "Couldn't reload $ORBIT_ROOT, starting instead"; start_orbit; - fi + fi + else + if [ -e "/home/$ORBIT_USER/closed_sites.txt" ]; then + closed_sites="$(cat /home/$ORBIT_USER/closed_sites.txt)"; + else + closed_sites=""; + fi + for APP in `ls -1 $NGINX_ORBIT_SITES`; do + get_orbit_root $APP; + if [ ! -z "$ORBIT_ROOT" ]; then + if [[ "$closed_sites" =~ "$ORBIT_ROOT" ]]; then + echo "Stopping $ORBIT_ROOT"; + sig QUIT && continue; + else + sig USR2 && echo "$ORBIT_ROOT reloaded OK" && continue; + echo >&2 "Couldn't reload $ORBIT_ROOT, starting instead"; + start_orbit; + fi + fi done fi exit 0;