Skip to content
Snippets Groups Projects
customizeChroot 3.05 KiB
Newer Older
  • Learn to ignore specific revisions
  • Eric Vidal's avatar
    Eric Vidal committed
    # 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
    
    Eric Vidal's avatar
    Eric Vidal committed
    # distribution.
    
    # This file may not be copied, modified, propagated, or distributed
    # except according to the terms contained in the LICENSE file.
    
    Eric Vidal's avatar
    Eric Vidal committed
    
    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
                out_error "Missing file : ${list}"
                exit	
            fi
        done
        
        unset list
    
    Eric Vidal's avatar
    Eric Vidal committed
    }
    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
    
    Eric Vidal's avatar
    Eric Vidal committed
        unset _tmp
    }
    
    ############################## only modifie this script after this line ############################
    
    
    Eric Vidal's avatar
    Eric Vidal committed
    create_log_user(){
    
        out_action "add ${NEWUSER} at log group"
        gpasswd -a "$NEWUSER" log
    
    Eric Vidal's avatar
    Eric Vidal committed
    }
    custo_once create_log_user 
    
    
    jean-michel's avatar
    jean-michel committed
    config_66(){
    
    
        # creation of the live/ to avoid crash
        mkdir -p -m1777 /run/66
    
    
    jean-michel's avatar
    jean-michel committed
        out_action "Create, enable tree [system]"
    
        66-tree -v3 -nE system
    
    jean-michel's avatar
    jean-michel committed
        out_action "Enable ntpd,sshd on tree [system]"
    
        66-enable -v3 -t system ntpd sshd
    
    
    jean-michel's avatar
    jean-michel committed
        out_action "Create, enable tree [desktop] with flag current"
    
        66-tree -v3 -nEc desktop
    
    jean-michel's avatar
    jean-michel committed
        out_action "Enable dbus,networkmanager,wpa_supplicant services,sddm on tree [desktop]"
        66-enable -v3 -t desktop dbus networkmanager wpa_supplicant sddm
    
    
        # avoid permissions access issue
        chown -R ${NEWUSER}:users /run/66
    
    
    jean-michel's avatar
    jean-michel committed
        out_action "For ${NEWUSER}: Create, enable tree [gui] with flag current"
        su "${NEWUSER}" -c "66-tree -v3 -nEc gui"
    
    jean-michel's avatar
    jean-michel committed
        out_action "Enable dbus-user and xdg-user-dirs on tree [gui]"
        su "${NEWUSER}" -c "66-enable -v3 -t gui dbus-user xdg-user-dirs"
    
    Eric Vidal's avatar
    Eric Vidal committed
    }
    
    jean-michel's avatar
    jean-michel committed
    custo_once config_66
    
    Eric Vidal's avatar
    Eric Vidal committed
    
    
    jean-michel's avatar
    jean-michel committed
    config_user(){
    
        out_action "Create ${NEWUSER} .scandir file"
        su "${NEWUSER}" -c "cat > /home/${NEWUSER}/.scandir <<EOF
    #!/usr/bin/execlineb -P
    #emptyenv -p
    s6-setsid -qb --
    umask 022
    
    66-scandir -v3 -cu
    EOF"
        out_action "Set 750 permissions on .scandir file"
        su "${NEWUSER}" -c "chmod 750 /home/${NEWUSER}/.scandir"
        
        out_action "Create ${NEWUSER} .zprofile file"
        su "${NEWUSER}" -c "cat > /home/${NEWUSER}/.zprofile <<EOF
    ## Execute scandir script
    ## Send a down signal, or 'could not sync environment to dbus' with sddm when user logout/login 
    ## Send an up signal for services inside tree [gui]
    
    (.scandir &) &
    66-all -t gui down
    sleep 01
    66-all -t gui up
    EOF"
    
        out_action "Create ${NEWUSER} .xinitrc file"
        su "${NEWUSER}" -c "cat > /home/${NEWUSER}/.xinitrc <<EOF
    ## Uncomment if you use startx command line to launch plasma DE
    exec ck-launch-session startkde
    EOF"
    }
    custo_once config_user
    
    
    out_valid "Customization terminate"
    
    Eric Vidal's avatar
    Eric Vidal committed