From a3628fc49db4d88ff3e4067268650710d1da3f6f Mon Sep 17 00:00:00 2001 From: Silvino Silva Date: Fri, 12 Feb 2021 03:59:34 +0000 Subject: initial openbsd support --- linux/scripts/act-chroot.sh | 15 +++ linux/scripts/backup-ports.sh | 136 +++++++++++++++++++++++++ linux/scripts/backup-system.sh | 194 +++++++++++++++++++++++++++++++++++ linux/scripts/chroot.sh | 9 ++ linux/scripts/install-core.sh | 179 ++++++++++++++++++++++++++++++++ linux/scripts/portspage.patch | 27 +++++ linux/scripts/restore-ports.sh | 53 ++++++++++ linux/scripts/setup-core.sh | 154 ++++++++++++++++++++++++++++ linux/scripts/setup-iso.sh | 144 ++++++++++++++++++++++++++ linux/scripts/setup-target.sh | 224 +++++++++++++++++++++++++++++++++++++++++ linux/scripts/setup-virtual.sh | 78 ++++++++++++++ 11 files changed, 1213 insertions(+) create mode 100644 linux/scripts/act-chroot.sh create mode 100644 linux/scripts/backup-ports.sh create mode 100644 linux/scripts/backup-system.sh create mode 100644 linux/scripts/chroot.sh create mode 100644 linux/scripts/install-core.sh create mode 100644 linux/scripts/portspage.patch create mode 100644 linux/scripts/restore-ports.sh create mode 100644 linux/scripts/setup-core.sh create mode 100644 linux/scripts/setup-iso.sh create mode 100755 linux/scripts/setup-target.sh create mode 100644 linux/scripts/setup-virtual.sh (limited to 'linux/scripts') diff --git a/linux/scripts/act-chroot.sh b/linux/scripts/act-chroot.sh new file mode 100644 index 0000000..29103b1 --- /dev/null +++ b/linux/scripts/act-chroot.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +CHROOT="/mnt" + +mkdir -p $CHROOT/boot/efi +mkdir -p $CHROOT/media + +mkdir -p $CHROOT/dev +mkdir -p $CHROOT/tmp +mkdir -p $CHROOT/proc +mkdir -p $CHROOT/sys + +mount -t proc proc $CHROOT/proc +mount -t sysfs sys $CHROOT/sys +mount --bind /dev $CHROOT/dev diff --git a/linux/scripts/backup-ports.sh b/linux/scripts/backup-ports.sh new file mode 100644 index 0000000..bac18e5 --- /dev/null +++ b/linux/scripts/backup-ports.sh @@ -0,0 +1,136 @@ +#!/bin/bash + +DEST_SYS=/usr/ports/releases/stable +DEST_ARC=/usr/ports/releases/archives + +#PACKAGES=/usr/ports/packages +PACKAGES=/usr/ports/archive/packages + +#PRT_GET_FLAGS="-fr -if -is" +PRT_GET_FLAGS="-fr" + +# Build Name = R1 (System number) D1 (Droid/Machine number) +BUILD_NAME="R1D9" +#echo "Give build NAME;" +#echo "${DEST_ARC}/NAME-0.0.0.targ.gz" +#read BUILD_NAME + +#internal +database=${DEST_SYS}/pkg-db.tar.gz +ports=${DEST_SYS}/etc-ports.tar.gz +metadata=${DEST_SYS}/metadata.tar.gz +build=${DEST_SYS}/metadata/build-version +portsver=${DEST_SYS}/metadata/ports-releases +all=${DEST_SYS}/metadata/all-installed +collinst=${DEST_SYS}/metadata/installed +notfound=${DEST_SYS}/metadata/not-found + +echo "Give build CRUX_RELEASE.VERSION (3.4.X);" +echo "${DEST_ARC}/${BUILD_NAME}-VERSION.tar.gz" +read BUILD_VERSION + +mkdir -p ${DEST_SYS} +mkdir -p ${DEST_ARC} +mkdir -p ${DEST_SYS}/metadata + +archive="${DEST_ARC}/${BUILD_NAME}-${BUILD_VERSION}.tar" +echo "Creating $archive ..." +if [ -f ${archive} ]; then + rm ${archive} +fi + +backup_collections() { + + # backup collection packages + while read COLL_VERSION; do + COLL_NAME=$(echo $COLL_VERSION | cut -d "-" -f 1) + COLL_RELEASE=$(echo $COLL_VERSION | cut -d "-" -f 2) + + if [ -f ${DEST_SYS}/${COLL_VERSION}.tar ]; then + rm ${DEST_SYS}/${COLL_VERSION}.tar + fi + + while read PORT_NAME; do + # get installed version not version on ports + PACKAGE=$(grep "^${PORT_NAME}#" ${all}) + + # check if binary package exist + if [ ! -f /usr/ports/packages/${PACKAGE} ]; then + echo "Building package: ${PACKAGE};" + sudo prt-get update ${PRT_GET_FLAGS} ${PORT_NAME} + fi + + if [ -f /usr/ports/packages/${PACKAGE} ]; then + echo ${PACKAGE} >> ${DEST_SYS}/metadata/${COLL_NAME}-backup + tar rvf ${DEST_SYS}/${COLL_VERSION}.tar --directory=${PACKAGES} ${PACKAGE} + else + echo "Package ${PACKAGE} from ${PORT_NAME} port not found." + echo ${PACKAGE} >> ${notfound}-${COLL_VERSION} + fi + done < ${collinst}-${COLL_NAME} + + tar rvf $archive --directory=${DEST_SYS} ${COLL_VERSION}.tar + + done < ${portsver} +} + +create_metadata() { + + echo "${BUILD_NAME}-${BUILD_VERSION}" > ${build} + + # archive pkgutils data + tar --xattrs -zcpf $database --directory=/var/lib/pkg/ db + tar rvf $archive --directory=${DEST_SYS} $(basename ${database}) + + # archive ports data + tar --xattrs -zcpf $ports --directory=/etc/ports . + tar rvf $archive --directory=${DEST_SYS} $(basename ${ports}) + + # must be using gwak instead of sed + prt-get listinst -v | sed 's/ /#/g' | sed 's/$/.pkg.tar.gz/g' > ${all} + + if [ -f ${portsver} ]; then + rm ${portsver} + fi + + for filename in /etc/ports/*.git; do + source $filename + + echo "${NAME} port collection release (exp; ${BUILD_VERSION}):" + + read RELEASE + echo ${NAME}-${RELEASE} >> ${portsver} + + # backup ports collection + echo "Backing up collection: ${NAME}" + tar --xattrs -zcpf ${DEST_SYS}/"ports"-${NAME}-${RELEASE}.tar.gz \ + --directory=/usr/ports/${NAME} \ + --exclude=.git \ + . + + tar rvf $archive --directory=${DEST_SYS} "ports"-${NAME}-${RELEASE}.tar.gz + + # create list of installed packages + prt-get printf "%i %p %n\n" | grep "yes /usr/ports/${NAME}" | cut -d " " -f 3 > ${collinst}-${NAME} + +done +} + +create_archive() { + tar --xattrs -zcpf ${metadata} --directory=${DEST_SYS} metadata/ + tar rvf $archive --directory=${DEST_SYS} $(basename ${metadata}) +} + +update_host() { + echo "Creating links to /usr/ports/installed" + rm -r /usr/ports/installed + pkg_installed + + echo "Creating ports page" + portspage --title=${BUILD_NAME}-${BUILD_VERSION} /usr/ports/installed > /usr/ports/installed/index.html +} + +create_metadata +backup_collections +create_archive +update_host diff --git a/linux/scripts/backup-system.sh b/linux/scripts/backup-system.sh new file mode 100644 index 0000000..22fe588 --- /dev/null +++ b/linux/scripts/backup-system.sh @@ -0,0 +1,194 @@ +#!/bin/bash + +ROOT_DIR= +DEST_DIR=/root/backup +DEST_SYS="${DEST_DIR}/system" +DATA_CNF="${DEST_DIR}/conf" +DATA_USR="${DEST_DIR}/user" +DATA_SRV="${DEST_DIR}/srv" + +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 ..." +} + +print_data () { + echo "ROOT_DIR=${ROOT_DIR}" + echo "DEST_DIR=${DEST_DIR}" + echo "DEST_SYS=${DEST_SYS}" + echo "DATA_CNF=${DATA_CNF}" + echo "DATA_USR=${DATA_USR}" + echo "DATA_SRV=${DATA_SRV}" +} + +print_help() { + echo "usage: backup-system [options]" + echo "options:" + echo " -r, --root root directory to backup, default /" + echo " -d, --destination save backup, default /root/backup" + echo " -h, --help print help and exit" +} + +while [ "$1" ]; do + case $1 in + -r|--root) + ROOT_DIR=$2 + if [ ${ROOT_DIR} == "/" ]; then + ROOT_DIR="" + fi + shift ;; + -d|--destination) + DEST_DIR=$2 + + # Destination directory + DEST_SYS="${DEST_DIR}/system" + DATA_CNF="${DEST_DIR}/conf" + DATA_USR="${DEST_DIR}/user" + DATA_SRV="${DEST_DIR}/srv" + + shift ;; + -h|--help) + print_help + exit 0 ;; + *) + echo "backup-system: invalid option $1" + print_help + exit 1 ;; + esac + shift +done + +print_data +ConfirmOrExit + +mkdir -p ${DATA_CNF} +mkdir -p ${DATA_USR} +mkdir -p ${DATA_SRV} + +# Backup system settings +tar --xattrs -zcpf $DATA_CNF/etc.tar.gz \ + --directory=$ROOT_DIR/etc \ + . + +tar --xattrs -zcpf $DATA_CNF/usr_etc.tar.gz \ + --directory=$ROOT_DIR/usr/etc \ + . + +bacup_home_metadata () { +# User Meta Data + + for dir in /home/*; do + if [ "${dir}" != "/home/lost+found" ]; then + user=$(basename $dir) + tar --xattrs -zcpf "${DATA_USR}/meta-${user}.tar.gz" \ + $dir/.bash_profile \ + $dir/.bashrc \ + $dir/.config \ + $dir/.gitconfig \ + $dir/.gnupg \ + $dir/.irssi \ + $dir/.lynxrc \ + $dir/.mutt \ + $dir/.netrc \ + $dir/.profile \ + $dir/.spectrwm.conf \ + $dir/.ssh \ + $dir/.tmux.conf \ + $dir/.vim \ + $dir/.vimrc \ + $dir/.xinitrc + + # encript data + #gpg --output "${DATA_USR}/meta-${user}.tar.gz.gpg" \ + # --encrypt --recipient user@host \ + # "${DATA_USR}/meta-${user}.tar.gz" + + tar --xattrs -zcpf "${DATA_USR}/gitolite-${user}.tar.gz" \ + $dir/gitolite-admin + fi + done +} + +backup_services () { + # backup web data first stop php and nginx + for pkg_www in ${ROOT_DIR}/srv/www/*; do + if [[ ! $(ls ${pkg_www} | grep -v "backup_deploy") = "" ]]; then + pkg_back="${DATA_SRV}/www" + if [ ! -d ${pkg_back} ]; then + mkdir -p ${pkg_back} + fi + bck_file="${pkg_back}/$(basename ${pkg_www}).tar.gz" + exc="${pkg_www}/backup_deploy" + tar --exclude ${exc} --xattrs -zcpf ${bck_file} ${pkg_www} + fi + done + + # backup database data first dump all databases + pkg_back="${DATA_SRV}/pgsql" + if [ ! -d ${pkg_back} ]; then + mkdir -p ${pkg_back} + fi + pg_dumpall -U postgres | gzip > ${pkg_back}/cluster_dump.gz + + tar --xattrs -zcpf "${pkg_back}/pgsql-conf.tar.gz" \ + ${ROOT_DIR}/srv/pgsql/data/pg_hba.conf \ + ${ROOT_DIR}/srv/pgsql/data/pg_ident.conf \ + ${ROOT_DIR}/srv/pgsql/data/postgresql.conf + + + # backup gitolite repositories + pkg_back="${DATA_SRV}/gitolite" + if [ ! -d ${pkg_back} ]; then + mkdir -p ${pkg_back} + fi + + tar --xattrs -zcpf "${pkg_back}/gitolite.tar.gz" \ + --directory=${ROOT_DIR}/srv/gitolite \ + . +} + +while true +do + echo "Backup User Metadata ?" + echo "Please confirm (y or n): " + read CONFIRM + case $CONFIRM in + n|N|no|NO|No) break ;; + y|Y|YES|yes|Yes) + echo "Accept - you entered $CONFIRM" + bacup_home_metadata + break + ;; + *) echo "Please enter only y or n" + esac +done + +# Server Data +while true +do + echo "Backup Server Data ?" + echo "Please confirm (y or n): " + read CONFIRM + case $CONFIRM in + n|N|no|NO|No) break ;; + y|Y|YES|yes|Yes) + echo "Accept - you entered $CONFIRM" + backup_services + break + ;; + *) echo "Please enter only y or n" + esac +done diff --git a/linux/scripts/chroot.sh b/linux/scripts/chroot.sh new file mode 100644 index 0000000..00fbd78 --- /dev/null +++ b/linux/scripts/chroot.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +CHROOT=/mnt + +chroot $CHROOT /usr/bin/env -i \ + HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \ + PATH=/bin:/usr/bin:/sbin:/usr/sbin \ + /bin/bash --login + diff --git a/linux/scripts/install-core.sh b/linux/scripts/install-core.sh new file mode 100644 index 0000000..078aa3b --- /dev/null +++ b/linux/scripts/install-core.sh @@ -0,0 +1,179 @@ +#!/bin/bash + +CHROOT="/mnt" +PORT_PKG="${CHROOT}/media/crux" +INSTALL_OPT=0 + +#echo "1.1.8. Install Handbook\n" +#cp ${PORT_PKG}/handbook.txt $CHROOT/root/ + +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 ..." +} + + +install_core() { + + mkdir -p ${CHROOT}/var/lib/pkg + touch ${CHROOT}/var/lib/pkg/db + + CORE_LS="${DATA_DIR}/core.pkg" + + if [ ! -f ${CORE_LS} ]; then + CORE_LS=${CHROOT}/core.pkg + echo "1.1.4 Create core.pkg and install pkgadd" + for p in ${PORT_PKG}/core/*; + do + echo $(basename $p) >> ${CORE_LS}; + done + fi + + # it is required a degree in astrophysics in order to figure out how to extract a file to a target folder + bsdtar -C ${CHROOT} -xf "${PORT_PKG}/core/pkgutils#5.40.7-1.pkg.tar.xz" usr/bin/pkgadd + mv ${CHROOT}/usr/bin/pkgadd ${CHROOT} + chmod +x ${CHROOT}/pkgadd + + echo "1.1.4 File core.pkg complete, review list of packages before continue... [PRESS ENTER]" + read PAUSE + vim ${CORE_LS} + + echo "1.1.4 Starting install" + + #cd $CHROOT + while read line; do + pkg=${PORT_PKG}/core/${line} + echo "Installing ${pkg}" + #${CHROOT}/pkgadd -f -r ${CHROOT} ${pkg} + ${CHROOT}/pkgadd -f -r ${CHROOT} ${pkg} + done < ${CORE_LS} + + rm ${CHROOT}/pkgadd + + if [ -f ${CHROOT}/core.pkg ]; then + rm ${CHROOT}/core.pkg; + fi +} + +install_packages() { + echo "Installing ${PORT_PKG}/opt/fakeroot" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/fakeroot#* + echo "Installing ${PORT_PKG}/opt/dbus" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/dbus#* + echo "Installing ${PORT_PKG}/opt/expat" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/expat#* + echo "Installing ${PORT_PKG}/opt/libnl" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/libnl#* + echo "Installing ${PORT_PKG}/opt/libpng" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/libpng#* + echo "Installing ${PORT_PKG}/opt/freetype" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/freetype#* + echo "Installing ${PORT_PKG}/opt/libffi" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/libffi#* + echo "Installing ${PORT_PKG}/opt/sqlite3" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/sqlite3#* + echo "Installing ${PORT_PKG}/opt/python" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/python#* + echo "Installing ${PORT_PKG}/opt/glib" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/glib#* + echo "Installing ${PORT_PKG}/opt/grub2" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/grub2#* + echo "Installing ${PORT_PKG}/opt/grub2-efi" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/grub2-efi#* + echo "Installing ${PORT_PKG}/opt/wireless-tools" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/wireless-tools#* + echo "Installing ${PORT_PKG}/opt/wpa_supplicant" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/wpa_supplicant#* + echo "Installing ${PORT_PKG}/opt/lvm2" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/lvm2#* + echo "Installing ${PORT_PKG}/opt/mdadm" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/mdadm#* + echo "Installing ${PORT_PKG}/opt/efivar" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/efivar#* + echo "Installing ${PORT_PKG}/opt/efibootmgr" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/efibootmgr#* + echo "Installing ${PORT_PKG}/opt/dosfstools" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/dosfstools#* + echo "Installing ${PORT_PKG}/opt/parted" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/parted#* + echo "Installing ${PORT_PKG}/opt/libgcrypt" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/libgcrypt#* + echo "Installing ${PORT_PKG}/opt/cryptsetup" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/cryptsetup#* + echo "Installing ${PORT_PKG}/opt/popt" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/popt#* + echo "Installing ${PORT_PKG}/opt/libgpg-error" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/libgpg-error#* + echo "Installing ${PORT_PKG}/opt/libevent" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/libevent#* + echo "Installing ${PORT_PKG}/opt/libtirpc" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/libtirpc#* + echo "Installing ${PORT_PKG}/opt/git" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/git#* + echo "Installing ${PORT_PKG}/opt/tmux" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/tmux#* + echo "Installing ${PORT_PKG}/opt/prt-utils" + $CHROOT/usr/bin/pkgadd -f -r $CHROOT ${PORT_PKG}/opt/prt-utils#* +} + +print_data() { + echo "1.1.4 Paths to packages and target:" + echo "chroot: ${CHROOT}" + echo "packages dir: ${PORT_PKG}" + echo "install optional: ${INSTALL_OPT}" +} + +print_help() { + echo "usage: install-core [options]" + echo "options:" + echo " -r, --chroot default chroot is /mnt" + echo " -p, --packages packages directory /mnt/media/crux" + echo " -o, --optional install extra packages" + echo " -h, --help print help and exit" +} + +while [ "$1" ]; do + case $1 in + -r|--chroot) + CHROOT=$2 + shift ;; + -p|--packages) + PORT_PKG=$2 + shift ;; + -o|--optional) + INSTALL_OPT=1 + ;; + -h|--help) + print_help + exit 0 ;; + *) + echo "setup-iso: invalid option $1" + print_help + exit 1 ;; + esac + shift +done + +print_data +ConfirmOrExit +install_core +echo "=========[ core installed ]===========" + +if [[ $INSTALL_OPT -eq 1 ]]; +then + install_packages + echo "=========[ extra packages installed ]===========" +fi diff --git a/linux/scripts/portspage.patch b/linux/scripts/portspage.patch new file mode 100644 index 0000000..94e653a --- /dev/null +++ b/linux/scripts/portspage.patch @@ -0,0 +1,27 @@ +220c220 +< print "

