#!/usr/bin/env zsh # Copyright (c) 2017-2018 Dyne.org Foundation # # decode.blend is written and maintained by Ivan J. # # This source code is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This software is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this source code. If not, see . ## libdevuansdk build script for decode-os BLENDPATH="${BLENDPATH:-$(dirname $0)}" source $BLENDPATH/config source $BLENDPATH/helpers blend_release_path=$BLENDPATH/$release blend_packages=${blend_release_path}/packages blend_scripts=${blend_release_path}/scripts blend_bootstrap_setup() { fn blend_bootstrap_setup "(override)" req=(strapdir) ckreq || return 1 sudo cp -v "$R/../extra/deb.torproject.org.asc" "$strapdir" cat <<-EOF | sudo tee ${strapdir}/blend-bootstrap-setup >/dev/null #!/bin/sh echo " * Adding deb.torproject.org repo key to apt..." cat /deb.torproject.asc | apt-key add - rm -f /deb.torproject.asc EOF chroot-script -d blend-bootstrap-setup || zerr } blend_preinst() { fn blend_preinst req=(blend_name username userpass) ckreq || return 1 notice "executing $blend_name preinst" if [[ -d "${blend_scripts}" ]]; then notice "copying blend-specific scripts into $R/extra/custom-scripts" mkdir -p "$R/extra/custom-scripts" || { zerr; return 1; } cp -fv "$blend_scripts"/*.sh "$R/extra/custom-scripts" else notice "no blend-specific scripts found in ${blend_scripts}" fi if [[ -d "${blend_scripts}" ]]; then notice "copying blend-specific scripts" mkdir -p "$R/extra/custom-scripts" cp -fv "$blend_scripts"/*.sh "$R/extra/custom-scripts" else notice "no blend-specific scripts found in ${blend_release_path}/automate" fi enable_apt-proxy notice "get selections for current system. DISABLED" # Either run here or look at the get_selections function # in ${blends_release_path}/../helpers and run on the # system you wish to duplicate. # #get_selections # For packages in a separate debs directory notice "blend-specific packages." if [[ -d "${blend_packages}" ]] ; then act "copying blend-specific debs from ${blend_packages} into $R/extra/custom-packages" mkdir -p "$R/extra/custom-packages" || { zerr; return 1; } cp -fv "$blend_packages"/*.deb "$R/extra/custom-packages" else notice "no blend-specific debs found in ${blend_packages}" fi # for packages in the top level blend path. setopt EXTENDED_GLOB if [[ -n $blend_release_path/"*.deb"(#qN) ]]; then act "copying blend-specific debs from ${blend_release_path} into $R/extra/custom-packages" mkdir -p "$strapdir/extra/custom-packages" || { zerr; return 1; } cp -fv "$blend_release_path"/*.deb "$R/extra/custom-packages" || { zerr; return 1; } else print "No debian packages found in ${blend_release_path}." fi cat <<-EOF | sudo tee "$strapdir/install-custompackages" >/dev/null #!/bin/sh cd extra_packages dpkg -i *_all.deb *_${arch}.deb apt-get -f install cd - >/dev/null rm -rf extra_packages EOF act "installing blend-specific packages." chroot-script -d install-custompackages || { zerr; return 1; } notice "adding user account." act "customize the post-adduser script." cat <<-EOF | sudo tee "$strapdir/usr/local/sbin/adduser.local" >/dev/null #!/bin/sh ## Site-specific setup for newly-created users. ## adduser(8) will call this script after setting up a new user. ## Usage: adduser.local USER UID GID HOME set -euo pipefail if [[ "\$#" != 4 ]]; then echo "usage: $0 username uid gid home" > /dev/stderr fi NEW_USERNAME="\${1:?}" NEW_UID="\${2:?}" NEW_GID="\${3:?}" NEW_HOME="\${4:?}" # EXAMPLE: adduser discards permissions when copying from /etc/skel. #chgrp www-data ${NEW_HOME}/public_html #chmod g+s ${NEW_HOME}/public_html # EXAMPLE: create a matching MySQL User for the Unix user. #mysql -vv -e "CREATE USER '${NEW_USERNAME}'@'localhost' IDENTIFIED WITH auth_socket;" # Fetch the tmux plugins. #su -c '/usr/share/tmux-plugin-manager/bin/install_plugins' ${NEW_USERNAME} EOF chmod u+x ${strapdir}/usr/local/sbin/adduser.local act "create default user." # that populate /etc/skel will be reflected in the new user directory. add-user "${username}" "${userpass}" ${userskel:-/etc/skel} || exit 1 } blend_postinst() { fn blend_postinst req=(strapdir) ckreq || return 1 notice "executing $blend_name postinst" notice "copying rootfs overlays" rootfs_overlay_path="$R/../rootfs-overlay" sudo rsync -raX "${rootfs_overlay_path}/common/" "${strapdir}" if [[ -n "$vmsdk_version" ]]; then _sdk="vm" elif [[ -n "$armsdk_version" ]]; then _sdk="arm" elif [[ -n "$livesdk_version" ]]; then _sdk="live" fi sudo rsync -raX "${rootfs_overlay_path}/${_sdk}/" "${strapdir}" blend_finalize || zerr } blend_finalize() { fn blend_finalize req=(strapdir) ckreq || return 1 act "enabling ssh." #enablessh act "set grub theme." pushd "$strapdir" # This line is in desktop-base so we should always have a grub theme in /etc/default/grub to change.. # printf "\nGRUB_THEME=/usr/share/desktop-base/grub-themes/${grub_theme}/theme.txt\n" >> /etc/default/grub grub_theme_path="/usr/share/desktop-base/grub-themes/${grub_theme}/theme.txt" regex="s|^\(GRUB_THEME=\).*|\1\"${grub_theme_path}\"|" sed -i "${regex}" ./etc/default/grub popd cat <<-EOF | sudo tee ${strapdir}/finalize >/dev/null #!/bin/sh ## permissions for i in cdrom floppy sudo audio dip video plugdev netdev; do gpasswd -a ${username} \$i done chsh -s "${default_shell}" ${username} chown -R 1000:1000 /home/${username} #sed -e 's/UsePAM yes/UsePAM no/' -i /etc/ssh/sshd_config ## misc sed -i -e 's/devuan/rockpro64/' /etc/hosts echo rockpro64 > /etc/hostname mkdir -p /var/lib/tor ## cleanup apt-get --yes --force-yes purge ${finalize_purge_packages} apt-get --yes --force-yes autoremove apt-get clean apt-get update cleanupfiles=" /var/log/bootstrap.log /var/log/dpkg.log /var/log/alternatives.log /var/log/fontconfig.log /var/log/apt /var/log/fsck /var/log/ConsoleKit /var/lib/polkit-1 /usr/local/share/zsh/site-functions " echo "\$cleanupfiles" | xargs rm -rf EOF chroot-script -d finalize || zerr } conf_print_sourceslist() { fn conf_print_sourceslist "(override)" cat <<-EOF ## package repositories deb http://deb.devuan.org/merged $release main deb http://deb.devuan.org/merged $release-updates main deb http://deb.devuan.org/merged $release-security main ## source repositories #deb-src http://deb.devuan.org/merged $release main #deb-src http://deb.devuan.org/merged $release-updates main #deb-src http://deb.devuan.org/merged $release-security main EOF }