#!/sbin/runscript # Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 opts="start stop status init" depend() { need net tuncfg } start() { check_config ebegin "Starting hamachi" start-stop-daemon --quiet --start -c "${USER}" \ --exec /usr/bin/hamachi -- \ -c "${CONFDIR}" start 2>&1 >"${LOG}" result=$? if [ ${result} -eq 0 ]; then chown "${USER}:${GROUP}" "${CONFDIR}"/ipc_sock chmod g+rwx "${CONFDIR}"/ipc_sock /usr/bin/hamachi -c "${CONFDIR}" login if [ -z "$(/usr/bin/hamachi -c "${CONFDIR}" | grep 'logged in')" ]; then result=1 /usr/bin/hamachi -c "${CONFDIR}" stop 2>&1 >"${LOG}" fi fi eend ${result} } stop() { ebegin "Stopping hamachi" /usr/bin/hamachi -c "${CONFDIR}" logout 2>&1 >"${LOG}" /usr/bin/hamachi -c "${CONFDIR}" stop 2>&1 >"${LOG}" eend $? } init() { ebegin "Making initial configuration" /usr/bin/hamachi-init -c "${CONFDIR}" 2>&1 >/dev/null result=$? chown -R "${USER}:${GROUP}" "${CONFDIR}" chmod g+rx "${CONFDIR}" eend ${result} } check_config() { if [ ! -d "${CONFDIR}" ]; then einfo "It seems you don't have configured hamachi yet. Running init now" init fi } status() { service_started "${SVCNAME}" || return 1 /usr/bin/hamachi -c "${CONFDIR}" /usr/bin/hamachi -c "${CONFDIR}" list }