summaryrefslogtreecommitdiff
path: root/net/freenx/files/patch-freenx-nxsetup
blob: b102358a62446ec18d36faa1b02b338d9d471397 (plain) (blame)
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
--- nxsetup.unported	Mon Jan 22 19:22:50 2007
+++ nxsetup
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/local/bin/bash
 
 # Coypright (c) 2004-2005 by Fabian Franz <freenx@fabian-franz.de>.
 #                    2005 by Jon Severinsson <jonno@users.berlios.de>.
@@ -165,7 +165,16 @@
 		# adduser needs a valid group to add the user to
 		! nx_group_exists && addgroup --system --quiet $GROUPADD_OPTIONS nx
 		adduser $USERADD_OPTIONS nx
-		
+
+	# FreeBSD?
+	elif [ "$(uname)" = "FreeBSD" ]
+	then
+		USERADD_OPTIONS="-d $NX_HOME_DIR -s $PATH_BIN/nxserver"
+		[ -n "$SETUP_UID" ] && USERADD_OPTIONS="-u $SETUP_UID $USERADD_OPTIONS"
+		[ -n "$SETUP_GID" ] && USERADD_OPTIONS="-g $SETUP_GID $USERADD_OPTIONS"
+		[ -n "$SETUP_GID" ] && pw groupadd nx -g $SETUP_GID
+		pw useradd nx $USERADD_OPTIONS
+
 	# no, its a "normal" useradd
 	else
 		USERADD_OPTIONS="-g nx -d $NX_HOME_DIR -s $PATH_BIN/nxserver"
@@ -198,15 +207,16 @@
 install_nx()
 {
 	set -e
-	
-	if [ "$(pidof sshd 2>/dev/null)" = "" ]
+
+	[ -f /var/run/sshd.pid ] && MAYBE_PID=`cat /var/run/sshd.pid 2>/dev/null`
+	if test -z "$MAYBE_PID"
+
 	then 
 		echo -n "Starting ssh service ..."
 		# Generate Host keys if they are not available, yet
 		[ -e /etc/ssh/ssh_host_rsa_key ] || $COMMAND_SSH_KEYGEN -q -t rsa -f /etc/ssh/ssh_host_rsa_key -C '' -N ''
 		[ -e /etc/ssh/ssh_host_dsa_key ] || $COMMAND_SSH_KEYGEN -q -t dsa -f /etc/ssh/ssh_host_dsa_key -C '' -N ''
-		[ -x /etc/init.d/sshd ] && /etc/init.d/sshd start
-		[ -x /etc/init.d/ssh ] && /etc/init.d/ssh start
+		[ -x /etc/rc.d/sshd ] && /etc/rc.d/sshd forcestart
 		echo "done"
 	fi
 	
@@ -319,13 +329,12 @@
 		cat /etc/ssh/ssh_host_rsa_key.pub >> $NX_HOME_DIR/.ssh/known_hosts
 	fi
 	
-	echo "done"
-	
 	echo -n "Setting up permissions ..."
-	chown -R nx:root $NX_SESS_DIR
-	chown -R nx:root $NX_ETC_DIR
-	chown -R nx:root $NX_HOME_DIR
-	chown nx:root "$NX_LOGFILE"
+	chown -R nx:nx $NX_SESS_DIR
+	chown -R nx:nx $NX_ETC_DIR
+	chown -R nx:nx $NX_HOME_DIR
+	chown nx:nx "$NX_LOGFILE"
+	chmod 0400 $NX_HOME_DIR/.ssh/$SSH_AUTHORIZED_KEYS
 	echo "done"
 }
 
@@ -389,7 +398,7 @@
 		then
 			luserdel nx
 		else
-			userdel nx
+			pw userdel nx
 		fi
 			
 		echo "done"