3 # Richard Kettlewell 2011-06-18
5 # This file is part of secnet.
6 # See README for full list of copyright holders.
8 # secnet is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # secnet is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # version 3 along with secnet; if not, see
20 # https://www.gnu.org/licenses/gpl.html.
24 group
=${group:-secnet}
27 # pick ID1 ID2 ... IDn
28 # Echoes an ID matching none of ID1..IDn
31 n
=250 # better not choose 0!
48 if dscl .
-read /Groups
/$group >/dev
/null
2>&1; then
51 gids
=$
(dscl .
-list
/Groups PrimaryGroupID|
awk '{print $2}')
53 dscl .
-create
/Groups
/$group
54 dscl .
-create
/Groups
/$group PrimaryGroupID
$gid
55 dscl .
-create
/Groups
/$group Password \
*
58 if dscl .
-read /Users
/$user >/dev
/null
2>&1; then
61 uids
=$
(dscl .
-list
/Users UniqueID|
awk '{print $2}')
63 gid
=$
(dscl .
-read /Groups
/$group PrimaryGroupID |
awk '{print $2}')
64 dscl .
-create
/Users
/$user
65 dscl .
-create
/Users
/$user UniqueID
$uid
66 dscl .
-create
/Users
/$user UserShell
/usr
/bin
/false
67 dscl .
-create
/Users
/$user RealName
'secnet'
68 dscl .
-create
/Users
/$user NFSHomeDirectory
/var
/empty
69 dscl .
-create
/Users
/$user PrimaryGroupID
$gid
70 dscl .
-create
/Users
/$user Password \
*
73 cp uk.org.greenend.secnet.plist
/Library
/LaunchDaemons
/.
74 launchctl load
/Library
/LaunchDaemons
75 echo "To start secnet:"
76 echo " sudo launchctl start uk.org.greenend.secnet"
78 echo "To stop secnet:"
79 echo " sudo launchctl stop uk.org.greenend.secnet"
82 echo " sudo launchctl unload /Library/LaunchDaemons/uk.org.greenend.secnet.plist"
83 echo " sudo rm -f /Library/LaunchDaemons/uk.org.greenend.secnet.plist"