summaryrefslogtreecommitdiff
path: root/misc/setiathome/files
diff options
context:
space:
mode:
authorjmmv <jmmv@pkgsrc.org>2003-04-09 15:52:28 +0000
committerjmmv <jmmv@pkgsrc.org>2003-04-09 15:52:28 +0000
commit01da2b5f391ca649482d793da2ff622bd6115e92 (patch)
tree90eb716a57904b8478b35d243662b4f6d0f25938 /misc/setiathome/files
parentae7bd83c80dd486f1b39c142484b577319180d52 (diff)
downloadpkgsrc-01da2b5f391ca649482d793da2ff622bd6115e92.tar.gz
Add a rc.d script to run this program at bootup as an unprivileged user.
Bump PKGREVISION to 1. Closes my own PR pkg/18361.
Diffstat (limited to 'misc/setiathome/files')
-rw-r--r--misc/setiathome/files/setiathome.sh52
1 files changed, 52 insertions, 0 deletions
diff --git a/misc/setiathome/files/setiathome.sh b/misc/setiathome/files/setiathome.sh
new file mode 100644
index 00000000000..937a973fe5e
--- /dev/null
+++ b/misc/setiathome/files/setiathome.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+#
+# $NetBSD: setiathome.sh,v 1.1 2003/04/09 15:52:29 jmmv Exp $
+#
+
+# PROVIDE: setiathome
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+
+. /etc/rc.subr
+
+sah_user="nobody"
+sah_group="nobody"
+sah_homedir="/var/db/setiathome"
+
+name="setiathome"
+rcvar=$name
+command="/usr/pkg/bin/${name}"
+pidfile="${sah_homedir}/pid.sah"
+extra_commands="config"
+
+setiathome_config() {
+ if [ ! -d ${sah_homedir} ]; then
+ mkdir ${sah_homedir}
+ chmod 755 ${sah_homedir}
+ chown ${sah_user}:${sah_group} ${sah_homedir}
+ fi
+
+ su -fm ${sah_user} -c "cd ${sah_homedir} && exec ${command} -login"
+ return 0
+}
+
+setiathome_start() {
+ if [ ! -f ${sah_homedir}/key.sah ]; then
+ run_rc_command config
+ fi
+
+ echo "Starting ${name}."
+ su -fm ${sah_user} -c "cd ${sah_homedir} && exec ${command} \
+ ${command_args} &" 2>/dev/null 1>/dev/null
+}
+
+setiathome_poststop() {
+ rm -f ${sah_homedir}/pid.sah
+}
+
+config_cmd=setiathome_config
+start_cmd=setiathome_start
+stop_postcmd=setiathome_poststop
+
+load_rc_config $name
+run_rc_command "$1"