Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
60 lines (44 sloc) 2.09 KB
#!/bin/bash -e
env | grep -q "APP_USER=" || echo "Please set APP_USER environment variable"
echo "app user at the beginning: $APP_USER"
# perl -e 'print crypt("password", "salt"),"\n"'
getent passwd $APP_USER >/dev/null 2>&1 || useradd $APP_USER -p passwordhashgoeshere # sa3tHJ3/KuYvI would set the password to "password"
# copy root's authorized keys to APP_USER
mkdir -p /home/$APP_USER/.ssh
touch /home/$APP_USER/.ssh/authorized_keys
chmod 700 /home/$APP_USER/.ssh
chmod 600 /home/$APP_USER/.ssh/authorized_keys
chown -R $APP_USER /home/$APP_USER/.ssh
authorized_keys_string=`cat /root/.ssh/authorized_keys`
grep -sq "$authorized_keys_string" /home/$APP_USER/.ssh/authorized_keys || cat /root/.ssh/authorized_keys >> /home/$APP_USER/.ssh/authorized_keys
## enable ssh password auth
perl -p -i -e 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
/etc/init.d/sshd reload
# install epel
rpm -q epel-release-5-4.noarch || rpm -Uvh
# install git
yum -y install git
# rvm prereqs
yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libffi-devel openssl-devel iconv-devel java
# passwordless sudo
sudo_string='ALL ALL = (ALL) NOPASSWD: ALL'
grep "$sudo_string" /etc/sudoers || echo "$sudo_string" >> /etc/sudoers
cat <<'BOOTSTRAP_AS_USER' > /home/$APP_USER/
set -e
export APP_USER=$1
cd ~
mkdir -p /home/$APP_USER/rvm/src
curl -Lskf | tar xvz -C/home/$APP_USER/rvm/src --strip 1
cd "/home/$APP_USER/rvm/src" && ./install
rvm_include_string='[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"'
grep "$rvm_include_string" ~/.bashrc || echo "$rvm_include_string" >> ~/.bashrc
cat <<'RVMRC_CONTENTS' > ~/.rvmrc
chmod a+x /home/$APP_USER/
echo "finished"
rm /home/$APP_USER/
Jump to Line
Something went wrong with that request. Please try again.