$options{title}

\n"; +--- +> print "

Mirror | Crux | Git | Build errors | Distfiles | $options{title}.tar.gz | Archive

\n"; +233c233,238 +< print " PortVersionDescription"; +--- +> print " +> Project page +> Port +> Package +> Description"; +> +244,248c249,255 +< print " "; +< $db{$port}{URL} ? print "$port" : print "$port"; +< print "$db{$port}{version}-$db{$port}{release}"; +< print $db{$port}{Description} if $db{$port}{Description}; +< print ""; +--- +> my $port_collection=`prt-get info $port | grep "Path:" | cut -d ":" -f 2 | xargs basename`; +> print " "; +> $db{$port}{URL} ? print "$port" : print "$port"; +> #print "$db{$port}{version}-$db{$port}{release}"; +> print "$db{$port}{version}-$db{$port}{release}"; +> print "$port#$db{$port}{version}-$db{$port}{release}.pkg.tar.gz"; +> print "$db{$port}{Description}" if $db{$port}{Description}; diff --git a/linux/scripts/restore-ports.sh b/linux/scripts/restore-ports.sh new file mode 100644 index 0000000..cf886ab --- /dev/null +++ b/linux/scripts/restore-ports.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +BUILD_NAME=R1D9 +BUILD_VERSION=3.4.1 +WORK_DIR=/usr/ports/work/${BUILD_NAME}-${BUILD_VERSION} + +prepare_archive() { + mkdir -p ${WORK_DIR} + wget --directory-prefix=${WORK_DIR} https://tribu.semdestino.org/mirror/releases/archives/${BUILD_NAME}-${BUILD_VERSION}.tar.gz + echo "extracting ${WORK_DIR}/${BUILD_NAME}-${BUILD_VERSION}.tar.gz..." + tar -C ${WORK_DIR} -xf ${WORK_DIR}/${BUILD_NAME}-${BUILD_VERSION}.tar.gz + rm ${WORK_DIR}/${BUILD_NAME}-${BUILD_VERSION}.tar.gz +} + +extract_archives() { + while read COLL_VERSION; do + COLL_NAME=$(echo $COLL_VERSION | cut -d "-" -f 1) + COLL_RELEASE=$(echo $COLL_VERSION | cut -d "-" -f 2) + echo "extracting ${COLL_VERSION}.tar to /usr/ports/packages" + tar -C /usr/ports/packages -xf ${WORK_DIR}/${COLL_VERSION}.tar + rm ${WORK_DIR}/${COLL_VERSION}.tar + done < ${WORK_DIR}/metadata/ports-releases +} + +update_system() { + mkdir -p ${WORK_DIR}/etc/ports + tar -C ${WORK_DIR}/etc/ports -xf ${WORK_DIR}/etc_ports.tar.gz + cp ${WORK_DIR}/etc/ports/*.git /etc/ports/ + + while read COLL_VERSION; do + COLL_NAME=$(echo $COLL_VERSION | cut -d "-" -f 1) + ports -u $COLL_NAME + done < ${WORK_DIR}/metadata/ports-releases + + # first update with prt-get + prt-get sysup + prt-get --pre-install --post-install update $(prt-get listinst) + prt-get depinst $(prt-get printf "%p %n\n" | grep "/usr/ports/core" | cut -d " " -f 2) + prt-get update $(revdep) + + rejmerge +} + +install_distro() { + while read PACKAGE; do + prt-get depinst $(echo $PACKAGE | cut -d "#" -f 1); + done < ${WORK_DIR}/all-installed.pkg +} + +prepare_archive +extract_archives +update_system +install_distro diff --git a/linux/scripts/setup-core.sh b/linux/scripts/setup-core.sh new file mode 100644 index 0000000..45bce87 --- /dev/null +++ b/linux/scripts/setup-core.sh @@ -0,0 +1,154 @@ +#!/bin/bash + +# Absolute path to this script, +# e.g. /home/user/doc/core/scripts/foo.sh +SCRIPT=$(readlink -f "$0") +# Absolute path this script is in, +# e.g. /home/user/doc/core/scripts +SCRIPTPATH=$(dirname "$SCRIPT") +# Absolute path to doc section, +# e.g /home/user/doc/core +DIR_DATA=$(dirname "$SCRIPTPATH"); + +CHROOT="/mnt" +DATA_CNF="${DIR_DATA}/conf" +ADMIN_USER="machine-admin" + +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 ..." +} + +setup_core() { + + echo "1.1. Copying configuration data;\n" + if [ -f "${DATA_CNF}/etc.tar.gz" ]; then + echo "1.1. Extracting configuration data;\n" + tar --xattrs -xpvf $DATA_CNF/etc.tar.gz --directory=$CHROOT/etc + tar --xattrs -xpvf $DATA_CNF/usr_etc.tar.gz --directory=$CHROOT/usr/etc + else + echo "1.1.7. dns resolver, copy resolv.conf;\n" + cp /etc/resolv.conf $CHROOT/etc + + echo "1.1.9. Install Skeletons\n" + cp -r $DATA_CNF/skel $CHROOT/etc/ + + cp $DATA_CNF/sudoers $CHROOT/etc/ + + echo "1.2.1. Set hostname and hosts;" + cp $DATA_CNF/hosts $CHROOT/etc/ + + echo "1.2.5. File system table;" + cp $DATA_CNF/fstab $CHROOT/etc/ + chroot $CHROOT /bin/bash -c "mount >> /etc/fstab" + + echo "1.2.6. Initialization Scripts;" + cp $DATA_CNF/rc.d/* $CHROOT/etc/rc.d/ + cp $DATA_CNF/rc.conf $CHROOT/etc/ + + echo "1.3 Install Ports;" + rm -fr $CHROOT/etc/ports + cp -r $DATA_CNF/ports $CHROOT/etc/ports + cp $DATA_CNF/ports.conf $CHROOT/etc/ports.conf + + echo "1.3.3 Configure pkgmk;" + cp $DATA_CNF/pkgmk.conf $CHROOT/etc/pkgmk.conf + cp $DATA_CNF/pkgmk.conf.harden $CHROOT/etc/pkgmk.conf.harden + + echo "1.3.4 Configure prt-get;" + cp $DATA_CNF/prt-get.conf $CHROOT/etc/ + + fi + + echo "1.2.2. Set timezone;" + chroot $CHROOT /bin/bash -c tzselect + + echo "1.2.3. Set locale;" + chroot $CHROOT /bin/bash -c "localedef -i en_US -f UTF-8 en_US.UTF-8" +} + +setup_users(){ + echo "1.2.4.2. Create Administrator $ADMIN_USER;" + + chroot $CHROOT /usr/bin/env -i \ + HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \ + PATH=/bin:/usr/bin:/sbin:/usr/sbin \ + /bin/bash -c "useradd -U -m -k /etc/skel -s /bin/bash $ADMIN_USER" + + echo "1.2.4.3. Add Administrator $ADMIN_USER to wheel group;" + chroot $CHROOT /bin/bash -c "usermod -a -G wheel $ADMIN_USER" + echo "1.2.4.3. Uncomment to allow members of group wheel to execute any command\n + # %wheel ALL=(ALL) ALL" + + echo "1.3.1. Ports Layout;" + + chroot --userspec=pkgmk:pkgmk $CHROOT /bin/bash -c "mkdir /usr/ports/{work,distfiles,packages,work,pkgbuild}" + + echo "1.3.2. Build as unprivileged user;" + + + chroot $CHROOT /usr/bin/env -i \ + HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \ + PATH=/bin:/usr/bin:/sbin:/usr/sbin \ + /bin/bash -c "useradd -U -M -d /usr/ports -s /bin/false pkgmk" + + chroot $CHROOT /usr/bin/env -i \ + HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \ + PATH=/bin:/usr/bin:/sbin:/usr/sbin \ + /bin/bash -c "usermod -a -G pkgmk $ADMIN_USER" + + chroot $CHROOT /usr/bin/env -i \ + HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \ + PATH=/bin:/usr/bin:/sbin:/usr/sbin \ + /bin/bash -c "chown pkgmk /usr/ports/{distfiles,packages,work,pkgbuild}" + + chroot $CHROOT /usr/bin/env -i \ + HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \ + PATH=/bin:/usr/bin:/sbin:/usr/sbin \ + /bin/bash -c "chown pkgmk:pkgmk /usr/ports/pkgbuild" + + chroot $CHROOT /usr/bin/env -i \ + HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \ + PATH=/bin:/usr/bin:/sbin:/usr/sbin \ + /bin/bash -c "chmod g+w /usr/ports/pkgbuild" + + PKGMK_WRK="pkgmk /usr/ports/work tmpfs size=30G,gid=$(id -g pkgmk),uid=$(id -u pkgmk),defaults,mode=0750 0 0 >> /etc/fstab" + + chroot $CHROOT /usr/bin/env -i \ + HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \ + PATH=/bin:/usr/bin:/sbin:/usr/sbin \ + /bin/bash -c "echo ${PKGMK_WRK} >> /etc/fstab" +} + +setup_config(){ + vim $CHROOT/etc/rc.conf + vim $CHROOT/etc/hosts + vim $CHROOT/etc/resolv.conf + vim $CHROOT/etc/fstab + + vim $CHROOT/etc/pkgmk.conf + vim $CHROOT/etc/prt-get.conf +} + +echo "ADMIN_USER=${ADMIN_USER}"; +echo "CHROOT=${CHROOT}"; +echo "DATA_CNF=${DATA_CNF}"; + +ConfirmOrExit + +setup_core +setup_users +setup_config diff --git a/linux/scripts/setup-iso.sh b/linux/scripts/setup-iso.sh new file mode 100644 index 0000000..458284d --- /dev/null +++ b/linux/scripts/setup-iso.sh @@ -0,0 +1,144 @@ +#!/bin/sh + +# location of iso and md5 file +ISO_DIR="/usr/ports/iso" +MOUNT_POINT="/mnt/media" + +ISO_FILE="${ISO_DIR}/crux-3.5.iso" +MD5_FILE="${ISO_DIR}/crux-3.5.md5" + +# iso and md5 remote location +#ISO_URL="https://serverop.de/crux/crux-3.5/iso/crux-3.5.iso" +ISO_URL="https://ftp.spline.inf.fu-berlin.de/pub/crux/crux-3.5/iso/crux-3.5.iso" +MD5_URL="https://serverop.de/crux/crux-3.5/iso/crux-3.5.md5" + +# 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 ..." +} + +download_iso() { + + mkdir -p ${ISO_DIR} + + if [ -f $ISO_FILE ]; + then + echo "File $ISO_FILE exists." + else + echo "File $ISO_FILE does not exist." + cd $ISO_DIR && { curl -k -O $ISO_URL ; cd -; } + fi + + if [ -f $MD5_FILE ]; + then + echo "File ${MD5_FILE} exists." + else + echo "File ${MD5_FILE} does not exist." + cd ${ISO_DIR} && { curl -k -O ${MD5_URL} ; cd -; } + fi + +} + +check_iso() { + if cd ${ISO_DIR} && md5sum -c ${MD5_FILE} ; + then + echo "Valid iso md5sum" + else + echo "Invalid iso md5sum" + fi +} + +mount_iso() { + + if [ ! -f $ISO_FILE ]; + then + echo "File $ISO_FILE does not exist." + exit 0 + fi + + modprobe isofs + modprobe loop + mount -o loop $ISO_FILE $MOUNT_POINT +} + +print_data() { + echo "1.1.1 Paths to iso and md5 files:" + echo "iso dir: ${ISO_DIR}" + echo "iso file: ${ISO_FILE}" + echo "md5 file: ${MD5_FILE}" + echo "iso url: ${ISO_URL}" + echo "md5 url: ${MD5_URL}" + echo "mount point: ${MOUNT_POINT}" +} + +print_help() { + echo "usage: setup-iso [options]" + echo "options:" + echo " -r, --root default dir is /usr/ports/iso" + echo " -d, --download download iso" + echo " -c, --check check iso md5sum" + echo " -m, --mount mount iso on /media " + echo " -h, --help print help and exit" +} + +while [ "$1" ]; do + case $1 in + -r|--root) + ISO_DIR=$2 + + ISO_FILE="${ISO_DIR}/crux-3.5.iso" + MD5_FILE="${ISO_DIR}/crux-3.5.md5" + + shift ;; + -d|--download) + echo "Download iso:" + echo "_____________________" + print_data + ConfirmOrExit + download_iso + exit 0 ;; + -c|--check) + echo "Check iso md5sum:" + echo "_____________________" + print_data + ConfirmOrExit + check_iso + exit 0 ;; + -m|--mount) + echo "Check iso md5sum:" + echo "_____________________" + if [ ! -z "$2" ]; + then + MOUNT_POINT=$2 + fi + print_data + ConfirmOrExit + mount_iso + exit 0 ;; + -h|--help) + print_help + exit 0 ;; + *) + echo "setup-iso: invalid option $1" + print_help + exit 1 ;; + esac + shift +done + +echo "setup-iso: no option provided" +print_help +exit 1 diff --git a/linux/scripts/setup-target.sh b/linux/scripts/setup-target.sh new file mode 100755 index 0000000..69b8640 --- /dev/null +++ b/linux/scripts/setup-target.sh @@ -0,0 +1,224 @@ +#!/bin/sh + +DEV=/dev/sda +VG=vg_system + +SETUP_TARGET="print" +CHROOT="/mnt" + +# 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_LOCAL="$(dirname $(dirname ${DIR}))/local"; + +##read BLK_EFI +BLK_EFI="${DEV}2" +##read BLK_BOOT +BLK_BOOT="${DEV}3" +##read BLK_ROOT +BLK_CRYPT="${DEV}4" +BLK_ROOT="/dev/$VG/lv_root" +##read BLK_VAR +BLK_VAR="/dev/${VG}/lv_var" +##read BLK_USR +#BLK_USR="${DEV}6" +##read BLK_SWP +BLK_SWP="/dev/${VG}/lv_swap" +##read BLK_HOME +BLK_HOME="/dev/${VG}/lv_home" + + +# 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 ..." +} + + +partition_target () { + + parted --script $DEV \ + mklabel gpt \ + unit mib \ + mkpart primary 1 3 \ + name 1 grub \ + set 1 bios_grub on \ + mkpart ESP fat32 3 125 \ + name 2 efi \ + set 2 boot on \ + mkpart primary ext4 125 1128 \ + name 3 boot \ + mkpart primary 1128 100% \ + set 4 lvm on + + modprobe dm-crypt + cryptsetup luksFormat ${BLK_CRYPT} + cryptsetup luksOpen ${BLK_CRYPT} cryptlvm + + pvcreate /dev/mapper/cryptlvm + vgcreate ${VG} /dev/mapper/cryptlvm + + lvcreate -L 20G -n lv_root ${VG} + lvcreate -L 4G -n lv_var ${VG} + lvcreate -L 8G -n lv_swap ${VG} + lvcreate -L 120G -n lv_home ${VG} + +} + +mount_target () { + echo "1.1.2 Creating File System on $BLK_EFI with fat32:" + mkfs.fat -F 32 $BLK_EFI + echo "1.1.2 Creating File System on $BLK_BOOT with ext4:" + mkfs.ext4 $BLK_BOOT + echo "1.1.2 Creating File System on $BLK_ROOT with ext4:" + mkfs.ext4 $BLK_ROOT + echo "1.1.2 Creating File System on $BLK_VAR with ext4:" + mkfs.ext4 $BLK_VAR + #echo "1.1.2 Creating File System on $BLK_USR with ext4:" + #mkfs.ext4 $BLK_USR + echo "1.1.2 Creating Swap File System on $BLK_SWP:" + mkswap $BLK_SWP + echo "1.1.2 Creating File System on $BLK_HOME with ext4:" + mkfs.ext4 $BLK_HOME + + echo "1.1.3 mount point to chroot (/mnt):\n" + mount $BLK_ROOT $CHROOT + + mkdir -p $CHROOT/boot + mount $BLK_BOOT $CHROOT/boot + + mkdir -p $CHROOT/boot/efi + mount $BLK_EFI $CHROOT/boot/efi + + mkdir -p $CHROOT/var + mount $BLK_VAR $CHROOT/var + + #mkdir -p $CHROOT/usr + #mount $BLK_USR $CHROOT/usr + + mkdir -p $CHROOT/home + mount $BLK_HOME $CHROOT/home + + mkdir -p $CHROOT/var/lib/pkg + mkdir -p $CHROOT/usr/ports + + mkdir -p $CHROOT/media + + mkdir -p $CHROOT/dev + mkdir -p $CHROOT/tmp + mkdir -p $CHROOT/proc + mkdir -p $CHROOT/sys + +} + +directory_target () { + + mkdir -p $CHROOT/home + mkdir -p $CHROOT/boot/efi + mkdir -p $CHROOT/var/lib/pkg + mkdir -p $CHROOT/usr/ports + + mkdir -p $CHROOT/media + + mkdir -p $CHROOT/dev + mkdir -p $CHROOT/tmp + mkdir -p $CHROOT/proc + mkdir -p $CHROOT/sys + +} + + +enable_target () { + + mount --bind /dev $CHROOT/dev + mount -vt devpts devpts $CHROOT/dev/pts + mount -vt tmpfs shm $CHROOT/dev/shm + mount -vt proc proc $CHROOT/proc + mount -vt sysfs sysfs $CHROOT/sys + +} + +print_target() { + echo "Device: $DEV" + echo "CHROOT: $CHROOT" + echo "Option Selected: $SETUP_TARGET" + + echo "1.1.2 EFI block; ($BLK_EFI)" + echo "1.1.2 boot block; ($BLK_BOOT)" + echo "1.1.2 cryptlvm block; ($BLK_CRYPT)" + echo "1.1.2 root block; ($BLK_ROOT)" + echo "1.1.2 var block; ($BLK_VAR)" + echo "1.1.2 usr block; ($BLK_USR)" + echo "1.1.2 swap block; ($BLK_SWP)" + echo "1.1.2 home block; ($BLK_HOME)" + + +} + +print_help() { + echo "usage: setup_target [options]" + echo "options:" + echo " -p, --partition create partitions and file systems" + echo " -m, --mount mount partitions on chroot" + echo " -d, --directory keep temporary working directory" + echo " -e, --enable enable chroot (proc,dev, sys...)" + echo " -v, --view view environment vars and exit" + echo " -h, --help print help and exit" +} + + +while [ "$1" ]; do + case $1 in + -p|--partition) + SETUP_TARGET="partition" + print_target + ConfirmOrExit + partition_target + exit 0 ;; + -m|--mount) + SETUP_TARGET="mount" + print_target + ConfirmOrExit + mount_target + exit 0 ;; + -d|--directory) + SETUP_TARGET="directory" + print_target + ConfirmOrExit + directory_target + exit 0 ;; + -e|--enable) + SETUP_TARGET="enable" + print_target + ConfirmOrExit + enable_target + exit 0 ;; + -v|--view) + SETUP_TARGET="view" + print_target + exit 0 ;; + -h|--help) + print_help + exit 0 ;; + *) + echo "setup-target: invalid option $1" + exit 1 ;; + esac + shift +done diff --git a/linux/scripts/setup-virtual.sh b/linux/scripts/setup-virtual.sh new file mode 100644 index 0000000..3583bb6 --- /dev/null +++ b/linux/scripts/setup-virtual.sh @@ -0,0 +1,78 @@ +#!/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 ..." +} + +DEV_NAME=${1} +IMG=${2}.qcow2 +SIZE=${3} +CHROOT="/mnt" +DEV="/dev/${DEV_NAME}" + +echo "/srv/qemu/img/${IMG}" +echo "${SIZE}" +echo "DEV_NAME=${DEV_NAME}" +echo "DEV=${DEV}" +echo "CHROOT=${CHROOT}" + +ConfirmOrExit + +#qemu-img create -f qcow2 example.qcow2 20G +qemu-img create -f qcow2 /srv/qemu/img/${IMG} ${SIZE} +qemu-nbd -c ${DEV} /srv/qemu/img/${IMG} + +parted --script ${DEV} \ + mklabel gpt \ + unit mib \ + mkpart primary 2 4 \ + name 1 grub \ + mkpart ESP fat32 4 128 \ + name 2 efi \ + mkpart primary ext4 128 1128 \ + name 3 boot \ + mkpart primary ext4 1128 12128 \ + name 4 root \ + mkpart primary ext4 12128 14128 \ + name 5 var \ + mkpart primary ext4 14128 100% \ + name 6 lvm \ + set 1 bios_grub on \ + set 2 boot on \ + set 6 lvm on + +kpartx -a -s -l -u ${DEV} + +mkfs.fat -F 32 /dev/mapper/${DEV_NAME}p2 +mkfs.ext4 /dev/mapper/${DEV_NAME}p3 +mkfs.ext4 /dev/mapper/${DEV_NAME}p4 +mkfs.ext4 /dev/mapper/${DEV_NAME}p5 +pvcreate /dev/mapper/${DEV_NAME}p6 + +mount /dev/mapper/${DEV_NAME}p4 $CHROOT +mkdir -p $CHROOT/proc +mkdir -p $CHROOT/sys +mkdir -p $CHROOT/dev +mkdir -p $CHROOT/media + +mkdir -p $CHROOT/boot +mount /dev/mapper/${DEV_NAME}p3 $CHROOT/boot +mkdir -p $CHROOT/boot/efi +mount /dev/mapper/${DEV_NAME}p2 $CHROOT/boot/efi +mkdir -p $CHROOT/var +mount /dev/mapper/${DEV_NAME}p5 $CHROOT/var -- cgit From 2a862d9141a84b612ec2dd109a7f74a2b10ffb91 Mon Sep 17 00:00:00 2001 From: builder Date: Fri, 26 Feb 2021 00:18:20 +0000 Subject: tools scripts moved to linux --- linux/scripts/mirror-system | 73 +++++++++++++++++++++++++++++ linux/scripts/pkgmk-test.conf | 19 ++++++++ linux/scripts/pkgmk-test.sh | 5 ++ linux/scripts/replace.sh | 9 ++++ linux/scripts/runvm/c12-dvd | 15 ++++++ linux/scripts/runvm/profile/crux | 7 +++ linux/scripts/runvm/runvm.sh | 26 +++++++++++ linux/scripts/setup-gitolite.sh | 43 ++++++++++++++++++ linux/scripts/setup-nginx.sh | 24 ++++++++++ linux/scripts/setup-openssh.sh | 43 ++++++++++++++++++ linux/scripts/setup-php.sh | 7 +++ linux/scripts/setup-postgresql.sh | 87 +++++++++++++++++++++++++++++++++++ linux/scripts/setup-x.sh | 96 +++++++++++++++++++++++++++++++++++++++ tools/scripts/mirror-system | 73 ----------------------------- tools/scripts/pkgmk-test.conf | 19 -------- tools/scripts/pkgmk-test.sh | 5 -- tools/scripts/replace.sh | 9 ---- tools/scripts/runvm/c12-dvd | 15 ------ tools/scripts/runvm/profile/crux | 7 --- tools/scripts/runvm/runvm.sh | 26 ----------- tools/scripts/setup-gitolite.sh | 43 ------------------ tools/scripts/setup-nginx.sh | 24 ---------- tools/scripts/setup-openssh.sh | 43 ------------------ tools/scripts/setup-php.sh | 7 --- tools/scripts/setup-postgresql.sh | 87 ----------------------------------- tools/scripts/setup-x.sh | 96 --------------------------------------- 26 files changed, 454 insertions(+), 454 deletions(-) create mode 100755 linux/scripts/mirror-system create mode 100644 linux/scripts/pkgmk-test.conf create mode 100644 linux/scripts/pkgmk-test.sh create mode 100755 linux/scripts/replace.sh create mode 100644 linux/scripts/runvm/c12-dvd create mode 100644 linux/scripts/runvm/profile/crux create mode 100644 linux/scripts/runvm/runvm.sh create mode 100644 linux/scripts/setup-gitolite.sh create mode 100644 linux/scripts/setup-nginx.sh create mode 100644 linux/scripts/setup-openssh.sh create mode 100644 linux/scripts/setup-php.sh create mode 100644 linux/scripts/setup-postgresql.sh create mode 100644 linux/scripts/setup-x.sh delete mode 100755 tools/scripts/mirror-system delete mode 100644 tools/scripts/pkgmk-test.conf delete mode 100644 tools/scripts/pkgmk-test.sh delete mode 100755 tools/scripts/replace.sh delete mode 100644 tools/scripts/runvm/c12-dvd delete mode 100644 tools/scripts/runvm/profile/crux delete mode 100644 tools/scripts/runvm/runvm.sh delete mode 100644 tools/scripts/setup-gitolite.sh delete mode 100644 tools/scripts/setup-nginx.sh delete mode 100644 tools/scripts/setup-openssh.sh delete mode 100644 tools/scripts/setup-php.sh delete mode 100644 tools/scripts/setup-postgresql.sh delete mode 100644 tools/scripts/setup-x.sh (limited to 'linux/scripts') 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/ + diff --git a/tools/scripts/mirror-system b/tools/scripts/mirror-system deleted file mode 100755 index 6c8a528..0000000 --- a/tools/scripts/mirror-system +++ /dev/null @@ -1,73 +0,0 @@ -#!/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/tools/scripts/pkgmk-test.conf b/tools/scripts/pkgmk-test.conf deleted file mode 100644 index 4a04eec..0000000 --- a/tools/scripts/pkgmk-test.conf +++ /dev/null @@ -1,19 +0,0 @@ -# -# /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/tools/scripts/pkgmk-test.sh b/tools/scripts/pkgmk-test.sh deleted file mode 100644 index 4cfe2c3..0000000 --- a/tools/scripts/pkgmk-test.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/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/tools/scripts/replace.sh b/tools/scripts/replace.sh deleted file mode 100755 index 8d5d8d9..0000000 --- a/tools/scripts/replace.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/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/tools/scripts/runvm/c12-dvd b/tools/scripts/runvm/c12-dvd deleted file mode 100644 index 9cbf201..0000000 --- a/tools/scripts/runvm/c12-dvd +++ /dev/null @@ -1,15 +0,0 @@ -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/tools/scripts/runvm/profile/crux b/tools/scripts/runvm/profile/crux deleted file mode 100644 index 672b80d..0000000 --- a/tools/scripts/runvm/profile/crux +++ /dev/null @@ -1,7 +0,0 @@ -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/tools/scripts/runvm/runvm.sh b/tools/scripts/runvm/runvm.sh deleted file mode 100644 index 21cd097..0000000 --- a/tools/scripts/runvm/runvm.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/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/tools/scripts/setup-gitolite.sh b/tools/scripts/setup-gitolite.sh deleted file mode 100644 index c42db14..0000000 --- a/tools/scripts/setup-gitolite.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/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/tools/scripts/setup-nginx.sh b/tools/scripts/setup-nginx.sh deleted file mode 100644 index 11065d2..0000000 --- a/tools/scripts/setup-nginx.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/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/tools/scripts/setup-openssh.sh b/tools/scripts/setup-openssh.sh deleted file mode 100644 index 14afe8b..0000000 --- a/tools/scripts/setup-openssh.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/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/tools/scripts/setup-php.sh b/tools/scripts/setup-php.sh deleted file mode 100644 index 4c28173..0000000 --- a/tools/scripts/setup-php.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/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/tools/scripts/setup-postgresql.sh b/tools/scripts/setup-postgresql.sh deleted file mode 100644 index 4e1ee3a..0000000 --- a/tools/scripts/setup-postgresql.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/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/tools/scripts/setup-x.sh b/tools/scripts/setup-x.sh deleted file mode 100644 index 262b4dd..0000000 --- a/tools/scripts/setup-x.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/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/ - -- cgit From 481f16b3d3f4a0b03ab3bb3b8d879b0c8ec25c04 Mon Sep 17 00:00:00 2001 From: Silvino Silva Date: Fri, 26 Feb 2021 19:48:39 +0000 Subject: fix install crux version --- linux/index.html | 6 +++--- linux/install.html | 14 +++++++------- linux/scripts/setup-iso.sh | 14 +++++++------- 3 files changed, 17 insertions(+), 17 deletions(-) (limited to 'linux/scripts') diff --git a/linux/index.html b/linux/index.html index 482730a..c9a130f 100644 --- a/linux/index.html +++ b/linux/index.html @@ -11,7 +11,7 @@

