Browse Source

fix restore links sites-enable Пн 06 апр 2026 01:58:30 MSK

root 1 month ago
parent
commit
f1f8c63cbb
1 changed files with 19 additions and 15 deletions
  1. 19 15
      src/avto4certbot.sh

+ 19 - 15
src/avto4certbot.sh

@@ -1,10 +1,10 @@
1
-#!/bin/bash
1
+#!/bin/bash -x
2
 #
2
 #
3
 # author: Koshuba V.O.
3
 # author: Koshuba V.O.
4
 # license: GPL 2.0
4
 # license: GPL 2.0
5
 # create 2022
5
 # create 2022
6
 #
6
 #
7
-version="0.5.4";
7
+version="0.5.7";
8
 sname="avto4certbot";
8
 sname="avto4certbot";
9
 
9
 
10
 # script path
10
 # script path
@@ -101,14 +101,14 @@ if [ ! -d $conf_dir ]; then
101
  mkdir -p $conf_dir;
101
  mkdir -p $conf_dir;
102
 fi
102
 fi
103
 
103
 
104
-##
104
+## create info active config sites 
105
 if [[ "$opt" != "" ]] && [[ $opt != "nginx" ]] && [[ "$opt" == "apache" ]]; then
105
 if [[ "$opt" != "" ]] && [[ $opt != "nginx" ]] && [[ "$opt" == "apache" ]]; then
106
-  find $sites_apache/* -maxdepth 0 -type l -printf '%f\n' >$tmp_dir/active_sites.inf 2>/dev/null;
106
+  ls -F -n $sites_apache/*|awk '{print$9":"$11}' >$tmp_dir/active_sites.inf
107
   get_tools[${#get_tools[@]}]="apache2";
107
   get_tools[${#get_tools[@]}]="apache2";
108
   web_service="$apache2_service";
108
   web_service="$apache2_service";
109
 fi
109
 fi
110
 if [[ "$opt" != "" ]] && [[ $opt != "apache" ]] && [[ "$opt" == "nginx" ]]; then
110
 if [[ "$opt" != "" ]] && [[ $opt != "apache" ]] && [[ "$opt" == "nginx" ]]; then
111
-  find $sites_nginx/* -maxdepth 0 -type l -printf '%f\n' >$tmp_dir/active_sites.inf 2>/dev/null;
111
+  ls -F -n $sites_nginx/*|awk '{print$9":"$11}' >$tmp_dir/active_sites.inf
112
   get_tools[${#get_tools[@]}]="nginx";
112
   get_tools[${#get_tools[@]}]="nginx";
113
   web_service="nginx";
113
   web_service="nginx";
114
 fi
114
 fi
@@ -135,7 +135,7 @@ function checkDep() {
135
             reports=()
135
             reports=()
136
             reports[${#reports[@]}]="Sorry, there are no required packages to work, please install:${pkgdep[@]}"
136
             reports[${#reports[@]}]="Sorry, there are no required packages to work, please install:${pkgdep[@]}"
137
             makeErr
137
             makeErr
138
-            exit
138
+            exit 0
139
         fi
139
         fi
140
     done
140
     done
141
 }
141
 }
@@ -143,16 +143,16 @@ function checkDep() {
143
 function swSites(){
143
 function swSites(){
144
 ## clear active sites
144
 ## clear active sites
145
 if [ "$event_key" = "1" ]; then
145
 if [ "$event_key" = "1" ]; then
146
-active_sites=( $(cat $tmp_dir/active_sites.inf) );
146
+  active_sites=( $(cat $tmp_dir/active_sites.inf|sed 's/:/ /g'|awk '{print$1}') );
147
   for ((xd=0; xd != ${#active_sites[@]}; xd++)); do
147
   for ((xd=0; xd != ${#active_sites[@]}; xd++)); do
148
     if [[ "$opt" != "" ]] && [[ $opt != "nginx" ]] && [[ "$opt" == "apache" ]]; then
148
     if [[ "$opt" != "" ]] && [[ $opt != "nginx" ]] && [[ "$opt" == "apache" ]]; then
149
-      if [ -f $sites_apache/${active_sites[$xd]} ]; then
150
-        rm $sites_apache/${active_sites[$xd]}
149
+      if [ -f ${active_sites[$xd]} ]; then
150
+        rm ${active_sites[$xd]}
151
       fi
151
       fi
152
     fi
152
     fi
153
     if [[ "$opt" != "" ]] && [[ $opt != "apache" ]] && [[ "$opt" == "nginx" ]]; then
153
     if [[ "$opt" != "" ]] && [[ $opt != "apache" ]] && [[ "$opt" == "nginx" ]]; then
154
-      if [ -f $sites_nginx/${active_sites[$xd]} ]; then
155
-        rm $sites_nginx/${active_sites[$xd]}
154
+      if [ -f ${active_sites[$xd]} ]; then
155
+        rm ${active_sites[$xd]}
156
       fi
156
       fi
157
     fi
157
     fi
158
   done
158
   done
@@ -170,13 +170,17 @@ if [ "$event_key" = "0" ]; then
170
   active_sites=( $(cat $tmp_dir/active_sites.inf) );
170
   active_sites=( $(cat $tmp_dir/active_sites.inf) );
171
   for ((xd=0; xd != ${#active_sites[@]}; xd++)); do
171
   for ((xd=0; xd != ${#active_sites[@]}; xd++)); do
172
     if [[ "$opt" != "" ]] && [[ $opt != "nginx" ]] && [[ "$opt" == "apache" ]]; then
172
     if [[ "$opt" != "" ]] && [[ $opt != "nginx" ]] && [[ "$opt" == "apache" ]]; then
173
-      if [ ! -f $sites_apache/${active_sites[$xd]} ]; then
174
-        ln -s $available_apache/${active_sites[$xd]} $sites_apache/${active_sites[$xd]}
173
+      get_enable=$(echo -e ${active_sites[$xd]}|sed 's/:/ /g'|awk '{print$1}');
174
+      get_available=$(echo -e ${active_sites[$xd]}|sed 's/:/ /g'|awk '{print$2}');
175
+      if [ ! -f $get_enable ]; then
176
+        ln -s $get_available $get_enable;
175
       fi
177
       fi
176
     fi
178
     fi
177
     if [[ "$opt" != "" ]] && [[ $opt != "apache" ]] && [[ "$opt" == "nginx" ]]; then
179
     if [[ "$opt" != "" ]] && [[ $opt != "apache" ]] && [[ "$opt" == "nginx" ]]; then
178
-      if [ ! -f $sites_nginx/${active_sites[$xd]} ]; then
179
-        ln -s $available_nginx/${active_sites[$xd]} $sites_nginx/${active_sites[$xd]}
180
+      get_enable=$(echo -e ${active_sites[$xd]}|sed 's/:/ /g'|awk '{print$1}');
181
+      get_available=$(echo -e ${active_sites[$xd]}|sed 's/:/ /g'|awk '{print$2}');
182
+      if [ ! -f $get_enable ]; then
183
+        ln -s $get_available $get_enable;
180
       fi
184
       fi
181
     fi
185
     fi
182
   done
186
   done