Skip to content

Commit cdf0cc4

Browse files
authored
Merge pull request #1 from crowdsecurity/enable_service
2 parents 6d30699 + 2f9bd30 commit cdf0cc4

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

scripts/install.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,20 @@ gen_config_file() {
3333
}
3434

3535

36+
if ! [ $(id -u) = 0 ]; then
37+
log_err "Please run the install script as root or with sudo"
38+
exit 1
39+
fi
3640
echo "Installing cs-custom-bouncer"
3741
install_custom_bouncer
3842
gen_apikey
3943
gen_binary_path
4044
gen_config_file
45+
systemctl enable cs-custom-bouncer.service
46+
if ! [ -f "$BINARY_PATH" ]; then
47+
echo "$BINARY_PATH doesn't exist, can't start cs-custom-bouncer service."
48+
echo "Please edit ${CONFIG_DIR}cs-custom-bouncer.yaml with a real binary path and run 'sudo systemctl start cs-custom-bouncer'."
49+
exit 1
50+
fi
51+
systemctl start cs-custom-bouncer.service
4152
echo "cs-custom-bouncer service has been installed!"

scripts/uninstall.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
SYSTEMD_PATH_FILE="/etc/systemd/system/cs-custom-bouncer.service"
4+
LOG_FILE="/var/log/cs-custom-bouncer.log"
5+
CONFIG_DIR="/etc/crowdsec/cs-custom-bouncer/"
6+
BIN_PATH_INSTALLED="/usr/local/bin/cs-custom-bouncer"
7+
8+
uninstall() {
9+
systemctl stop cs-custom-bouncer
10+
rm -rf "${CONFIG_DIR}"
11+
rm -f "${SYSTEMD_PATH_FILE}"
12+
rm -f "${BIN_PATH_INSTALLED}"
13+
rm -f "${LOG_FILE}"
14+
}
15+
16+
uninstall
17+
18+
echo "cs-custom-bouncer uninstall successfully"

0 commit comments

Comments
 (0)