Annotation of buildman/install, revision 1.11

1.1       snw         1: #!/bin/sh
                      2: 
                      3: # SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC
                      4: # SPDX-FileCopyrightText: (C) 2025 Serena Willis
                      5: #
                      6: # SPDX-License-Identifier: AGPL-3.0
                      7: 
                      8: #
                      9: # BuildMan 0.0.1
                     10: #  Distributed CI/CD system with portability to older UNIX systems
                     11: #
                     12: #  install - buildman installer
                     13: #
                     14: # Copyright (C) 2025 Coherent Logic Development LLC
                     15: #
                     16: # Author: Serena Willis <snw@coherent-logic.com>
                     17: #
                     18: 
                     19: PROGN=`basename $0`
                     20: 
1.7       snw        21: #if [ "$UID" != "0" ]
                     22: #then
                     23: #    echo "$PROGN error:  must run as root"
                     24: #    exit 1
                     25: #fi
1.1       snw        26: 
                     27: TARGET="client"
                     28: TUSER="build:6000"
                     29: TGROUP="build:6000"
                     30: BUILDMAN_MASTER=""
1.11    ! snw        31: INSTALL_BASE="/usr/local"
1.1       snw        32: 
1.2       snw        33: OS=`uname`
                     34: 
                     35: if [ "$OS" = "SCO_SV" ] ; then
                     36:     THOST=`hostname -s`
                     37:     PATH=/usr/gnu/bin:$PATH
                     38:     export PATH
                     39: else
                     40:     if [ "$OS" = "SunOS" ] ; then
                     41:         THOST=`hostname`
                     42:     else    
                     43:         THOST=`hostname -s`
                     44:     fi
                     45: fi
                     46: 
                     47: tmphost=`echo ${THOST} | cut -d. -f1`
                     48: THOST="${tmphost}"
                     49: 
1.4       snw        50: if [ "$OS" = "SunOS" ]
1.2       snw        51: then
                     52:     BUILDMAN_BASE="/export/home/build"
                     53: else    
                     54:     BUILDMAN_BASE="/home/build"
                     55: fi
                     56: 
1.10      snw        57: while getopts ':t:u:g:b:m:i:h' OPTION
1.1       snw        58: do
                     59:     case $OPTION in
1.2       snw        60: 
                     61:         i)
                     62:             INSTALL_BASE="${OPTARG}"
                     63:             ;;
                     64:         
                     65:         u)
                     66:             TUSER="${OPTARG}"
                     67:             ;;
                     68: 
                     69:         g)
                     70:             TGROUP="${OPTARG}"
                     71:             ;;
1.1       snw        72:         
1.2       snw        73:         b)
                     74:             BUILDMAN_BASE="${OPTARG}"
                     75:             ;;
                     76: 
                     77:         m)
                     78:             BUILDMAN_MASTER="${OPTARG}"
1.5       snw        79:             ;;
1.10      snw        80: 
                     81:         h)
                     82:             echo ""
                     83:             echo "BuildMan Installer"
                     84:             echo " Copyright (C) 2025 Coherent Logic Development LLC"
                     85:             echo ""
                     86:             echo ""
                     87:             echo "usage:  ${PROGN} [-i <install-base>] [-b <buildman-base>] [-u <buildman-username:buildman-uid>] [-g <buildman-groupname:buildman-gid> ] [-m <buildman-master>"
                     88:             echo "  <install-base> is the directory in which buildman will be installed"
                     89:             echo "  <buildman-base> is the directory in which buildman will operate"
                     90:             echo "  <buildman-username> is the username owning the files for buildman"
                     91:             echo "  <buildman-uid> is the numeric UID of the owner of the buildman files"
                     92:             echo "  <buildman-groupname> is the group name owning the files for buildman"
                     93:             echo "  <buildman-gid> is the numeric GID of the group owning the buildman files"
                     94:             echo "  <buildman-master> is the primary buildman host, supplied as IP address or FQDN"
1.11    ! snw        95:             echo ""
1.10      snw        96:             exit 0
                     97:             ;;
1.1       snw        98:     esac
                     99: done
1.2       snw       100: 
                    101: T_LOGIN=`echo ${TUSER} | cut -d: -f1`
                    102: T_UID=`echo ${TUSER} | cut -d: -f2`
                    103: T_GRPNAM=`echo ${TGROUP} | cut -d: -f1`
                    104: T_GID=`echo ${TGROUP} | cut -d: -f2`
                    105: 
1.11    ! snw       106: BIN_BASE="${INSTALL_BASE}/bin"
        !           107: 
        !           108: if [ ! -d "${BIN_BASE}" ]
        !           109: then
        !           110:     mkdir -p "${BIN_BASE}"
        !           111: fi
1.2       snw       112: 
                    113: groupadd -g ${T_GID} ${T_GRPNAM}
                    114: useradd -u ${T_UID} -g ${T_GRPNAM} -c "BuildMan" -m -d "${BUILDMAN_BASE}" "${T_LOGIN}"
                    115: 
1.11    ! snw       116: install -o ${T_UID} -g ${T_GID} -m 750 bm "${BIN_BASE}/bm"
        !           117: install -o ${T_UID} -g ${T_GID} -m 750 bma "${BIN_BASE}/bma"
1.2       snw       118: 
                    119: DEF="/etc/default/bm"
                    120: 
1.3       snw       121: 
1.2       snw       122: echo "BUILDMAN_BASE=${BUILDMAN_BASE}" > "${DEF}"
1.9       snw       123: echo "BUILDMAN_USER=${T_LOGIN}" >> "${DEF}"
                    124: echo "BUILDMAN_GROUP=${T_GRPNAM}" >> "${DEF}"
1.2       snw       125: echo "BUILDMAN_UID=${T_UID}" >> "${DEF}"
                    126: echo "BUILDMAN_GID=${T_GID}" >> "${DEF}"
                    127: echo "BUILDMAN_MASTER=${BUILDMAN_MASTER}" >> "${DEF}"
                    128: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>