GNU/Linux

GNU/Linux covers installation and configuration of - basic functionality of Crux 3.5 Gnu\Linux operating system. + basic functionality of Crux 3.6 Gnu\Linux operating system. This documentation try's to follow Crux HandBook installation method diverges, for example, by only installing and documenting gpt and grub2.

@@ -21,10 +21,10 @@ folder the install process is automated and ports for extra ports used during the installation.

-

1. Install Crux 3.5 Gnu/Linux

+

1. Install Crux 3.6 Gnu/Linux

    -
  • 1.1. Install Crux 3.5 +
  • 1.1. Install Crux 3.6
    • 1.1.1. Download
    • 1.1.2. Prepare target
    • diff --git a/linux/install.html b/linux/install.html index f42f4a2..299027e 100644 --- a/linux/install.html +++ b/linux/install.html @@ -2,20 +2,20 @@ - 1.1. Install Crux 3.5 + 1.1. Install Crux 3.6 GNU/Linux Index -

      1.1. Install Crux 3.5

      +

      1.1. Install Crux 3.6

      -

      Installation of minimal Crux 3.5 Gnu\Linux system, +

      Installation of minimal Crux 3.6 Gnu\Linux system, with selected packages from core, opt and contrib ports. Process of installation documented can be executed from iso or from existing gnu\linux installation. Read - Hand book 3.5, + Hand book 3.6, .

      If you are booting from crux iso and is not your keyboard @@ -129,12 +129,12 @@

      Create encrypted block for lvm, partition layout of efi and bios boot systems is different.

      -

      On bios_boot systems partition should be 2;

      +

      On bios_boot systems partition should be 2 (sda4);

               (parted) set 4 lvm on
      -        # cryptsetup luksFormat /dev/sda2
      -        # cryptsetup luksOpen /dev/sda2 cryptlvm
      +        # cryptsetup luksFormat /dev/sda4
      +        # cryptsetup luksOpen /dev/sda4 cryptlvm
               

      Create physical group and volume group;

      diff --git a/linux/scripts/setup-iso.sh b/linux/scripts/setup-iso.sh index 458284d..19ac21f 100644 --- a/linux/scripts/setup-iso.sh +++ b/linux/scripts/setup-iso.sh @@ -4,13 +4,13 @@ ISO_DIR="/usr/ports/iso" MOUNT_POINT="/mnt/media" -ISO_FILE="${ISO_DIR}/crux-3.5.iso" -MD5_FILE="${ISO_DIR}/crux-3.5.md5" +ISO_FILE="${ISO_DIR}/crux-3.6.iso" +MD5_FILE="${ISO_DIR}/crux-3.6.md5" # iso and md5 remote location -#ISO_URL="https://serverop.de/crux/crux-3.5/iso/crux-3.5.iso" -ISO_URL="https://ftp.spline.inf.fu-berlin.de/pub/crux/crux-3.5/iso/crux-3.5.iso" -MD5_URL="https://serverop.de/crux/crux-3.5/iso/crux-3.5.md5" +#ISO_URL="https://serverop.de/crux/crux-3.6/iso/crux-3.6.iso" +ISO_URL="https://ftp.spline.inf.fu-berlin.de/pub/crux/crux-3.6/iso/crux-3.6.iso" +MD5_URL="https://serverop.de/crux/crux-3.6/iso/crux-3.6.md5" # First we define the function ConfirmOrExit () { @@ -99,8 +99,8 @@ while [ "$1" ]; do -r|--root) ISO_DIR=$2 - ISO_FILE="${ISO_DIR}/crux-3.5.iso" - MD5_FILE="${ISO_DIR}/crux-3.5.md5" + ISO_FILE="${ISO_DIR}/crux-3.6.iso" + MD5_FILE="${ISO_DIR}/crux-3.6.md5" shift ;; -d|--download) -- cgit From 21507178e5386bb5645e33276172c55fa4c53bd6 Mon Sep 17 00:00:00 2001 From: Silvino Date: Fri, 26 Feb 2021 19:55:21 +0000 Subject: fix linux mirror-system script --- linux/scripts/mirror-system | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'linux/scripts') diff --git a/linux/scripts/mirror-system b/linux/scripts/mirror-system index 6c8a528..73a5473 100755 --- a/linux/scripts/mirror-system +++ b/linux/scripts/mirror-system @@ -51,7 +51,7 @@ for installed in *; do 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 + prt-get update $installed done done -- cgit