Sha256: 80c57214b26b6882f4ceef8fc79c3677f217d8850f235dc56e6cc39af9291540

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

#!/bin/sh

. /rebuild/re-build-bootstrap-utils

DEBUG_OUTPUT=/dev/null

rebuild_banner()
{
  BEST_ECHO=`which echo 2>/dev/null`
  if test -z $BEST_ECHO; then
    BEST_ECHO=echo
  fi

  $BEST_ECHO -e "\e[1;92m$1\e[0m"
}

setup_users()
{
  delete_user $REBUILD_USER_NAME
  delete_group $REBUILD_USER_NAME
  delete_group $REBUILD_GROUP_NAME

  if has_app useradd; then

    groupadd -o -g $REBUILD_GROUP_ID $REBUILD_GROUP_NAME

    useradd -o -M                          \
            -g $REBUILD_GROUP_ID           \
            -u $REBUILD_USER_ID            \
            --home-dir $REBUILD_USER_HOME  \
            $REBUILD_USER_NAME

  else

    echo "$REBUILD_GROUP_NAME:x:$REBUILD_GROUP_ID:" >> /etc/group
    echo "$REBUILD_USER_NAME:x:$REBUILD_USER_ID:$REBUILD_GROUP_ID:Linux User,,,:$REBUILD_USER_HOME:" >> /etc/passwd

  fi
}

rebuild_shell()
{
  if test -f /bin/bash; then
    echo /bin/bash
  else
    echo /bin/sh
  fi
}

sudo_params()
{
  echo "-n -H -E -g $REBUILD_GROUP_NAME -u $REBUILD_USER_NAME"
}

setup_users 2>$DEBUG_OUTPUT

cd $REBUILD_PWD

. /rebuild/rebuild.rc

if test -n "$*"; then
    rebuild_banner ">>> rebuild env $HOSTNAME"
    rebuild_banner ">>> $*"
    sudo `sudo_params` `rebuild_shell` -c "$*"
else
    rebuild_banner ">>> rebuild env $HOSTNAME interactive"
    rebuild_banner ">>> Press CTRL-D do leave"
    sudo `sudo_params` `rebuild_shell`
fi

RC=$?

rebuild_banner "<<< rebuild env $HOSTNAME"

exit $RC

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rbld-1.0.0 cli/lib/bootstrap/re-build-entry-point