source: src-sh/warden/scripts/backend/setupusers.sh @ 0988d23

9.1-release9.2-releasereleng/10.0releng/10.0.1
Last change on this file since 0988d23 was 0988d23, checked in by Kris Moore <kris@…>, 12 months ago

Add my working directory for the new warden backend changes.

Includes patches from John Hixson (john@…) to change
how warden uses "nicknames" instead of IP addresses for jail
identification.

  • Property mode set to 100755
File size: 1.3 KB
Line 
1#!/bin/sh
2# Script to setup the initial rootpw on a jail
3# Args $1 = JAILDIR
4# Args $2 = rootPW
5######################################################################
6
7# Source our functions
8PROGDIR="/usr/local/share/warden"
9
10# Source our variables
11. ${PROGDIR}/scripts/backend/functions.sh
12
13JAILNAME="$1"
14ROOTPW="${2}"
15
16export ROOTPW
17
18if [ -z "${JAILNAME}" ]
19then
20  echo "ERROR: You must specify a jail"
21  exit 5
22fi
23
24if [ -z "${JDIR}" ]
25then
26  echo "ERROR: JDIR is unset!!!!"
27  exit 5
28fi
29
30JAILDIR="${JDIR}/${JAILNAME}"
31
32if [ ! -d "${JAILDIR}" ]
33then
34  echo "ERROR: No jail located at ${JAILDIR}"
35  exit 5
36fi
37
38if [ -z "${ROOTPW}" ]
39then
40  echo "ERROR: Missing root pw!"
41  exit 5
42fi
43
44set_warden_metadir
45
46
47# End of error checking, now lets add the users / passwords
48#####################################################################
49
50echo -e "Changing root password on: ${IP} \c"
51
52if [ -e "${JMETADIR}/jail-linux" ] ; then
53
54  echo '#!/bin/bash
55echo -e "${ROOTPW}\n${ROOTPW}" | passwd root
56' > "${JAILDIR}/.chpass.sh"
57
58else
59
60  echo '#!/bin/sh
61echo "${ROOTPW}" | pw usermod root -h 0
62' > "${JAILDIR}/.chpass.sh"
63
64fi
65
66chmod 755 "${JAILDIR}/.chpass.sh"
67chroot "${JAILDIR}" /.chpass.sh
68if [ $? -eq 0 ] ; then
69  echo -e "Success!"
70else
71  echo -e "FAILED!"
72fi
73
74rm "${JAILDIR}/.chpass.sh"
75
76
77unset ROOTPW
Note: See TracBrowser for help on using the repository browser.