#!/bin/sh
# SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC
# SPDX-FileCopyrightText: (C) 2025 Serena Willis
#
# SPDX-License-Identifier: AGPL-3.0
#
# BuildMan 0.0.1
# Distributed CI/CD system with portability to older UNIX systems
#
# install - buildman installer
#
# Copyright (C) 2025 Coherent Logic Development LLC
#
# Author: Serena Willis <snw@coherent-logic.com>
#
PROGN=`basename $0`
#if [ "$UID" != "0" ]
#then
# echo "$PROGN error: must run as root"
# exit 1
#fi
TARGET="client"
TUSER="build:6000"
TGROUP="build:6000"
BUILDMAN_MASTER=""
INSTALL_BASE="/usr/local"
OS=`uname`
if [ "$OS" = "SCO_SV" ] ; then
THOST=`hostname -s`
PATH=/usr/gnu/bin:$PATH
export PATH
else
if [ "$OS" = "SunOS" ] ; then
THOST=`hostname`
else
THOST=`hostname -s`
fi
fi
tmphost=`echo ${THOST} | cut -d. -f1`
THOST="${tmphost}"
if [ "$OS" = "SunOS" ]
then
BUILDMAN_BASE="/export/home/build"
else
BUILDMAN_BASE="/home/build"
fi
while getopts ':t:u:g:b:m:i:' OPTION
do
case $OPTION in
i)
INSTALL_BASE="${OPTARG}"
;;
u)
TUSER="${OPTARG}"
;;
g)
TGROUP="${OPTARG}"
;;
b)
BUILDMAN_BASE="${OPTARG}"
;;
m)
BUILDMAN_MASTER="${OPTARG}"
;;
esac
done
T_LOGIN=`echo ${TUSER} | cut -d: -f1`
T_UID=`echo ${TUSER} | cut -d: -f2`
T_GRPNAM=`echo ${TGROUP} | cut -d: -f1`
T_GID=`echo ${TGROUP} | cut -d: -f2`
groupadd -g ${T_GID} ${T_GRPNAM}
useradd -u ${T_UID} -g ${T_GRPNAM} -c "BuildMan" -m -d "${BUILDMAN_BASE}" "${T_LOGIN}"
install -o ${T_UID} -g ${T_GID} -m 750 bm "${INSTALL_BASE}/sbin/bm"
install -o ${T_UID} -g ${T_GID} -m 750 bma "${INSTALL_BASE}/sbin/bma"
DEF="/etc/default/bm"
echo "BUILDMAN_BASE=${BUILDMAN_BASE}" > "${DEF}"
echo "BUILDMAN_UID=${T_UID}" >> "${DEF}"
echo "BUILDMAN_GID=${T_GID}" >> "${DEF}"
echo "BUILDMAN_MASTER=${BUILDMAN_MASTER}" >> "${DEF}"
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>