mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-18 23:45:52 +08:00
update
This commit is contained in:
+3
-51
@@ -129,65 +129,17 @@ def contentReplace(content):
|
||||
content = content.replace('{$REDIS_PASS}', mw.getRandomString(10))
|
||||
return content
|
||||
|
||||
|
||||
|
||||
def initDreplace():
|
||||
|
||||
file_tpl = getInitDTpl()
|
||||
service_path = mw.getServerDir()
|
||||
|
||||
initD_path = getServerDir() + '/init.d'
|
||||
if not os.path.exists(initD_path):
|
||||
os.mkdir(initD_path)
|
||||
file_bin = initD_path + '/' + getPluginName()
|
||||
|
||||
# initd replace
|
||||
if not os.path.exists(file_bin):
|
||||
content = mw.readFile(file_tpl)
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
mw.writeFile(file_bin, content)
|
||||
mw.execShell('chmod +x ' + file_bin)
|
||||
|
||||
# log
|
||||
dataLog = getServerDir() + '/data'
|
||||
if not os.path.exists(dataLog):
|
||||
mw.execShell('mkdir -p ' + dataLog)
|
||||
mw.execShell('chmod +x ' + file_bin)
|
||||
|
||||
# config replace
|
||||
dst_conf = getConf()
|
||||
dst_conf_init = getServerDir() + '/init.pl'
|
||||
if not os.path.exists(dst_conf_init):
|
||||
conf_content = mw.readFile(getConfTpl())
|
||||
conf_content = conf_content.replace('{$SERVER_PATH}', service_path)
|
||||
conf_content = conf_content.replace('{$REDIS_PASS}', mw.getRandomString(10))
|
||||
|
||||
mw.writeFile(dst_conf, conf_content)
|
||||
mw.writeFile(dst_conf_init, 'ok')
|
||||
|
||||
# systemd
|
||||
systemDir = mw.systemdCfgDir()
|
||||
systemService = systemDir + '/' + getPluginName() + '.service'
|
||||
if os.path.exists(systemDir) and not os.path.exists(systemService):
|
||||
systemServiceTpl = getPluginDir() + '/init.d/' + getPluginName() + '.service.tpl'
|
||||
service_path = mw.getServerDir()
|
||||
content = mw.readFile(systemServiceTpl)
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
mw.writeFile(systemService, content)
|
||||
mw.execShell('systemctl daemon-reload')
|
||||
|
||||
return file_bin
|
||||
return True
|
||||
|
||||
|
||||
def ladpOp(method):
|
||||
file = initDreplace()
|
||||
initDreplace()
|
||||
|
||||
current_os = mw.getOs()
|
||||
if current_os == "darwin":
|
||||
data = mw.execShell(file + ' ' + method)
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return data[1]
|
||||
return 'ok'
|
||||
|
||||
if current_os.startswith("freebsd"):
|
||||
data = mw.execShell('service slapd ' + method)
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
[Unit]
|
||||
Description=Redis In-Memory Data Store
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
ExecStart={$SERVER_PATH}/redis/bin/redis-server {$SERVER_PATH}/redis/redis.conf
|
||||
ExecReload=/bin/kill -USR2 $MAINPID
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,77 +0,0 @@
|
||||
#!/bin/sh
|
||||
# chkconfig: 2345 55 25
|
||||
# description: Redis Service
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: Redis
|
||||
# Required-Start: $all
|
||||
# Required-Stop: $all
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: starts Redis
|
||||
# Description: starts the MDW-Web
|
||||
### END INIT INFO
|
||||
|
||||
# Simple Redis init.d script conceived to work on Linux systems
|
||||
# as it does use of the /proc filesystem.
|
||||
|
||||
CONF="{$SERVER_PATH}/redis/redis.conf"
|
||||
REDISPORT=$(cat $CONF |grep port|grep -v '#'|awk '{print $2}')
|
||||
REDISPASS=$(cat $CONF |grep requirepass|grep -v '#'|awk '{print $2}')
|
||||
if [ "$REDISPASS" != "" ];then
|
||||
REDISPASS=" -a $REDISPASS"
|
||||
fi
|
||||
EXEC={$SERVER_PATH}/redis/bin/redis-server
|
||||
CLIEXEC="{$SERVER_PATH}/redis/bin/redis-cli -p $REDISPORT$REDISPASS"
|
||||
PIDFILE={$SERVER_PATH}/redis/redis.pid
|
||||
|
||||
echo $REDISPASS
|
||||
echo $REDISPORT
|
||||
echo $CLIEXEC
|
||||
|
||||
mkdir -p {$SERVER_PATH}/redis/data
|
||||
|
||||
redis_start(){
|
||||
if [ -f $PIDFILE ];then
|
||||
kill -9 `cat $PIDFILE`
|
||||
fi
|
||||
|
||||
echo "Starting Redis server..."
|
||||
nohup $EXEC $CONF >> {$SERVER_PATH}/redis/logs.pl 2>&1 &
|
||||
}
|
||||
redis_stop(){
|
||||
if [ ! -f $PIDFILE ]
|
||||
then
|
||||
echo "$PIDFILE does not exist, process is not running"
|
||||
else
|
||||
PID=$(cat $PIDFILE)
|
||||
echo "Stopping ..."
|
||||
$CLIEXEC shutdown save 2>/dev/null
|
||||
while [ -x /proc/${PID} ]
|
||||
do
|
||||
echo "Waiting for Redis to shutdown ..."
|
||||
sleep 1
|
||||
done
|
||||
echo "Redis stopped"
|
||||
rm -rf $PIDFILE
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
redis_start
|
||||
;;
|
||||
stop)
|
||||
redis_stop
|
||||
;;
|
||||
restart|reload)
|
||||
redis_stop
|
||||
sleep 0.3
|
||||
redis_start
|
||||
;;
|
||||
*)
|
||||
echo "Please use start or stop as first argument"
|
||||
;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user