aboutsummaryrefslogtreecommitdiffstats
path: root/sysutils/cdrtools/pkg-install.rscsi
blob: fe91941c71ae34307ff3628e9d2dc4c3612844aa (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
#!/bin/sh

PATH=/bin:/usr/sbin:/usr/bin

PKG_PREFIX=${PKG_PREFIX:=/usr/local}

case $2 in
    PRE-INSTALL)
        ;;

    POST-INSTALL)
        USER=rscsi
        UID=99
        GROUP=${USER}
        GID=${UID}
        UCOMMENT="Remote SCSI"
        UHOME=${PKG_PREFIX}/rscsi
        USHELL=${PKG_PREFIX}/sbin/rscsi

        echo "==========================================================================="
        echo

        if ! pw groupshow "${GROUP}" >/dev/null 2>&1; then
            if ! pw groupadd ${GROUP} -g ${GID}; then
                echo "Adding group \"${GROUP}\" failed."
                exit 1
            fi
        fi

        if ! pw usershow "${USER}" >/dev/null 2>&1; then
            if ! pw useradd ${USER} -u ${UID} -c "${UCOMMENT}" \
                -d ${UHOME} -g ${GROUP} -s ${USHELL}; then
                echo "Adding user \"${USER}\" failed."
                exit 1
            fi
        fi

        if ! [ -d ${UHOME} ] ; then 
            mkdir -p ${UHOME}
            chown ${UID}:${GID} ${UHOME}
        fi

        if ! [ -f ${UHOME}/.rhosts ] ; then
            cp /usr/share/skel/dot.rhosts ${UHOME}/.rhosts
            chown ${UID}:${GID} ${UHOME}/.rhosts
            chmod 0600 ${UHOME}/.rhosts
        fi

        echo "See ${PKG_PREFIX}/share/doc/cdrtools/README.rscsi and ${PKG_PREFIX}/etc/rscsi"
        echo "for further information on how to configure remote access to SCSI-devices"
        echo "via rscsi."

        if ! grep '^shell' /etc/inetd.conf >/dev/null 2>&1; then
            echo "Don't forget to add an entry for rshd(8) to /etc/inetd.conf in order to"
            echo "be able to use the remote SCSI daemon."
        fi

        echo

        ;;
esac