#!/bin/bash TARGET=$1 DEBIAN_CODENAME=$2 LANG=C VERSION="$(date +%g.%m)" APT_PARAM='' STDOUT='/dev/stdout' if [ !$MKRESCUE_VERBOSE ]; then APT_PARAM='-qq -o=Dpkg::Use-Pty=0'; STDOUT='/dev/null' fi SOFTWARE="acl acpi-support-base attr \ bash-completion bind9-host binutils bridge-utils bsdmainutils \ ca-certificates \ debootstrap dialog dosfstools dmidecode \ efibootmgr ethtool \ fdisk file \ gddrescue gdisk grub-pc grub-efi-amd64-bin \ hdparm \ ifenslave iproute2 iputils-ping ipxe \ less lsof lvm2 lzip \ mdadm mtr-tiny mtools \ nano netcat-traditional net-tools nfs-common ntfs-3g nvme-cli \ parted pciutils pixz procps psmisc pv \ rsync \ screen scrub smartmontools ssh strace sysstat systemd systemd-resolved systemd-sysv \ tar tcpdump telnet traceroute tree \ usbutils \ vim vlan \ wget \ xz-utils xfsprogs \ zfsutils-linux zstd" chroot ${TARGET} apt-get $APT_PARAM --yes install ${SOFTWARE} > $STDOUT chroot ${TARGET} systemctl enable systemd-networkd.service chroot ${TARGET} systemctl enable systemd-resolved.service chroot ${TARGET} systemctl enable acpid.service echo "Etc/UTC" > ${TARGET}/etc/timezone chroot ${TARGET} dpkg-reconfigure -f noninteractive tzdata cat << EOF > ${TARGET}/etc/motd WARNING: Authorized access only! EOF cat << EOF > ${TARGET}/etc/issue WMI Rescue Linux (based on Debian GNU/Linux ${DEBIAN_CODENAME^}) Version ${VERSION} AMD64 EOF #disable console blanking #(consoleblank=0 as kernel param or setterm -blank 0) #current value can be checked in /sys/module/kernel/parameters/consoleblank echo -ne "\033[9;0]" >> ${TARGET}/etc/issue sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' ${TARGET}/etc/ssh/sshd_config cat << EOF > ${TARGET}/etc/systemd/network/all.network [Match] Name=* [Network] DHCP=yes EOF cat << EOF > ${TARGET}/etc/systemd/resolved.conf [Resolve] FallbackDNS=8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844 EOF rm ${TARGET}/etc/resolv.conf ln -s /run/systemd/resolve/resolv.conf ${TARGET}/etc/resolv.conf rm ${TARGET}/etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service #use old network device names ln -s /dev/null ${TARGET}/etc/systemd/network/99-default.link cat << EOF > ${TARGET}/etc/systemd/system/ssh-session-cleanup.service [Unit] Description=OpenBSD Secure Shell session cleanup Wants=network.target After=network.target [Service] ExecStart=/bin/true ExecStop=/usr/lib/openssh/ssh-session-cleanup RemainAfterExit=yes Type=oneshot [Install] WantedBy=multi-user.target EOF chroot ${TARGET} systemctl enable ssh-session-cleanup.service cat << EOF > ${TARGET}/etc/screenrc startup_message off defscrollback 5000 EOF cat << EOF > ${TARGET}/etc/sysctl.d/60-panic.conf kernel.panic = 5 kernel.panic_on_oops = 1 EOF # VIM sed -i 's/" let g:skip_defaults_vim = 1/let g:skip_defaults_vim = 1/g' ${TARGET}/etc/vim/vimrc cat << EOF > ${TARGET}/etc/vim/vimrc.local syntax enable set background=dark " spaces & tabs set tabstop=4 " number of visual spaces per TAB set softtabstop=4 " number of spaces in tab when editing set expandtab " tabs are spaces set shiftwidth=4 " indent shift set autoindent " UI config set number " show line numbers set showcmd " show command in bottom bar filetype indent on " load filetype-specific indent files set wildmenu " visual autocomplete for command menu set lazyredraw " redraw only when we need to set showmatch " highlight matching [{()}] set laststatus=2 " always display status line set ruler " show the line and column number set showmode " show current mode set mousemodel=extend set history=100 set pastetoggle= " searching set incsearch " search as characters are entered set hlsearch " highlight matches " folding set foldenable " enable folding set foldlevelstart=10 " open most folds by default set foldnestmax=10 " 10 nested fold max nnoremap za set foldmethod=indent " movement set backspace=indent,eol,start " language-specific settings autocmd FileType mail,news set textwidth=74 formatoptions=tln21cq autocmd FileType text setlocal textwidth=78 autocmd FileType make set noexpandtab tabstop=8 let bash_is_sh = 1 let c_gnu=1 let c_comment_strings=1 let java_highlight_java_lang_ids=1 let python_highlight_all = 1 EOF rsync -avS ${TARGET}/etc/skel/ ${TARGET}/root/ echo zfs >> ${TARGET}/etc/modules mkdir ${TARGET}/etc/bash_completion.d cp ${TARGET}/usr/share/bash-completion/completions/zfs ${TARGET}/etc/bash_completion.d/