1 |
ssuominen 09/07/30 10:10:12 |
2 |
|
3 |
Added: hamachi.initd.2 |
4 |
Log: |
5 |
Make init script POSIX wrt #279058, thanks to Michał Górny. |
6 |
(Portage version: 2.2_rc33/cvs/Linux x86_64) |
7 |
|
8 |
Revision Changes Path |
9 |
1.1 net-misc/hamachi/files/hamachi.initd.2 |
10 |
|
11 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-misc/hamachi/files/hamachi.initd.2?rev=1.1&view=markup |
12 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-misc/hamachi/files/hamachi.initd.2?rev=1.1&content-type=text/plain |
13 |
|
14 |
Index: hamachi.initd.2 |
15 |
=================================================================== |
16 |
#!/sbin/runscript |
17 |
# Copyright 1999-2005 Gentoo Foundation |
18 |
# Distributed under the terms of the GNU General Public License v2 |
19 |
|
20 |
opts="start stop status init" |
21 |
|
22 |
depend() { |
23 |
need net tuncfg |
24 |
} |
25 |
|
26 |
start() { |
27 |
check_config |
28 |
ebegin "Starting hamachi" |
29 |
|
30 |
start-stop-daemon --quiet --start -c "${USER}" \ |
31 |
--exec /usr/bin/hamachi -- \ |
32 |
-c "${CONFDIR}" start 2>&1 >"${LOG}" |
33 |
result=$? |
34 |
|
35 |
if [ ${result} -eq 0 ]; then |
36 |
chown "${USER}:${GROUP}" "${CONFDIR}"/ipc_sock |
37 |
chmod g+rwx "${CONFDIR}"/ipc_sock |
38 |
|
39 |
/usr/bin/hamachi -c "${CONFDIR}" login |
40 |
if [ -z "$(/usr/bin/hamachi -c "${CONFDIR}" | grep 'logged in')" ]; then |
41 |
result=1 |
42 |
/usr/bin/hamachi -c "${CONFDIR}" stop 2>&1 >"${LOG}" |
43 |
fi |
44 |
fi |
45 |
|
46 |
eend ${result} |
47 |
} |
48 |
|
49 |
stop() { |
50 |
ebegin "Stopping hamachi" |
51 |
|
52 |
/usr/bin/hamachi -c "${CONFDIR}" logout 2>&1 >"${LOG}" |
53 |
/usr/bin/hamachi -c "${CONFDIR}" stop 2>&1 >"${LOG}" |
54 |
|
55 |
eend $? |
56 |
} |
57 |
|
58 |
init() { |
59 |
ebegin "Making initial configuration" |
60 |
|
61 |
/usr/bin/hamachi-init -c "${CONFDIR}" 2>&1 >/dev/null |
62 |
result=$? |
63 |
chown -R "${USER}:${GROUP}" "${CONFDIR}" |
64 |
chmod g+rx "${CONFDIR}" |
65 |
|
66 |
eend ${result} |
67 |
} |
68 |
|
69 |
check_config() { |
70 |
if [ ! -d "${CONFDIR}" ]; then |
71 |
einfo "It seems you don't have configured hamachi yet. Running init now" |
72 |
init |
73 |
fi |
74 |
} |
75 |
|
76 |
status() { |
77 |
service_started "${SVCNAME}" || return 1 |
78 |
/usr/bin/hamachi -c "${CONFDIR}" |
79 |
/usr/bin/hamachi -c "${CONFDIR}" list |
80 |
} |