-
Notifications
You must be signed in to change notification settings - Fork 0
/
saprouter
80 lines (68 loc) · 1.94 KB
/
saprouter
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/sh
# PROVIDE: saprouter
# REQUIRE: LOGIN DAEMON NETWORKING
# KEYWORD: shutdown
. /etc/rc.subr
name=saprouter
rcvar=${name}_enable
pidfile="/var/run/${name}.pid"
extra_commands="status"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
status_cmd="${name}_status"
#start_precmd="echo \"Starting SAPRouter\""
#stop_postcmd="echo \"Bye-Bye\""
load_rc_config ${name}
: ${saprouter_enable="NO"}
: ${saprouter_cn=""}
: ${saprouter_verbosity=1}
: ${saprouter_port=3299}
: ${saprouter_saprouttab="/usr/saprouter/saprouttab"}
: ${saprouter_hostname="localhost"}
: ${saprouter_user="saprouter"}
: ${saprouter_log="/var/log/saprouter.log"}
: ${saprouter_directory="/usr/sap/saprouter"}
: ${saprouter_snclib="/usr/sap/saprouter/libsapcrypto.so"}
saprouter_start() {
if saprouter_is_running
then
echo "SAPRouter is already running!"
else
echo "Starting SAPRouter..."
su -m ${saprouter_user} -c "export SECUDIR=${saprouter_directory};export SNC_LIB=${saprouter_snclib};${saprouter_directory}/${name} -r -S ${saprouter_port} -K \"p:${saprouter_cn}\" -R ${saprouter_saprouttab} -V ${saprouter_verbosity} -H ${saprouter_hostname} -T ${saprouter_log} > /dev/null &";
if saprouter_is_running
then
echo "SAPRouter has started!"
else
echo "Error has occurred when starting SAPRouter, please check ${saprouter_log} file for more details!"
fi
fi
}
saprouter_stop() {
if saprouter_is_running
then
echo "Stopping SAPRouter"
su -m ${saprouter_user} -c "${saprouter_directory}/${name} -s -H ${saprouter_hostname} > /dev/null"
else
echo "SAPRouter is already stopped!"
fi
}
saprouter_status() {
if saprouter_is_running;
then
echo "SAPRouter service is running!"
else
echo "SAPRouter service is NOT running!"
fi
}
saprouter_is_running() {
# 0 - True
# 1 - False
if ps ax | grep -v grep | grep ${saprouter_directory}/${name} > /dev/null
then
return 0
else
return 1
fi
}
run_rc_command "$1"