|
|
@@ -1,10 +1,10 @@
|
|
1
|
|
-#!/bin/bash
|
|
|
1
|
+#!/bin/bash -x
|
|
2
|
2
|
#
|
|
3
|
3
|
# author: Koshuba V.O.
|
|
4
|
4
|
# license: GPL 2.0
|
|
5
|
5
|
# create 2022
|
|
6
|
6
|
#
|
|
7
|
|
-version="0.5.4";
|
|
|
7
|
+version="0.5.7";
|
|
8
|
8
|
sname="avto4certbot";
|
|
9
|
9
|
|
|
10
|
10
|
# script path
|
|
|
@@ -101,14 +101,14 @@ if [ ! -d $conf_dir ]; then
|
|
101
|
101
|
mkdir -p $conf_dir;
|
|
102
|
102
|
fi
|
|
103
|
103
|
|
|
104
|
|
-##
|
|
|
104
|
+## create info active config sites
|
|
105
|
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
|
107
|
get_tools[${#get_tools[@]}]="apache2";
|
|
108
|
108
|
web_service="$apache2_service";
|
|
109
|
109
|
fi
|
|
110
|
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
|
112
|
get_tools[${#get_tools[@]}]="nginx";
|
|
113
|
113
|
web_service="nginx";
|
|
114
|
114
|
fi
|
|
|
@@ -135,7 +135,7 @@ function checkDep() {
|
|
135
|
135
|
reports=()
|
|
136
|
136
|
reports[${#reports[@]}]="Sorry, there are no required packages to work, please install:${pkgdep[@]}"
|
|
137
|
137
|
makeErr
|
|
138
|
|
- exit
|
|
|
138
|
+ exit 0
|
|
139
|
139
|
fi
|
|
140
|
140
|
done
|
|
141
|
141
|
}
|
|
|
@@ -143,16 +143,16 @@ function checkDep() {
|
|
143
|
143
|
function swSites(){
|
|
144
|
144
|
## clear active sites
|
|
145
|
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
|
147
|
for ((xd=0; xd != ${#active_sites[@]}; xd++)); do
|
|
148
|
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
|
151
|
fi
|
|
152
|
152
|
fi
|
|
153
|
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
|
156
|
fi
|
|
157
|
157
|
fi
|
|
158
|
158
|
done
|
|
|
@@ -170,13 +170,17 @@ if [ "$event_key" = "0" ]; then
|
|
170
|
170
|
active_sites=( $(cat $tmp_dir/active_sites.inf) );
|
|
171
|
171
|
for ((xd=0; xd != ${#active_sites[@]}; xd++)); do
|
|
172
|
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
|
177
|
fi
|
|
176
|
178
|
fi
|
|
177
|
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
|
184
|
fi
|
|
181
|
185
|
fi
|
|
182
|
186
|
done
|