3 # SPDX-FileCopyrightText: 2002-2023 Ole Tange, http://ole.tange.dk and Free Software and Foundation, Inc.
5 # SPDX-License-Identifier: GPL-3.0-or-later
8 # After first run, set this:
10 INSTALL
=${INSTALL:-"sudo aptitude -y install"}
12 # The testsuite depends on this:
13 test_pkgs
="imagemagick expect autossh sshpass jq libpod-simple-perl"
14 test_pkgs
="$test_pkgs pod2pdf gawk lua5.3 clisp php-cli nodejs"
15 test_pkgs
="$test_pkgs mono-csharp-shell libevent-dev tcl libtext-csv-perl"
16 test_pkgs
="$test_pkgs xterm libc6-i386 libcrypt1:i386"
17 test_pkgs
="$test_pkgs libtest-nowarnings-perl xemacs21-bin"
20 packaging_pkgs
="dpkg-dev build-essential debhelper osc cvs automake-1.15"
21 packaging_pkgs
="$packaging_pkgs python3-m2crypto alien"
24 shebang_pkgs
="gnuplot octave ruby r-base-core"
27 sql_pkgs
="libdbd-pg-perl libdbd-sqlite3-perl libdbd-csv-perl"
28 sql_pkgs
="$sql_pkgs libdbd-mysql-perl rlwrap"
31 compression_pkgs
="zstd clzip liblz4-tool lzop pigz pixz gzip plzip pbzip2"
32 compression_pkgs
="$compression_pkgs lzma xz-utils lzip bzip2 lbzip2 lrzip"
33 compression_pkgs_missing
="pxz"
36 # (csh = bsd-csh that is broken)
37 shell_pkgs
="ash dash fdclone fish fizsh ksh ksh93u+m ksh93 mksh posh rc rush sash"
38 shell_pkgs
="$shell_pkgs tcsh yash zsh busybox-static"
41 database_pkgs
="postgresql mysql-server sqlite influxdb influxdb-client"
44 build_pkgs
="bison libxxhash-dev libzstd-dev liblz4-dev libssl-dev"
45 build_pkgs
="$build_pkgs python3-cmarkgfm graphviz"
47 sudo dpkg
--add-architecture i386
; sudo apt update
48 pip
install sphinx-rtd-theme
49 if $INSTALL $test_pkgs $packaging_pkgs $shebang_pkgs $sql_pkgs \
50 $compression_pkgs $shell_pkgs $database_pkgs $build_pkgs ; then
60 install_oracle_client
() {
61 # https://salsa.debian.org/perl-team/modules/packages/libdbd-oracle-perl/blob/master/debian/README.Debian
62 # sql oracle:// && return 0
65 get_rpm_install_deb
() {
69 if [ ! -e `echo $glob*rpm` ] ; then
72 if [ ! -e `echo $glob*deb` ] ; then
73 echo Convert
`echo $glob*rpm` to deb
74 fakeroot alien
`echo $glob*rpm`
76 if [ ! -e `echo $testglob` ] ; then
77 echo Install
`echo $glob*deb`
78 sudo dpkg
-i `echo $glob*deb`
82 oracleurl
=https
://download.oracle.com
/otn_software
/linux
/instantclient
/19600
83 client
=oracle-instantclient19.6
84 ver
=19.6.0.0.0-1.x86_64.rpm
85 get_rpm_install_deb
'oracle-instantclient*devel' $client-devel-$ver /usr
/share
/doc
/oracle-instantclient
*-devel/copyright
86 get_rpm_install_deb
'oracle-instantclient*basic' $client-basic-$ver /usr
/share
/oracle
/*/client
*/doc
/BASIC_README
87 get_rpm_install_deb
'oracle-instantclient*sqlplus' $client-sqlplus-$ver /usr
/lib
/oracle
/*/client
*/bin
/sqlplus
90 echo Add this to .bashrc
:
91 ORACLE_HOME
=`echo /usr/lib/oracle/*/client*`
92 echo ORACLE_HOME
=$ORACLE_HOME
93 if grep -q ORACLE_HOME
=/ ~
/.bashrc
; then
94 perl
-i.old
-pe "s:ORACLE_HOME=/.*:ORACLE_HOME=$ORACLE_HOME:" ~
/.bashrc
96 echo ORACLE_HOME
=$ORACLE_HOME >> ~
/.bashrc
97 echo 'PATH=$PATH:$ORACLE_HOME/bin' >> ~
/.bashrc
98 echo 'export ORACLE_HOME' >> ~
/.bashrc
99 echo 'export ORACLE_SID=XE' >> ~
/.bashrc
101 perl
-MCPAN -e 'install DBD::Oracle'
102 # TODO set up vagrant oracle server
103 git clone https
://github.com
/oracle
/vagrant-projects.git
104 # TODO set up default passwd
105 echo sudo su
- oracle
-c "'/home/oracle/setPassword.sh $oracle_password'" |
107 # test it works: sql oracle://
112 echo '# Create PostgreSQL'
113 # Drop database and user if needed
114 sudo su
- postgres
-c 'dropdb '`whoami`
115 sudo su
- postgres
-c 'dropuser '`whoami`
116 sudo su
- postgres
-c 'createdb '`whoami`
117 sudo su
- postgres
-c 'createuser '`whoami`
118 sudo su
- postgres
-c "sql pg:/// \"ALTER USER \\\"`whoami`\\\" WITH PASSWORD '`whoami`';\""
120 mysqlrootpass
=${mysqlrootpass:-b+Ydjq4ejT4E}
121 dburl
=mysql
://root
:"$mysqlrootpass"@
/mysql
122 echo '# Create MySQL'
123 sudo su mysql mysqladmin create
`whoami`
124 # Default Debian way of getting "root" access
125 sudo mysql
--defaults-file=/etc
/mysql
/debian.cnf mysql
<<< "ALTER USER 'root'@'localhost' IDENTIFIED BY '$mysqlrootpass';"
127 # Drop database and user if needed
128 sudo sql
"$dburl" "DROP DATABASE `whoami`;DROP USER '`whoami`'@'localhost';"
129 sudo sql
"$dburl" "CREATE DATABASE `whoami`;CREATE USER '`whoami`'@'localhost' IDENTIFIED BY '`whoami`'; GRANT ALL ON `whoami`.* TO '`whoami`'@'localhost';"
132 add_server_to_hosts
() {
133 # Insert 127.1.2.3 server in /etc/hosts
134 if grep -q 127.1.2.3 /etc
/hosts
; then
138 printf "127.1.2.3\tserver\n" |
139 sudo
tee -a /etc
/hosts
144 shells
="bash sh csh ash dash tcsh zsh ksh ksh2020 ksh93 fish fizsh mksh"
145 shells
="$shells posh rc sash yash nopathbash nopathcsh"
146 shellsplus
="parallel $shells"
147 parallel
-k echo ::: $shellsplus
150 create_shell_logins
() {
152 echo '# Create shell logins'
156 append-if-not-exists
() {
160 if grep -qF "$string" "$file"; then
161 # It is there already
162 echo "$string is already in $file"
164 echo "$string" | sudo
tee -a "$file"
169 append-if-not-exists
/etc
/shells $
(which $shell ||
170 which ${shell#"nopath"})
171 sudo killall
-u $shell
172 sudo deluser
$shell && sudo
mv /home
/$shell /tmp
/$shell.
$RANDOM
174 if echo $shell |
grep -q parallel
; then
175 # User parallel should have /bin/bash
178 # Other users should have `which $shell` with nopath removed
179 loginshell
=$
(which $shell ||
which ${shell#"nopath"})
181 sudo adduser
--shell $loginshell --disabled-password --gecos "$shell for parallel,,," $shell &&
182 echo "$shell:$SSHPASS" | sudo chpasswd
&&
183 sshpass
-e ssh-copy-id
$shell@lo
&&
184 echo "$shell created"
186 export -f del_add_user
188 echo '# (Re-)create user'
189 # Racecondition: if multiple adds a group it will the same group ID
190 (shellsplus
; echo withpassword
) |
191 parallel
--lb --halt soon
,fail
=1 --timeout 1000% --retries 5 --tag -j1 del_add_user ||
192 (echo Creation failed
: $?
; false
)
198 echo Add server keys
for lo and server
&&
199 ssh $shell@lo
'rm -f .ssh/id_rsa;
200 ssh-keyscan lo >>.ssh/known_hosts;
201 ssh-keyscan server >> .ssh/known_hosts' &&
202 echo Do ssh-keygen
&&
203 echo |
ssh -t $shell@lo ssh-keygen
-b 1024 -f .ssh
/id_rsa
&&
204 echo Do
ssh $shell@lo
'cat .ssh/id_rsa.pub >> .ssh/authorized_keys' &&
205 ssh $shell@lo
'cat .ssh/id_rsa.pub | tee -a .ssh/authorized_keys' |
206 ssh parallel@lo
'cat >> .ssh/authorized_keys' &&
207 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" &&
208 echo Do env_parallel
--install &&
209 ssh $shell@lo
'mkdir -p .parallel;
210 touch .parallel/will-cite;
211 env_parallel --install' &&
212 echo OK make_sshkey
$shell &&
214 echo OK make_sshkey
$shell >&2 &&
217 export -f make_sshkey
219 echo '# Make and copy sshkey'
220 shellsplus | parallel
--timeout 20 --retries 5 --tag -j5 make_sshkey
223 ssh $1@lo
ssh $2@lo
echo OK ||
224 (echo failed
&& false
)
227 echo "# copy id from X to X"
228 shellsplus | parallel
--timeout 10 --tag ssh_a_to_b
{} {}
233 ssh $from cat .ssh
/id_rsa.pub |
ssh $to 'cat >> .ssh/authorized_keys'
235 export -f ssh_copy_id
237 echo '# copy id from any X to any Y'
238 parallel
-u --bar -j3 --timeout 3 --retries 10 --tag \
239 ssh_copy_id
{1}@lo
{2}@lo
::: $
(shellsplus
) ::: $
(shellsplus
)
240 echo '# Test the copying went well'
241 parallel
--bar -j2 --timeout 9 --retries 10 --tag \
242 ssh_a_to_b
::: $
(shellsplus
) ::: $
(shellsplus
)
244 echo '# change paths to no path'
246 ssh nopathbash@lo
'echo > .bashrc PATH=/bin:/usr/bin'
247 ssh nopathbash@lo
'echo > .profile PATH=/bin:/usr/bin'
248 # Remove env_parallel from .profile
249 ssh nopathbash@lo
'perl -i.bak -pe s/.*env_parallel.*// .profile .bashrc'
250 ssh nopathcsh@lo
'echo >> .cshrc setenv PATH /bin:/usr/bin'
251 ssh nopathcsh@lo
'echo >> .login setenv PATH /bin:/usr/bin'
252 ssh nopathbash@lo
'echo $PATH; echo 1 | parallel echo' ||
253 echo Great
- this should FAIL
: parallel should not be found
254 ssh nopathcsh@lo
'echo $PATH; echo 1 | parallel echo' ||
255 echo Great
- this should FAIL
: parallel should not be found
260 ssh-keyscan localhost
>>~
/.ssh
/known_hosts
261 ssh-copy-id localhost
263 # SHELLS: lsh-client against openssh server
267 lsh-make-seed
-o ".lsh/yarrow-seed-file"
268 lsh
-c aes256-ctr
--sloppy-host-authentication \
269 --capture-to ~
/.
lsh
/host-acls lo
echo Added host-auth
270 lsh
-c aes256-ctr
--sloppy-host-authentication \
271 --capture-to ~
/.
lsh
/host-acls localhost
echo Added host-auth
272 lsh-keygen | lsh-writekey
-c none
273 export_key_to_local_users
() {
274 lsh-export-key
--openssh < ~
/.
lsh
/identity.pub |
275 ssh -l $1 lo
'cat >>.ssh/authorized_keys'
277 export -f export_key_to_local_users
278 shellsplus | parallel
--bar --timeout 5 export_key_to_local_users
279 shellsplus | parallel
--bar --timeout 5 'lsh -l {} lo true || export_key_to_local_users {}'
280 shellsplus | parallel
--bar --timeout 5 'lsh -l {} lo true || echo Fail {}'
284 echo "# Add public key to freebsd7.t"
285 ssh freebsd7.t
cat .ssh
/id_rsa.pub |
286 ssh parallel@localhost
'cat >>.ssh/authorized_keys'
289 echo HostkeyAlgorithms
+ssh-dss
290 echo to .ssh
/config
if you get
291 echo no matching
host key
type found. Their offer
: ssh-dss
293 echo Add to
/etc
/ssh
/sshd_config
294 echo Ciphers aes128-ctr
,aes192-ctr
,aes256-ctr
,aes256-cbc
,aes192-cbc
,aes128-cbc
,3des-cbc
295 echo KexAlgorithms diffie-hellman-group-exchange-sha256
,ecdh-sha2-nistp256
,ecdh-sha2-nistp384
,ecdh-sha2-nistp521
,curve25519-sha256@libssh.org
,diffie-hellman-group1-sha1
,diffie-hellman-group14-sha1
,diffie-hellman-group-exchange-sha1
298 echo Unable to negotiate with server port
22: no matching cipher found.
299 echo Their offer
: aes128-cbc
,3des-cbc
,blowfish-cbc
,cast128-cbc
,arcfour
,aes192-cbc
,aes256-cbc
,rijndael-cbc@lysator.liu.se
300 echo add this to .ssh
/config
301 echo Ciphers
+aes256-cbc
306 git clone https
://github.com
/tmux
/tmux.git
312 rsync
-a --delete tmux
/ tmux
$1/
319 sudo
cp tmux
/usr
/local
/bin
/tmux-
$1
322 echo '# Building tmux'
324 stdout parallel
--lb --tag '/usr/local/bin/tmux-{} -V || make_one {}'
326 parallel
-k -v /usr
/local
/bin
/tmux-
{} -V
331 echo You may have to
kill conftest
333 git clone https
://git.savannah.gnu.org
/git
/bash.git
336 git tag |
grep -v -- '-.*-' |
grep -v bash-4.1
.11)
339 rsync
-a --delete bash
/ $1/
343 LDFLAGS
=-static .
/configure
&&
345 sudo
cp bash
/usr
/local
/bin
/$1
348 echo '# Building bash'
350 stdout parallel
--lb --tag \
351 '/usr/local/bin/{} --version || make_one {}'
353 parallel
-k -v --tag '/usr/local/bin/{} --version'
359 git clone https
://github.com
/WayneD
/rsync
362 git tag |
grep -v -- '-.*-' |
grep -v pre
)
365 rsync
-a --delete rsync
/ rsync-
$1/
369 perl
-i -pe 's/AC_DEFINE_UNQUOTED.HAVE_REMSH, .HAVE_REMSH./AC_DEFINE_UNQUOTED(HAVE_REMSH, \$HAVE_REMSH,[dummy])/;
370 s/AC_DEFINE.HAVE_ERRNO_DECL.,/AC_DEFINE(HAVE_ERRNO_DECL,[1],[dummy]),/;
371 s/AC_DEFINE.HAVE_FNMATCH.,/AC_DEFINE(HAVE_FNMATCH,[1],[dummy]),/;' configure.
in
372 autoreconf
--install -W gnu
373 # Make "lib/addrinfo.h" ?
374 LDFLAGS
=-static .
/configure
&&
375 (make proto
; make -j2) &&
376 sudo
cp rsync
/usr
/local
/bin
/rsync-
$1
379 echo '# Building rsync'
381 stdout parallel
--lb --tag \
382 '/usr/local/bin/rsync-{} --version || make_one {}'
384 parallel
-k -v --tag '/usr/local/bin/rsync-{} --version'
388 install_tangetools
() {
389 git clone https
://gitlab.com
/ole.tange
/tangetools.git
396 parallel
--record-env
398 # Build locale for LC_ALL=zh_HK.big5hkscs perl -e 1
399 sudo locale-gen zh_HK
404 install_tangetools
&&
405 install_oracle_client
&&
407 add_server_to_hosts
&&
408 create_shell_logins
&&