Sha256: ff6576672a03bba9c37d050928f10f993bbb9af699e7add82e4153a23e7c032e

Contents?: true

Size: 1.52 KB

Versions: 10

Compression:

Stored size: 1.52 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 2>$DEBUG_OUTPUT
  delete_group $REBUILD_USER_NAME 2>$DEBUG_OUTPUT
  delete_group $REBUILD_GROUP_NAME 2>$DEBUG_OUTPUT

  if has_app useradd; then

    groupadd -o -g $REBUILD_GROUP_ID $REBUILD_GROUP_NAME 2>$DEBUG_TRACE

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

  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

cd $REBUILD_PWD 2>/dev/null

. /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=$?

if test -z "$*"; then
rebuild_banner ""
fi

rebuild_banner "<<< rebuild env $HOSTNAME"

exit $RC

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rbld-1.3.8 cli/lib/bootstrap/re-build-entry-point
rbld-1.3.7 cli/lib/bootstrap/re-build-entry-point
rbld-1.3.6 cli/lib/bootstrap/re-build-entry-point
rbld-1.3.5 cli/lib/bootstrap/re-build-entry-point
rbld-1.3.4 cli/lib/bootstrap/re-build-entry-point
rbld-1.3.3 cli/lib/bootstrap/re-build-entry-point
rbld-1.3.2 cli/lib/bootstrap/re-build-entry-point
rbld-1.3.1 cli/lib/bootstrap/re-build-entry-point
rbld-1.3.0 cli/lib/bootstrap/re-build-entry-point
rbld-1.2.0 cli/lib/bootstrap/re-build-entry-point