29 lines
1.6 KiB
Bash
29 lines
1.6 KiB
Bash
#!/usr/bin/bash
|
|
org_user="$1"
|
|
current_user="$2"
|
|
if [[ ! -z "$org_user" ]] && [[ ! -z "$current_user" ]] && [[ "$current_user" != "$org_user" ]]; then
|
|
sed -i "s/\/home\/$org_user\//\/home\/$current_user\//g" /etc/logrotate.d/orbit
|
|
sed -i "s/\/home\/$org_user\t/\/home\/$current_user\t/g" /etc/rsnapshot.conf
|
|
sed -i "s/\/home\/$org_user\//\/home\/$current_user\//g" /etc/nginx/orbit_sites/orbit
|
|
sed -i "s/ORBIT_USER=.*/ORBIT_USER=$current_user/g" /etc/init.d/orbit
|
|
service nginx restart
|
|
if [[ ! -d /home/$current_user/.rvm/ ]] && [[ -d /home/$org_user/.rvm/ ]]; then
|
|
mv /home/$org_user/.rvm* /home/$current_user/.;
|
|
chown $current_user:$current_user /home/$current_user/.rvm* -R
|
|
fi
|
|
if [[ ! -d /home/$current_user/.gem/ ]] && [[ -d /home/$org_user/.gem/ ]]; then
|
|
mv /home/$org_user/.gem /home/$current_user/.;
|
|
chown $current_user:$current_user /home/$current_user/.gem -R
|
|
fi
|
|
sudo usermod -a -G rvm $current_user
|
|
find /home/$current_user/.rvm/ -type f -xtype f -exec sed "s/\/home\/$org_user\/.rvm/\/home\/$current_user\/.rvm/g" -i {} \;
|
|
if [[ ! -e "/home/$current_user/.bashrc" ]] || [[ -z "$(grep 'source "/etc/profile.d/rvm.sh"' "/home/$current_user/.bashrc")" ]]; then
|
|
echo 'source "/etc/profile.d/rvm.sh"' >> "/home/$current_user/.bashrc";
|
|
fi
|
|
if [[ -d /home/$current_user/.rvm/ ]]; then
|
|
ruby_ver=`ls /home/$current_user/.rvm/environments/ruby* |cut -d '/' -f6|cut -d '@' -f1|cut -d '-' -f2|sort -u -r|xargs|awk '{print $1}'`
|
|
su -l $current_user -c "source '/etc/profile.d/rvm.sh' && rvm use $ruby_ver --default && rvm user gemsets && gem pristine --all"
|
|
service orbit restart
|
|
fi
|
|
systemctl daemon-reload
|
|
fi |