-
Eric Vidal authoredEric Vidal authored
customizeChroot 4.48 KiB
#!@BINDIR@/bash
# Copyright (c) 2015-2018 Eric Vidal <eric@obarun.org>
# All rights reserved.
#
# This file is part of Obarun. It is subject to the license terms in
# the LICENSE file found in the top-level directory of this
# distribution.
# This file may not be copied, modified, propagated, or distributed
# except according to the terms contained in the LICENSE file.
sourcing(){
local list
for list in /tmp/obarun-install-tmp/install.conf /usr/lib/obarun/util.sh; do
if [[ -f "${list}" ]]; then
source "${list}"
else
oblog -f "Missing file : ${list}"
exit
fi
done
unset list
}
sourcing
custo_once() {
local _tmp cmd
cmd="${1}"
_tmp="/tmp/obarun-install-tmp"
if [[ ! -d $_tmp ]]; then
mkdir -p -m0755 $_tmp || die "Impossible to create $_tmp"
fi
if [[ ! -e $_tmp/customize.${cmd} ]]; then
"${cmd}" || die "Cannot execute $_"
touch $_tmp/customize.${cmd}
else
return
fi
unset _tmp
}
############################## only modifie this script after this line ############################
create_log_user(){
oblog "add ${NEWUSER} at log group"
gpasswd -a "$NEWUSER" log
}
config_tree_boot(){
oblog "Create tree boot"
66-tree -zv3 -n boot || die "unable to create boot tree"
}
config_enable_boot(){
oblog "Enable boot@system service at tree boot"
66-enable -zv3 -t boot -F boot@system || die "unable to enable boot@system"
# By default the configuration file is prefixed with a dot.
# 66-env -r do not know about it, so copy it without the prefix
BOOT_CONF="$(readlink /etc/66/conf/boot@system/version)"
cp "${BOOT_CONF}/.boot@system" "${BOOT_CONF}/boot@system" || die "unable to cp boot@system configuration file"
oblog "Configure boot@system service"
66-env -t boot -r "HOSTNAME=!${HOSTNAME}" -r "KEYMAP=!${KEYMAP}" -r "TZ=${ZONE}/${SUBZONE}" boot@system || die "unable to configure boot@system service"
oblog "Apply change to the boot@system service"
66-enable -zv3 -t boot -F boot@system || die "unable to apply boot changes"
}
config_tree_root(){
oblog "Create tree root and enable it"
66-tree -zv3 -cnE root || die "unable to create root tree"
}
config_enable_root(){
oblog "Enable sddm, consolekit, dbus, openntpd, networkmanager and wpa_supplicant on tree root"
66-enable -zv3 sddm consolekit dbus openntpd networkmanager wpa_supplicant || die "unable to enable dbus openntpd connmand wpa_supplicant"
}
config_tree_boot_user(){
oblog "Create boot-user tree"
66-tree -zv3 -En boot-user || die "unable to create boot-user tree"
}
config_enable_boot_user(){
oblog "Enable boot-user@${NEWUSER} at boot-user tree"
66-enable -zv3 -t boot-user -F boot-user@${NEWUSER} || die "unable to enable boot-user@${NEWUSER} service"
BOOT_USER="$(readlink /etc/66/conf/boot-user@${NEWUSER}/version)"
cp "${BOOT_USER}/.boot-user@${NEWUSER}" "${BOOT_USER}/boot-user@${NEWUSER}"
oblog "Configure boot-user@${NEWUSER} service"
66-env -t boot-user -r "DESKTOP_CMDLINE=!xfce4-session" boot-user@${NEWUSER} || die "unable to set DESKTOP_CMDLINE"
oblog "Apply change to the boot-user@{NEWUSER} service"
66-enable -zv3 -t boot-user -F boot-user@${NEWUSER} || die "unable to apply boot-user changes"
}
config_tree_base_user(){
oblog "Create base tree for ${NEWUSER}, enables and makes it current"
su "${NEWUSER}" -c "66-tree -zv3 -Ecn base" || die "unable to create base tree"
}
config_enable_base_user(){
oblog "Enable xdg-user-dirs, dbus-session@${NEWUSER} on base tree"
su "${NEWUSER}" -c "66-enable -zv3 xdg-user-dirs dbus-session@${NEWUSER}" || die "unable to enable xdg-user-dirs dbus-session@${NEWUSER} service"
}
config_xsession(){
cat << EOF > /home/${NEWUSER}/.xsession
list=( \$(ls -1 /home/${NEWUSER}/.66/conf/svscan@${NEWUSER}) )
for i in \${list[@]};do
var=\$(</home/${NEWUSER}/.66/conf/svscan@${NEWUSER}/\${i})
for j in \${var[@]}; do
export \${j}
done
done
66-all up
EOF
}
custo_once create_log_user
custo_once config_tree_boot
custo_once config_enable_boot
custo_once config_tree_root
custo_once config_enable_root
custo_once config_tree_boot_user
custo_once config_enable_boot_user
custo_once config_tree_base_user
custo_once config_enable_base_user
custo_once config_xsession
## Configure pulseaudio
config_pulse(){
echo "load-module module-device-manager" >> /etc/pulse/default.pa
}
custo_once config_pulse
oblog "Customization terminate"