Skip to content

Commit 870fe18

Browse files
author
Christoph Schläpfer
committed
Fixed ShellCheck error on v-delete-sys-snappymail
1 parent a1fed06 commit 870fe18

File tree

1 file changed

+89
-89
lines changed

1 file changed

+89
-89
lines changed

bin/v-delete-sys-snappymail

Lines changed: 89 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,89 @@
1-
#!/bin/bash
2-
# info: Delete SnappyMail webmail client
3-
# options: None
4-
#
5-
# This function removes the SnappyMail webmail client.
6-
7-
#----------------------------------------------------------#
8-
# Variables & Functions #
9-
#----------------------------------------------------------#
10-
11-
# Includes
12-
# shellcheck source=/etc/hestiacp/hestia.conf
13-
source /etc/hestiacp/hestia.conf
14-
# shellcheck source=/usr/local/hestia/func/main.sh
15-
source $HESTIA/func/main.sh
16-
# load config file
17-
source_conf "$HESTIA/conf/hestia.conf"
18-
# upgrade config file
19-
source "$HESTIA/install/upgrade/upgrade.conf"
20-
21-
# Folder paths
22-
SM_INSTALL_DIR="/var/lib/snappymail"
23-
SM_CONFIG_DIR="/etc/snappymail"
24-
SM_LOG="/var/log/snappymail"
25-
26-
#----------------------------------------------------------#
27-
# Verifications #
28-
#----------------------------------------------------------#
29-
30-
# Checking root permissions
31-
if [ "x$(id -u)" != 'x0' ]; then
32-
echo "ERROR: v-add-sys-snappymail can only be executed by the root user"
33-
exit 10
34-
fi
35-
36-
# Ensure that $HESTIA (/usr/local/hestia/) and other variables are valid.
37-
if [ -z "$HESTIA" ]; then
38-
HESTIA="/usr/local/hestia"
39-
fi
40-
41-
if [ -z "$HOMEDIR" ] || [ -z "$HESTIA_INSTALL_DIR" ]; then
42-
echo "ERROR: Environment variables not present, uninstallation aborted."
43-
exit 2
44-
fi
45-
46-
if [ -z "$(echo "$DB_SYSTEM" | grep -w 'mysql')" ]; then
47-
echo "ERROR: Mysql not available. Uninstallation aborted"
48-
exit 2
49-
fi
50-
51-
# Get current version
52-
if [ -f "/var/lib/snappymail/data/VERSION" ]; then
53-
version=$(cat /var/lib/snappymail/data/VERSION)
54-
else
55-
echo "Error: SnappyMail is not installed"
56-
exit 2
57-
fi
58-
59-
# Perform verification if read-only mode is enabled
60-
check_hestia_demo_mode
61-
62-
#----------------------------------------------------------#
63-
# Action #
64-
#----------------------------------------------------------#
65-
66-
rm -f -r $SM_INSTALL_DIR
67-
rm -f -r $SM_CONFIG_DIR
68-
rm ~/.snappymail
69-
70-
if [ -f '/usr/bin/mariadb' ]; then
71-
mariadb -e "DROP DATABASE snappymail" 2>&1
72-
mariadb -e "DROP USER snappymail@localhost"
73-
else
74-
mysql -e "DROP DATABASE snappymail" 2>&1
75-
mysql -e "DROP USER snappymail@localhost"
76-
fi
77-
# Updating hestia.conf
78-
if [ -z "$(echo "$WEBMAIL_SYSTEM" | grep -w 'snappymail')" ]; then
79-
# remove snappymail from webmail list and make sure the string doesn't start with a comma
80-
$BIN/v-change-sys-config-value 'WEBMAIL_SYSTEM' "$(echo "$WEBMAIL_SYSTEM" | sed "s/snappymail//g" | sed 's/^,//g')"
81-
fi
82-
83-
#----------------------------------------------------------#
84-
# Hestia #
85-
#----------------------------------------------------------#
86-
87-
$BIN/v-log-action "system" "Info" "Plugins" "SnappyMail removed (Version: $version)."
88-
89-
log_event "$OK" "$ARGUMENTS"
1+
#!/bin/bash
2+
# info: Delete SnappyMail webmail client
3+
# options: None
4+
#
5+
# This function removes the SnappyMail webmail client.
6+
7+
#----------------------------------------------------------#
8+
# Variables & Functions #
9+
#----------------------------------------------------------#
10+
11+
# Includes
12+
# shellcheck source=/etc/hestiacp/hestia.conf
13+
source /etc/hestiacp/hestia.conf
14+
# shellcheck source=/usr/local/hestia/func/main.sh
15+
source $HESTIA/func/main.sh
16+
# load config file
17+
source_conf "$HESTIA/conf/hestia.conf"
18+
# upgrade config file
19+
source "$HESTIA/install/upgrade/upgrade.conf"
20+
21+
# Folder paths
22+
SM_INSTALL_DIR="/var/lib/snappymail"
23+
SM_CONFIG_DIR="/etc/snappymail"
24+
SM_LOG="/var/log/snappymail"
25+
26+
#----------------------------------------------------------#
27+
# Verifications #
28+
#----------------------------------------------------------#
29+
30+
# Checking root permissions
31+
if [ "x$(id -u)" != 'x0' ]; then
32+
echo "ERROR: v-add-sys-snappymail can only be executed by the root user"
33+
exit 10
34+
fi
35+
36+
# Ensure that $HESTIA (/usr/local/hestia/) and other variables are valid.
37+
if [ -z "$HESTIA" ]; then
38+
HESTIA="/usr/local/hestia"
39+
fi
40+
41+
if [ -z "$HOMEDIR" ] || [ -z "$HESTIA_INSTALL_DIR" ]; then
42+
echo "ERROR: Environment variables not present, uninstallation aborted."
43+
exit 2
44+
fi
45+
46+
if [ -z "$(echo "$DB_SYSTEM" | grep -w 'mysql')" ]; then
47+
echo "ERROR: Mysql not available. Uninstallation aborted"
48+
exit 2
49+
fi
50+
51+
# Get current version
52+
if [ -f "/var/lib/snappymail/data/VERSION" ]; then
53+
version=$(cat /var/lib/snappymail/data/VERSION)
54+
else
55+
echo "Error: SnappyMail is not installed"
56+
exit 2
57+
fi
58+
59+
# Perform verification if read-only mode is enabled
60+
check_hestia_demo_mode
61+
62+
#----------------------------------------------------------#
63+
# Action #
64+
#----------------------------------------------------------#
65+
66+
rm -f -r $SM_INSTALL_DIR
67+
rm -f -r $SM_CONFIG_DIR
68+
rm ~/.snappymail
69+
70+
if [ -f '/usr/bin/mariadb' ]; then
71+
mariadb -e "DROP DATABASE snappymail" 2>&1
72+
mariadb -e "DROP USER snappymail@localhost"
73+
else
74+
mysql -e "DROP DATABASE snappymail" 2>&1
75+
mysql -e "DROP USER snappymail@localhost"
76+
fi
77+
# Updating hestia.conf
78+
if [ -z "$(echo "$WEBMAIL_SYSTEM" | grep -w 'snappymail')" ]; then
79+
# remove snappymail from webmail list and make sure the string doesn't start with a comma
80+
$BIN/v-change-sys-config-value 'WEBMAIL_SYSTEM' "$(echo "$WEBMAIL_SYSTEM" | sed "s/snappymail//g" | sed 's/^,//g')"
81+
fi
82+
83+
#----------------------------------------------------------#
84+
# Hestia #
85+
#----------------------------------------------------------#
86+
87+
$BIN/v-log-action "system" "Info" "Plugins" "SnappyMail removed (Version: $version)."
88+
89+
log_event "$OK" "$ARGUMENTS"

0 commit comments

Comments
 (0)