Proposal: add setup_user option or script

Issue #51 new
Jesse G created an issue

I'm proposing an option to chroot_setup (or perhaps a separate script) that would prepare a chroot for a particular user by performing the following steps (written in pseudoscript, with $USER being the given user):

mkdir -p $CHROOT_DIR/home/$USER
chown -R $USER  $CHROOT_DIR/home/$USER
system -kpieb "CHGUSRPRF USRPRF($USER) HOMEDIR('$CHROOT_DIR/./home/$USER')
cp ~/.profile $CHROOT_DIR/home/$USER
cp ~/.bash_profile $CHROOT_DIR/home/$USER

Assigning to Aaron for vote

Comments (1)

  1. Aaron Bartell

    Here's a sample of what I've been using. Does a number of defaults. It is done from a .lst file. I am split on whether to continue using .lst for custom stuff like this or to switch to doing .sh files.

    Obviously this would require global variables to be passed. (i.e. chroot_setup -g myuser=AARON -g mydir=/QOpenSys/mychroot1 /QOpenSys/mychroot1 /path/to/add_user.lst).

    Another feature I think we should add is to alter the prompt (via PS1 alteration, seen below) to denote whether you're in a chroot or not. Currently I only display the user, machine and current directory.

    :mkdir
    /home/myuser/.ssh
    /QOpenSys/etc/ssh
    
    :sh
    ssh-keygen -q -N '' -C '' -f mydir/home/myuser/.ssh/id_rsa
    touch mydir/home/myuser/.ssh/authorized_keys
    touch mydir/home/myuser/.ssh/known_hosts
    printf "Host *\nIdentityFile /home/myuser/.ssh/id_rsa\nUserKnownHostsFile /home/myuser/.ssh/known_hosts\n\n" > mydir/QOpenSys/etc/ssh/ssh_config
    
    echo "TERM=xterm" >> mydir/home/myuser/.profile
    echo "umask go=" >> mydir/home/myuser/.profile
    echo 'export PATH=/QOpenSys/pkgs/bin:$PATH' >> mydir/home/myuser/.profile
    
    echo "alias ls='ls -F --color=auto'" >> mydir/home/myuser/.bashrc
    echo 'export PS1="\n\[\e[0;32m\]\342\224\214\342\224\200[\[\e[0m\]\[\e[1;33m\]\u\[\e[0m\]\[\e[1;32m\] @ \[\e[0m\]\[\e[1;33m\]\h\[\e[0m\]\[\e[0;32m\]]\342\224\200[\[\e[0m\]\[\e[1;34m\]\w\[\e[0m\]\[\e[0;32m\]]\[\e[0m\]\n\[\e[0;32m\]\342\224\224\342\224\200[\[\e[0m\]\[\e[1;37m\]\$\[\e[0m\]\[\e[0;32m\]]\342\200\272 \[\e[0m\]"' >> ~/.bashrc
    
    echo "source ~/.profile" >> mydir/home/myuser/.bash_profile
    echo "source ~/.bashrc" >> mydir/home/myuser/.bash_profile
    
    echo "[core]" >> mydir/home/myuser/.gitconfig
    echo "  pager = " >> mydir/home/myuser/.gitconfig
    
    :chmod
    750 /home
    750 /home/myuser
    700 /home/myuser/.ssh
    600 /home/myuser/.ssh/id_rsa
    644 /home/myuser/.ssh/id_rsa.pub
    644 /home/myuser/.ssh/authorized_keys
    700 /home/myuser/.ssh/known_hosts
    1777 /tmp
    
  2. Log in to comment