diff options
author | builder <builder@host> | 2021-02-26 00:18:20 +0000 |
---|---|---|
committer | builder <builder@host> | 2021-02-26 00:18:20 +0000 |
commit | 2a862d9141a84b612ec2dd109a7f74a2b10ffb91 (patch) | |
tree | 037170f7158639bb6d43ac7ebc656df8e6dcc2bc /linux/scripts | |
parent | 88ad431d4bef94a816b4a1031fb5a62d4bd8a0d7 (diff) | |
download | doc-2a862d9141a84b612ec2dd109a7f74a2b10ffb91.tar.gz |
tools scripts moved to linux
Diffstat (limited to 'linux/scripts')
-rwxr-xr-x | linux/scripts/mirror-system | 73 | ||||
-rw-r--r-- | linux/scripts/pkgmk-test.conf | 19 | ||||
-rw-r--r-- | linux/scripts/pkgmk-test.sh | 5 | ||||
-rwxr-xr-x | linux/scripts/replace.sh | 9 | ||||
-rw-r--r-- | linux/scripts/runvm/c12-dvd | 15 | ||||
-rw-r--r-- | linux/scripts/runvm/profile/crux | 7 | ||||
-rw-r--r-- | linux/scripts/runvm/runvm.sh | 26 | ||||
-rw-r--r-- | linux/scripts/setup-gitolite.sh | 43 | ||||
-rw-r--r-- | linux/scripts/setup-nginx.sh | 24 | ||||
-rw-r--r-- | linux/scripts/setup-openssh.sh | 43 | ||||
-rw-r--r-- | linux/scripts/setup-php.sh | 7 | ||||
-rw-r--r-- | linux/scripts/setup-postgresql.sh | 87 | ||||
-rw-r--r-- | linux/scripts/setup-x.sh | 96 |
13 files changed, 454 insertions, 0 deletions
diff --git a/linux/scripts/mirror-system b/linux/scripts/mirror-system new file mode 100755 index 0000000..6c8a528 --- /dev/null +++ b/linux/scripts/mirror-system @@ -0,0 +1,73 @@ +#!/bin/bash + +if [ -f /tmp/mirror ]; then + echo "mirror system is already running" + exit 0 +fi + +touch /tmp/mirror + +#BUILD_NAME="R2D9" +#BUILD_TITLE="${BUILD_NAME}-$(cat /usr/ports/releases/stable/metadata/build-version)" +BUILD_TITLE="Crux 3.6" + +# Update system +ports -u + +# make them look like updated +echo "touch packages..." +for package in /usr/ports/packages/*; do + touch ${package}; +done + +# make sure permissions are right +echo "chown pkgmk:pkgmk -R /usr/ports" +chown pkgmk:pkgmk -R /usr/ports + +echo "update system" +prt-get depinst $(prt-get listinst | xargs prt-get quickdep) +prt-get sysup +prt-get update -fr $(revdep) + +# Create list of installed packages +echo "creating list of installed..." +rm -r /usr/ports/installed +pkg_installed + +### clean distribution files +mkdir -p /usr/ports/archive/distfiles +mv /usr/ports/distfiles/* /usr/ports/archive/distfiles +### clean packages files +mkdir -p /usr/ports/archive/packages +mv /usr/ports/packages/* /usr/ports/archive/packages +### get sources and packages +cd /usr/ports/installed +for installed in *; do + prt-get path $installed | while read -r line; do + cd $line + ##get source + sudo -u pkgmk -g pkgmk pkgmk -do + #make sure package exists + current="${installed}#$(prt-get current ${installed}).pkg.tar.gz" + echo "checking $current ..." + cp /usr/ports/archive/packages/${current} /usr/ports/packages/ + #prt-get update $installed + done +done + +# Create repository +echo "creating repository" +cd /usr/ports/packages +pkg-repgen + +# Create mirror page +echo "creating mirror index page" +portspage --title=${BUILD_TITLE} /usr/ports/installed > /usr/ports/installed/index.html + +sed -i "s@usr\/ports\/installed@mirror/installed@g" /usr/ports/installed/index.html + +echo "setting permissions /usr/ports" +chown pkgmk:pkgmk -R /usr/ports + +# Remove temporary file +rm /tmp/mirror diff --git a/linux/scripts/pkgmk-test.conf b/linux/scripts/pkgmk-test.conf new file mode 100644 index 0000000..4a04eec --- /dev/null +++ b/linux/scripts/pkgmk-test.conf @@ -0,0 +1,19 @@ +# +# /etc/pkgmk.conf: pkgmk(8) configuration +# + +source /etc/pkgmk.conf + +#PKGMK_SOURCE_MIRRORS=(http://c1.ank/distfiles/) +PKGMK_SOURCE_DIR="$PWD" +PKGMK_PACKAGE_DIR="$PWD" +PKGMK_WORK_DIR="$PWD/work" +PKGMK_DOWNLOAD="yes" +PKGMK_UP_TO_DATE="no" +# PKGMK_IGNORE_FOOTPRINT="no" +# PKGMK_IGNORE_NEW="no" +# PKGMK_NO_STRIP="no" +# PKGMK_DOWNLOAD_PROG="wget" +# PKGMK_WGET_OPTS="" +# PKGMK_CURL_OPTS="" +# PKGMK_COMPRESSION_MODE="gz" diff --git a/linux/scripts/pkgmk-test.sh b/linux/scripts/pkgmk-test.sh new file mode 100644 index 0000000..4cfe2c3 --- /dev/null +++ b/linux/scripts/pkgmk-test.sh @@ -0,0 +1,5 @@ +#!/bin/bash +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CONF=${DIR}/pkgmk-test.conf +echo "pkgmk -cf $CONF -d -is $1" +fakeroot pkgmk -cf $CONF -d -is $1 diff --git a/linux/scripts/replace.sh b/linux/scripts/replace.sh new file mode 100755 index 0000000..8d5d8d9 --- /dev/null +++ b/linux/scripts/replace.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# find and replace string on files +folder=$1 +oldstring=$2 +newstring=$3 + +#grep -rl $oldstring $folder | xargs sed -i s@$oldstring@$newstring@g +grep -rl "$oldstring" $folder | xargs sed -i "s@$oldstring@$newstring@g" diff --git a/linux/scripts/runvm/c12-dvd b/linux/scripts/runvm/c12-dvd new file mode 100644 index 0000000..9cbf201 --- /dev/null +++ b/linux/scripts/runvm/c12-dvd @@ -0,0 +1,15 @@ +export QEMU_AUDIO_DRV=alsa + +memory=1024 + +boot=c + +iso=iso/devuan_jessie_1.0.0_amd64_CD.iso + +image=img/c12-dvd.qcow2 + +tap="tap2" + +mac="54:60:be:ef:5c:72" + +other="-soundhw hda -vga std -display sdl -usb -device usb-ehci -device usb-host,vendorid=0x13d3,productid=0x5652" diff --git a/linux/scripts/runvm/profile/crux b/linux/scripts/runvm/profile/crux new file mode 100644 index 0000000..672b80d --- /dev/null +++ b/linux/scripts/runvm/profile/crux @@ -0,0 +1,7 @@ +mac="54:60:be:ef:5c:64" +memory=1024 +boot=$2 +tap="tap4" +iso=iso/crux-3.4.iso +image=img/c14.qcow2 +other="-vga std -display sdl" diff --git a/linux/scripts/runvm/runvm.sh b/linux/scripts/runvm/runvm.sh new file mode 100644 index 0000000..21cd097 --- /dev/null +++ b/linux/scripts/runvm/runvm.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +function rmac_addr (){ +printf '54:60:BE:EF:%02X:%02X\n' $((RANDOM%256)) $((RANDOM%256)) +} + +source profile/$1 + +#mac=$(rmac_addr) +#memory=1024 +#boot=d +#tap="tap1" +#iso=iso/crux-3.4.iso +#image=img/crux-standard.qcow2 +#other="-soundhw hda -vga std -display sdl" + +qemu-system-x86_64 \ + -enable-kvm \ + -m ${memory} \ + -boot ${boot} \ + -cdrom ${iso} \ + -hda ${image} \ + -device e1000,netdev=t0,mac=${mac} \ + -netdev tap,id=t0,ifname=${tap},script=no,downscript=no \ + ${other} \ + & diff --git a/linux/scripts/setup-gitolite.sh b/linux/scripts/setup-gitolite.sh new file mode 100644 index 0000000..c42db14 --- /dev/null +++ b/linux/scripts/setup-gitolite.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +# First we define the function +ConfirmOrExit () +{ + while true + do + echo -n "Please confirm (y or n) :" + read CONFIRM + case $CONFIRM in + y|Y|YES|yes|Yes) break ;; + n|N|no|NO|No) + echo "Aborting - you entered $CONFIRM" + exit + ;; + *) echo "Please enter only y or n" + esac + done + echo "You entered $CONFIRM. Continuing ..." +} + + +# Absolute path to this script, e.g. /home/user/bin/foo.sh +SCRIPT=$(readlink -f "$0") +# Absolute path this script is in, thus /home/user/bin +SCRIPTPATH=$(dirname "$SCRIPT") + +DIR=$(dirname "$SCRIPTPATH"); +DIR_CONF=$DIR"/conf" + +echo "SCRIPT=$SCRIPT"; +echo "SCRIPTPATH=$SCRIPTPATH"; +echo "DIR=$DIR"; +echo "DIR_CONF=$DIR_CONF"; +ConfirmOrExit + + prt-get depinst gitolite + + mkdir -p /srv/gitolite + useradd -U -d /srv/gitolite gitolite + chown gitolite:gitolite /srv/gitolite + +exit 0; diff --git a/linux/scripts/setup-nginx.sh b/linux/scripts/setup-nginx.sh new file mode 100644 index 0000000..11065d2 --- /dev/null +++ b/linux/scripts/setup-nginx.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +#. `dirname $0`/config-install.sh +# +#prt-get depinst nginx +# +#cp -R $CONF_DIR/etc/nginx/* /etc/nginx/ +# +#mkdir /srv/www +#chown www:www /srv/www +# +#usermod -a -g www nginx +#usermod -m -d /srv/www nginx + +openssl genrsa -des3 -out /etc/ssl/keys/nginx.key 2048 +openssl req -new -key /etc/ssl/keys/nginx.key -out /etc/ssl/certs/nginx.csr +openssl x509 -req -days 365 \ + -in /etc/ssl/certs/nginx.csr \ + -signkey /etc/ssl/keys/nginx.key \ + -out /etc/ssl/certs/nginx.crt + +cp /etc/ssl/keys/nginx.key /etc/ssl/keys/nginx.key.pass +openssl rsa -in /etc/ssl/keys/nginx.key.pass -out /etc/ssl/keys/nginx.key + diff --git a/linux/scripts/setup-openssh.sh b/linux/scripts/setup-openssh.sh new file mode 100644 index 0000000..14afe8b --- /dev/null +++ b/linux/scripts/setup-openssh.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +# First we define the function +ConfirmOrExit () +{ + while true + do + echo -n "Please confirm (y or n) :" + read CONFIRM + case $CONFIRM in + y|Y|YES|yes|Yes) break ;; + n|N|no|NO|No) + echo "Aborting - you entered $CONFIRM" + exit + ;; + *) echo "Please enter only y or n" + esac + done + echo "You entered $CONFIRM. Continuing ..." +} + + +# Absolute path to this script, e.g. /home/user/bin/foo.sh +SCRIPT=$(readlink -f "$0") +# Absolute path this script is in, thus /home/user/bin +SCRIPTPATH=$(dirname "$SCRIPT") + +DIR=$(dirname "$SCRIPTPATH"); +DIR_CONF=$DIR"/conf" + +echo "SCRIPT=$SCRIPT"; +echo "SCRIPTPATH=$SCRIPTPATH"; +echo "DIR=$DIR"; +echo "DIR_CONF=$DIR_CONF"; +ConfirmOrExit + + + #installer overwrite system init script + cp -R $DIR_CONF/etc/ssh/sshd_config /etc/ssh/sshd_config + + sh /etc/rc.d/sshd start + +exit 0; diff --git a/linux/scripts/setup-php.sh b/linux/scripts/setup-php.sh new file mode 100644 index 0000000..4c28173 --- /dev/null +++ b/linux/scripts/setup-php.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +. `dirname $0`/config-install.sh + +prt-get depinst php php-fpm php-gd php-pdo-pgsql php-postgresql + +cp /etc/php/php.ini-development /etc/php/php.ini diff --git a/linux/scripts/setup-postgresql.sh b/linux/scripts/setup-postgresql.sh new file mode 100644 index 0000000..4e1ee3a --- /dev/null +++ b/linux/scripts/setup-postgresql.sh @@ -0,0 +1,87 @@ +#!/bin/sh + +# First we define the function +ConfirmOrExit () +{ + while true + do + echo -n "Please confirm (y or n) :" + read CONFIRM + case $CONFIRM in + y|Y|YES|yes|Yes) break ;; + n|N|no|NO|No) + echo "Aborting - you entered $CONFIRM" + exit + ;; + *) echo "Please enter only y or n" + esac + done + echo "You entered $CONFIRM. Continuing ..." +} + + +# Absolute path to this script, e.g. /home/user/bin/foo.sh +SCRIPT=$(readlink -f "$0") +# Absolute path this script is in, thus /home/user/bin +SCRIPTPATH=$(dirname "$SCRIPT") + +DIR=$(dirname "$SCRIPTPATH"); +DIR_CONF=$DIR"/conf" + +echo "SCRIPT=$SCRIPT"; +echo "SCRIPTPATH=$SCRIPTPATH"; +echo "DIR=$DIR"; +echo "DIR_CONF=$DIR_CONF"; +ConfirmOrExit + +IS_INSTALL=$(prt-get isinst postgresql); +echo $IS_INSTALL; +if [ "$IS_INSTALL" = "package postgresql is installed" ] +then + echo "updating postgresql" + OLD_VERSION=$(prt-get current postgresql); + echo $OLD_VERSION; + + sudo -u postgres pg_dumpall > /srv/pgsql/dump-$OLD_VERSION.sql + + sh /etc/rc.d/postgresql stop + + #extra backup, in case ... + tar --xattrs -zcpf /srv/pgsql/data-$OLD_VERSION.tar.gz \ + --directory=/srv/pgsql/data . + + rm -R /srv/pgsql/data + + prt-get update postgresql + + NEW_VERSION=$(prt-get current postgresql); + echo $NEW_VERSION; + + sudo -u postgres initdb -D /srv/pgsql/data + + rejmerge + #installer overwrite system init script + cp -R $DIR_CONF/etc/rc.d/postgresql /etc/rc.d/ + + sh /etc/rc.d/postgresql start + sleep 5 + + sudo -u postgres psql -d postgres -f /srv/pgsql/dump-$OLD_VERSION.sql + +else + echo "install postgresql and dependencies" + prt-get depinst postgresql + + cp -R $DIR_CONF/etc/rc.d/postgresql /etc/rc.d/ + + mkdir /srv/pgsql/ + touch /var/log/postgresql + chown postgres:postgres /srv/pgsql /var/log/postgresql + + sudo -u postgres initdb -D /srv/pgsql/data + + cp $DIR_CONF/srv/pgsql/data/pg_hba.conf /srv/pgsql/data/ + chown postgres:postgres /srv/pgsql/data/pg_hba.conf +fi + +exit 0; diff --git a/linux/scripts/setup-x.sh b/linux/scripts/setup-x.sh new file mode 100644 index 0000000..262b4dd --- /dev/null +++ b/linux/scripts/setup-x.sh @@ -0,0 +1,96 @@ +#!/bin/bash + +# Absolute path to this script, e.g. /home/user/bin/foo.sh +SCRIPT=$(readlink -f "$0") +# Absolute path this script is in, thus /home/user/bin +SCRIPTPATH=$(dirname "$SCRIPT") + +DIR=$(dirname "$SCRIPTPATH"); +DIR_CONF=$DIR"/conf" + + + +prt-get depinst xorg-server \ + xorg-xinit \ + xorg-xrdb \ + xorg-xdpyinfo \ + xorg-xauth \ + xorg-xmodmap \ + xorg-xrandr \ + xorg-xgamma \ + xorg-xf86-input-evdev \ + xorg-xf86-input-synaptics \ + xsel \ + xkeyboard-config + +prt-get depinst xorg-font-util \ + xorg-font-alias \ + xorg-font-dejavu-ttf \ + xorg-font-cursor-misc \ + xorg-font-misc-misc \ + console-font-terminus \ + xorg-font-terminus \ + xorg-font-mutt-misc + +prt-get search xorg-font-bitstream | xargs sudo prt-get depinst +prt-get search xorg-font-bh | xargs sudo prt-get depinst + +#prt-get search otf- | xargs sudo prt-get depinst +#prt-get depinst otf-sourcecode + +prt-get depinst \ + alsa-utils \ + libdrm \ + mesa3d \ + ffmpeg \ + gstreamer \ + gstreamer-vaapi \ + gst-plugins-base \ + gst-plugins-good \ + gst-plugins-bad \ + gst-plugins-ugly \ + cmus \ + dmenu \ + st \ + gparted \ + gimp \ + libreoffice \ + ca-certificates \ + linux-pam \ + gstreamer \ + libgd \ + icu \ + syndaemon \ + firefox + +prt-get depinst \ + openbox \ + dwm \ + spectrwm \ + mate + +ConfirmOrExit () { + while true + do + echo -n "Please confirm (y or n) :" + read CONFIRM + case $CONFIRM in + y|Y|YES|yes|Yes) break ;; + n|N|no|NO|No) + echo "Aborting - you entered $CONFIRM" + exit + ;; + *) echo "Please enter only y or n" + esac + done + echo "You entered $CONFIRM. Continuing ..." +} + +echo "SCRIPT=$SCRIPT"; +echo "SCRIPTPATH=$SCRIPTPATH"; +echo "DIR=$DIR"; +echo "DIR_CONF=$DIR_CONF"; +ConfirmOrExit + +cp -R $DIR_CONF/etc/X11/* /etc/X11/ + |