2016-06-27 19:00:19 +00:00
#!/bin/bash
2016-08-03 21:45:13 +00:00
mysqlrootpass=${mysqlrootpass:-b+Ydjq4ejT4E}
# To configure zsh
echo Configure zsh and exit
zsh
INSTALL="echo sudo aptitude -y install"
2016-06-27 19:00:19 +00:00
# The testsuite depends on this:
2016-08-03 21:45:13 +00:00
$INSTALL imagemagick expect autossh sshpass jq libpod-simple-perl pod2pdf
2016-08-13 17:11:15 +00:00
$INSTALL lua5.2 clisp php7.0-cli nodejs-legacy mono-csharp-shell
2016-06-27 19:00:19 +00:00
# DEBIAN package
2016-08-03 21:45:13 +00:00
$INSTALL dpkg-dev build-essential debhelper
2016-07-22 16:10:28 +00:00
# SHEBANG TOOLS
2016-08-03 21:45:13 +00:00
$INSTALL gnuplot octave ruby r-base-core
2016-07-22 16:10:28 +00:00
# SQL TOOLS
2016-08-03 21:45:13 +00:00
$INSTALL libdbd-pg-perl libdbd-sqlite3-perl libdbd-csv-perl libdbd-mysql-perl rlwrap
2016-07-22 16:10:28 +00:00
# Compression
2016-08-03 21:45:13 +00:00
$INSTALL pxz pixz
2016-06-27 19:00:19 +00:00
# DATABASES
2016-08-03 21:45:13 +00:00
$INSTALL postgresql mysql-server sqlite
2016-07-02 16:00:51 +00:00
echo '# Create PostgreSQL'
2016-06-27 19:00:19 +00:00
sudo su - postgres -c 'createdb '`whoami`
sudo su - postgres -c 'createuser '`whoami`
sudo su - postgres -c "sql pg:/// \"ALTER USER \\\"`whoami`\\\" WITH PASSWORD '`whoami`';\""
2016-07-02 16:00:51 +00:00
echo '# Create MySQL'
2016-06-27 19:00:19 +00:00
sudo su - mysql mysqladmin create `whoami`
2016-07-02 16:00:51 +00:00
sql mysql://root:"$mysqlrootpass"@/mysql "DROP DATABASE `whoami`;DROP USER '`whoami`'@'localhost';"
sql mysql://root:"$mysqlrootpass"@/mysql "CREATE DATABASE `whoami`;CREATE USER '`whoami`'@'localhost' IDENTIFIED BY '`whoami`'; GRANT ALL ON `whoami`.* TO '`whoami`'@'localhost';"
2016-06-27 19:00:19 +00:00
# SHELLS
2016-08-03 21:45:13 +00:00
$INSTALL ash csh fdclone fish fizsh ksh mksh pdksh posh rc rush sash tcsh yash zsh
2016-06-27 19:00:19 +00:00
SSHPASS=`goodpasswd`
export SSHPASS
2016-08-03 21:45:13 +00:00
#shells="bash sh csh ash tcsh zsh ksh fish fizsh mksh pdksh posh rc sash yash nopathbash nopathcsh"
2017-02-12 20:48:15 +00:00
shells="bash sh csh ash dash tcsh zsh ksh fish fizsh mksh posh rc sash yash nopathbash nopathcsh"
2016-06-27 19:00:19 +00:00
create_shell_user() {
shell="$1"
sudo deluser $shell && sudo mv /home/$shell /tmp/$shell.$RANDOM
sudo groupdel $shell
sudo adduser --disabled-password --gecos "$shell for parallel,,," $shell &&
echo "$shell:$SSHPASS" | sudo chpasswd &&
sshpass -e ssh-copy-id $shell@lo &&
echo "ssh-keyscan" &&
ssh $shell@lo 'ssh-keyscan -t rsa lo >> .ssh/known_hosts' &&
2016-07-22 16:10:28 +00:00
ssh $shell@lo 'ssh-keyscan -t rsa server >> .ssh/known_hosts' &&
2016-08-03 21:45:13 +00:00
echo Do chsh -s $(which $shell || which ${shell#"nopath"}) $shell &&
(echo $shell | grep parallel ||
sudo chsh -s $(which $shell || which ${shell#"nopath"}) $shell) &&
2016-06-27 19:00:19 +00:00
echo | ssh -t $shell@lo ssh-keygen &&
2016-08-03 21:45:13 +00:00
echo Do ssh $shell@lo 'cat .ssh/id_rsa.pub >> .ssh/authorized_keys' &&
2016-06-27 19:00:19 +00:00
ssh $shell@lo 'cat .ssh/id_rsa.pub >> .ssh/authorized_keys' &&
ssh $shell@lo cat .ssh/id_rsa.pub | ssh parallel@lo 'cat >> .ssh/authorized_keys' &&
2017-01-16 23:16:03 +00:00
ssh $shell@lo 'echo ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAxg+dh+BL1myqo6A+pHcQCKVV5v7cewdkN8xGtMDqm7xGgh+e5A44W7qKViIx641d6yoWb012XzDz2MKetG4Kosoma8Z/qkS27p6901RmI3ap2JFffzBESlpQtW1FyxQPlMyBfrd4ONy8xW6R/gEkjC3yOcXCQO2494/c46ouXs5gtE84Cusr3RsopR4bI7oloH1GQZ4vsHSFSakq8IwcujaSh1mmribMONLb2TjDpmE7tAY+yfOVWHPQ2J+EU1//Go60EZfSRKOu81oxW7SJ2uGgWfWcs2T1lRtT8Yh+TwVTz8UFV75kVtpZ10x5baN+ncsSpaBK+8sFLfoMvA9yQQ== tange@freebsd71.tange.dk >> .ssh/authorized_keys' &&
2016-08-03 21:45:13 +00:00
echo Do env_parallel --install &&
ssh $shell@lo env_parallel --install &&
2017-01-16 23:16:03 +00:00
ssh $shell@lo 'mkdir .parallel; touch .parallel/will-cite' &&
2016-08-03 21:45:13 +00:00
echo OK Created $shell &&
echo
2016-06-27 19:00:19 +00:00
}
export -f create_shell_user
2016-08-03 21:45:13 +00:00
. `which env_parallel.bash`
shellsplus="parallel $shells"
parallel -u --timeout 15 --retries 2 --tag -j1 create_shell_user ::: $shellsplus
2016-06-27 19:00:19 +00:00
# sh fails if not run by itself
parallel -u --timeout 15 --retries 2 --tag -j1 create_shell_user ::: sh
2016-08-03 21:45:13 +00:00
parallel -j10 --tag ssh {}@lo ssh {}@lo echo {} OK ::: $shells
2016-06-27 19:00:19 +00:00
ssh_copy_id() {
from="$1"
to="$2"
ssh $from cat .ssh/id_rsa.pub | ssh $to 'cat >> .ssh/authorized_keys'
}
export -f ssh_copy_id
2016-08-03 21:45:13 +00:00
parallel --bar -j10 --timeout 3 --retries 10 --tag ssh_copy_id {1}@lo {2}@lo ::: $shellsplus ::: $shellsplus
parallel -j10 --timeout 3 --retries 10 --tag ssh {1}@lo ssh {2}@lo echo OK ::: $shellsplus ::: $shellsplus
2016-06-27 19:00:19 +00:00
# change paths to no path
(
2016-08-03 21:45:13 +00:00
ssh nopathbash@lo 'echo > .bashrc PATH=/bin:/usr/bin'
ssh nopathbash@lo 'echo > .profile PATH=/bin:/usr/bin'
2016-06-27 19:00:19 +00:00
# Remove env_parallel from .profile
ssh nopathbash@lo 'perl -i.bak -pe s/.*env_parallel.*// .profile .bashrc'
ssh nopathcsh@lo 'echo >> .cshrc setenv PATH /bin:/usr/bin'
ssh nopathbash@lo 'echo $PATH'
ssh nopathcsh@lo 'echo $PATH'
)
ssh-copy-id localhost
# SHELLS: lsh-client against openssh server
2016-08-03 21:45:13 +00:00
$INSTALL lsh-client
2016-06-27 19:00:19 +00:00
cd
mkdir .lsh
lsh-make-seed -o ".lsh/yarrow-seed-file"
2016-08-03 21:45:13 +00:00
lsh -c aes256-ctr --sloppy-host-authentication --capture-to ~/.lsh/host-acls lo echo Added host-auth
lsh -c aes256-ctr --sloppy-host-authentication --capture-to ~/.lsh/host-acls localhost echo Added host-auth
2016-06-27 19:00:19 +00:00
lsh-keygen | lsh-writekey -c none
2016-08-03 21:45:13 +00:00
lsh-export-key --openssh < ~/.lsh/identity.pub | lsh -c aes256-ctr lo 'cat >>.ssh/authorized_keys'
lsh-export-key --openssh < ~/.lsh/identity.pub | ssh csh@lo 'cat >>.ssh/authorized_keys'
2016-06-27 19:00:19 +00:00
2016-07-22 16:10:28 +00:00
2016-06-27 19:00:19 +00:00
parallel --record-env
sudo cp /usr/bin/tmux /usr/local/bin/tmux1.8
2016-08-03 21:45:13 +00:00
ssh freebsd7.t cat .ssh/id_rsa.pub | ssh parallel@localhost 'cat >>.ssh/authorized_keys'
echo Add:
echo HostkeyAlgorithms +ssh-dss
echo to .ssh/config if you get
echo no matching host key type found. Their offer: ssh-dss