Skip to content

Commit 91a804c

Browse files
committed
check_result function
1 parent 062b7e8 commit 91a804c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+204
-404
lines changed

bin/v-add-cron-job

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,9 @@ sync_cron_jobs
7272
# Increasing cron value
7373
increase_user_value $user '$U_CRON_JOBS'
7474

75-
# Restart crond
75+
# Restarting crond
7676
$BIN/v-restart-cron
77-
if [ $? -ne 0 ]; then
78-
exit $E_RESTART
79-
fi
77+
check_result $? "Cron restart failed" >/dev/null
8078

8179
# Logging
8280
log_history "added cron job $job"

bin/v-add-cron-reports

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ sync_cron_jobs
4646

4747
# Restart crond
4848
$BIN/v-restart-cron
49-
if [ $? -ne 0 ]; then
50-
exit $E_RESTART
51-
fi
49+
check_result $? "Cron restart failed" >/dev/null
5250

5351
# Logging
5452
log_history "enabled cron reporting"

bin/v-add-cron-vesta-autoupdate

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,9 @@ sync_cron_jobs
6666
# Increasing cron value
6767
increase_user_value $user '$U_CRON_JOBS'
6868

69-
# Restart crond
69+
# Restarting crond
7070
$BIN/v-restart-cron
71-
if [ $? -ne 0 ]; then
72-
exit $E_RESTART
73-
fi
71+
check_result $? "Cron restart failed" >/dev/null
7472

7573
# Logging
7674
log_history "added cron job $job"

bin/v-add-sys-ip

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,12 @@ fi
161161

162162
# Restarting web server
163163
$BIN/v-restart-web
164-
if [ $? -ne 0 ]; then
165-
exit $E_RESTART
166-
fi
164+
check_result $? "Web restart failed" >/dev/null
167165

168166
# Restarting proxy server
169167
if [ ! -z "$PROXY_SYSTEM" ]; then
170168
$BIN/v-restart-proxy
171-
if [ $? -ne 0 ]; then
172-
exit $E_RESTART
173-
fi
169+
check_result $? "Proxy restart failed" >/dev/null
174170
fi
175171

176172
# Restarting firewall

bin/v-add-sys-quota

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,11 @@ source $VESTA/conf/vesta.conf
2222
if [ ! -e "/usr/sbin/setquota" ]; then
2323
if [ -e "/etc/redhat-release" ]; then
2424
yum -y install quota >/dev/null 2>&1
25-
result=$?
25+
check_result $? "quota package installation failed" $E_UPDATE
2626
else
2727
export DEBIAN_FRONTEND=noninteractive
2828
apt-get -y install quota >/dev/null 2>&1
29-
result=$?
30-
fi
31-
32-
# Checking installation status
33-
if [ "$result" -ne 0 ]; then
34-
echo "Error: quota package wasn't successfully installed"
35-
log_event "$E_UPDATE" "$EVENT"
36-
exit $E_UPDATE
29+
check_result $? "quota package installation failed" $E_UPDATE
3730
fi
3831
fi
3932

@@ -66,11 +59,7 @@ chmod a+x /etc/cron.daily/quotacheck
6659
# Enabling fs quota
6760
if [ ! -z "$(quotaon -pa|grep " $mnt "|grep user|grep 'off')" ]; then
6861
quotaon $mnt
69-
if [ $? -ne 0 ]; then
70-
echo "Error: quota can't be enabled on $mnt partition"
71-
log_event "$E_DISK" "$EVENT"
72-
exit $E_DISK
73-
fi
62+
check_result $? "quota can't be enabled in $mtn" $E_DISK
7463
fi
7564

7665
# Updating DISK_QUOTA value

bin/v-add-user

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@ shell=$(grep -w "$shell_conf" /etc/shells |head -n1)
5858

5959
# Adding user
6060
/usr/sbin/useradd "$user" -s "$shell" -c "$email" -m -d "$HOMEDIR/$user"
61-
if [ $? -ne 0 ]; then
62-
echo "Error: user creation failed"
63-
log_event "$E_INVALID" "$EVENT"
64-
exit $E_INVALID
65-
fi
61+
check_result $? "user creation failed" $E_INVALID
6662

6763
# Adding password
6864
echo "$user:$password" | /usr/sbin/chpasswd

bin/v-add-web-domain

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,17 +213,14 @@ str="$str TIME='$TIME' DATE='$DATE'"
213213
# Registering domain
214214
echo "$str" >> $USER_DATA/web.conf
215215

216-
# Restart web server
216+
# Restarting web server
217217
if [ "$restart" != 'no' ]; then
218218
$BIN/v-restart-web
219-
if [ $? -ne 0 ]; then
220-
exit $E_RESTART
221-
fi
219+
check_result $? "Web restart failed" >/dev/null
220+
222221
if [ ! -z "$PROXY_SYSTEM" ]; then
223222
$BIN/v-restart-proxy
224-
if [ $? -ne 0 ]; then
225-
exit $E_RESTART
226-
fi
223+
check_result $? "Proxy restart failed" >/dev/null
227224
fi
228225
fi
229226

bin/v-add-web-domain-alias

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ if [ "$SSL" = 'yes' ]; then
7575
fi
7676

7777
# Checking proxy
78-
if [ ! -z "$PROXY" ]; then
78+
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
7979
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
8080
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
8181
del_web_config
@@ -100,16 +100,14 @@ update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS"
100100
# Update counters
101101
increase_user_value "$user" '$U_WEB_ALIASES'
102102

103-
# Adding task to the vesta pipe
103+
# Restarting web server
104104
if [ "$restart" != 'no' ]; then
105105
$BIN/v-restart-web
106-
if [ $? -ne 0 ]; then
107-
exit $E_RESTART
108-
fi
106+
check_result $? "Web restart failed" >/dev/null
109107

110-
$BIN/v-restart-proxy
111-
if [ $? -ne 0 ]; then
112-
exit $E_RESTART
108+
if [ ! -z "$PROXY_SYSTEM" ]; then
109+
$BIN/v-restart-proxy
110+
check_result $? "Proxy restart failed" >/dev/null
113111
fi
114112
fi
115113

bin/v-add-web-domain-backend

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ cat $WEBTPL/$WEB_BACKEND/$template.tpl |\
6767
# Restart backend server
6868
if [ "$restart" != 'no' ]; then
6969
$BIN/v-restart-web-backend
70-
if [ $? -ne 0 ]; then
71-
exit $E_RESTART
72-
fi
70+
check_result $? "Web backend restart failed" >/dev/null
7371
fi
7472

7573
# Logging

bin/v-add-web-domain-proxy

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,10 @@ fi
100100
update_object_value 'web' 'DOMAIN' "$domain" '$PROXY' "$PROXY"
101101
update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' "$extentions"
102102

103-
# Restart web server
103+
# Restarting web server
104104
if [ "$restart" != 'no' ]; then
105105
$BIN/v-restart-proxy
106-
if [ $? -ne 0 ]; then
107-
exit $E_RESTART
108-
fi
106+
check_result $? "Proxy restart failed" >/dev/null
109107
fi
110108

111109
log_history "enabled proxy support for $domain"

0 commit comments

Comments
 (0)