summaryrefslogtreecommitdiff
path: root/tools/beforeinstall.sh
blob: ef6eea5146568f5791a5e2f42c77808069412e55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash

WEB_PATH=/opt/nezha/nz-web

if [ 2 -eq $1 ];then
	if [ ! -d ${WEB_PATH}/config ];then
		exit 0
	fi

        echo "stop nz-web.service"
        systemctl stop nz-web.service
	
	TMP_PATH=/tmp/nezha/nz-web
	rm -rf $TMP_PATH

	mkdir -p $TMP_PATH
	cp -rf $WEB_PATH/config $TMP_PATH
	echo 'backup config file from '${WEB_PATH}
	
	if [ 0 -lt $(rpm -aq nz-web|wc -w) ];then
		echo 'clean before install...'
		rm -rf $WEB_PATH
	fi
fi