Skip to content

Instantly share code, notes, and snippets.

@kcho
Created August 5, 2016 04:56
Show Gist options
  • Save kcho/0bccfc5bf66c4d3ffc5881faa7ec553d to your computer and use it in GitHub Desktop.
Save kcho/0bccfc5bf66c4d3ffc5881faa7ec553d to your computer and use it in GitHub Desktop.
# Server
# BI server address
server=
id_at_server=
# Create id and append it to the BI server's authorized host list
ssh-keygen -t rsa
cat /root/.ssh/id_rsa.pub | ssh ${id_at_server}@${server} 'cat >> .ssh/authorized_keys'
#host checking
echo "Host *" >> /root/.ssh/config
echo " StrictHostKeyChecking no" /root/.ssh/config
chmod 400 /root/.ssh/config
chmod 400 /root/.ssh/id_rsa.pub
# Groups
# Name of the groups
admingroup="ccnc"
adminpassword=
workshopgroup="workshop"
workshoppassword=
# Make groups
sudo addgroup ${admingroup}
sudo addgroup ${workshopgroup}
# apt-get
# update and upgrade
sudo apt-get update -y
sudo apt-get upgrade -y
# Neurodebian install
wget -O- http://neuro.debian.net/lists/trusty.jp.full | sudo tee /etc/apt/sources.list.d/neurodebian.sources.list
sudo apt-key adv --recv-keys --keyserver hkp://pgp.mit.edu:80 0xA5D32F012649A5A9
gpg --keyserver keyserver.ubuntu.com --recv A5D32F012649A5A9
gpg --export --armor A5D32F012649A5A9 | sudo apt-key add -
sudo apt-get update
# Neuroimaging softwares
sudo apt-get install fsl-complete -y
sudo apt-get install afni -y
sudo apt-get install mricron caret -y
# FREESURFER
scp -r ${id_at_server}@${server}:/home/${id_at_server}/Downloads/freesurfer-Linux-centos6_x86_64-stable-pub-v5.3.0.tar.gz ./
tar -C /usr/local -xzvf ./freesurfer-Linux-centos6_x86_64-stable-pub-v5.3.0.tar.gz
sudo scp -r ${id_at_server}@${server}:/usr/local/license.txt /usr/local/freesurfer/license.txt
# Other softwares
sudo apt-get install tree parallel -y
# bash profile
echo 'alias rr="source /etc/profile"'
echo "export FREESURFER_HOME=/usr/local/freesurfer" >> /etc/profile
echo "source \$FREESURFER_HOME/SetUpFreeSurfer.sh" >> /etc/profile
echo "export PATH=\${PATH}:/usr/lib/afni/bin" >> /etc/profile
echo "#fsl configuration" >> /etc/profile
echo ". /etc/fsl/5.0/fsl.sh" >> /etc/profile
echo "alias ll='ls -artl'" >> /etc/profile
# Make CCNC IDs
pass=$(perl -e 'print crypt($ARGV[0], "password")' $adminpassword)
for i in `ssh ${id_at_server}@${server} 'ls /home'`
do
if [ ! -d /home/${i} ]
then
echo Making ${i}
sudo useradd -g ${admingroup} -m -p ${pass} -s /bin/bash ${i}
sudo mkdir /home/${i}/.ssh
sudo cp -r /home/ubuntu/.ssh/authorized_keys /home/${i}/.ssh/authorized_keys
sudo chown -R ${i} /home/${i}/.ssh
sudo chmod 400 /home/${i}/.ssh/authorized_keys
else
echo ${i} is already created
#sudo usermod -a -G workshop ${i}
fi
done
# Make workshop IDs
pass=$(perl -e 'print crypt($ARGV[0], "password")' $workshoppassword)
for i in `ssh ${id_at_server}@${server} 'cat /home/${id_at_server}/workshop/emails.txt'`
do
if [ ! -d /home/${i%@*} ]
then
echo Making ${i%@*}
sudo useradd -g ${workshopgroup} -m -p ${pass} -s /bin/bash ${i%@*}
sudo mkdir /home/${i%@*}/.ssh
sudo cp -r /home/ubuntu/.ssh/authorized_keys /home/${i%@*}/.ssh/authorized_keys
sudo chown -R ${i%@*} /home/${i%@*}/.ssh
sudo chmod 400 /home/${i%@*}/.ssh/authorized_keys
else
echo ${i%@*} is already created
fi
done
# VI
echo "imap jj <Esc>" >> /etc/vim/vimrc
echo 'cmap !! w !sudo tee % >/dev/null' >> /etc/vim/vimrc
echo 'set wildmode=longest,list,full' >> /etc/vim/vimrc
echo 'wildmenu' >> /etc/vim/vimrc
# Data
# Data permision
#find ./ -iname '*' -type d -exec sudo setfacl -R -m u::rx {} \;
#find ./ -iname '*' -type d -exec sudo setfacl -R -m g:workshop:rx {} \;
#find ./ -iname '*' -type d -exec sudo setfacl -R -m u:kangik:rwx {} \;
#workshopDataLoc=/media/workshop
#for adminID in dahye_bae eugenie_choe hannah_seo hyerim_oh hyunjung_kim jaewook_han Jeehyung_Suh jeongyun_kim kwaksa shinae_yeom sune_park takhyung_lee takwan_kim wsohn wujeong_hwang yoobin_kwak yoonyw
#do
#sudo setfacl -R -m g:workshopAdmin:rx ${workshopDataLoc}
#done
## vi
#sudo scp [email protected]:/etc/vim/vimrc /etc/vim/vimrc
#git clone https://github.com/VundleVim/Vundle.vim.git /home/kangik/.vim/bundle/Vundle.vim
#vim +PluginInstall +qall
#ln -s ~/.vim/vimrc ~/.vimrc
#fake recon-all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment