Post Install Script does not work while deploying ubuntu 16.04 image using FOG.



  • Hi Team,

    I am getting “Command not found” error while deploying ubuntu 16.04 OS to a new system.
    i used the Post install script in fog for ubuntu image deployment.
    I followed this link: https://forums.fogproject.org/topic/7740/the-magical-mystical-fog-post-download-script
    I am trying to install few applications and settings change for my requirement.
    I created fog.sh file and edited with required commands to do the task, added fog.sh file path to fog.postdownload file as per the above article, still the same issue.



  • @vinay said in Post Install Script does not work while deploying ubuntu 16.04 image using FOG.:

    @sebastian-roth
    Would you help me with the procedure to include chroot in my below mentioned script as i messed it up adding multiple things.?

    I looked over your script. Looks like you’d put the chroot related lines at the start of your script. You should play around with chroot before doing this though. On a linux VM, boot to a live Ubuntu disk or something - then try to chroot from the Ubuntu disk to the local disk. Once you do this a couple times you’ll understand what chroot does and how to work with it. Also you should Google search it (or duckduckgo search it) too. We can’t do all your work for you, we rather show you the way.



  • @sebastian-roth
    Would you help me with the procedure to include chroot in my below mentioned script as i messed it up adding multiple things.?


  • Developer

    @Vinay Please post current script code and error on screen again so we know what we are at.



  • @sebastian-roth
    Thanks for the heads up.
    However, i did add the chroot in the script, still it does not work.
    Could you help me with adding this chroot command to my fog.sh script, how i can apply here.


  • Moderator

    @vinay said in Post Install Script does not work while deploying ubuntu 16.04 image using FOG.:

    . /usr/share/fog/lib/funcs.sh

    First of all, thank you for sharing your script it helps greatly with resolving your issue.

    The simple thing first. You can remove this line . /usr/share/fog/lib/funcs.sh since you are not using any of the fog built in functions.

    Second, your script runs in the context of FOS. FOS is a highly customized version of linux, where target OS commands will not work as you found.

    You can probably use the change root command like Sebastian mentioned, but I would be concerned about the operating environment of FOS interfering with ubuntu native commands like apt-get.

    I think you should modify your postinstall script to drop this fog.sh script on your target system during imaging. Then configure ubuntu to execute this script via an rc.local startup script entry. Then at the end of your fog.sh script, have it remove the call to fog.sh from rc.local entry once fog.sh runs. That way your script is running within the context of your ubuntu environment.


  • Developer

    @Vinay The command need to be run in the destination Linux system. Something like this before running your commands.

    mkdir -p /mnt/ubuntu
    mount /dev/sdaX /mnt/ubuntu
    chroot /mnt/ubuntu /bin/bash
    ...
    

    If you haven’t heard about chroot yet you better start reading… :-)



  • @george1421
    Thank you for your reply George.
    It is just not taking systemctl and apt-get install commands.
    My fog.sh file shows as below:

    #!/bin/bash
    
    echo 'Installing required packages'
    apt-get update
    apt-get dist-upgrade
    apt-get -y install samba sssd ntp
    DEBIAN_FRONTEND=noninteractive apt-get -y install krb5-user
    
    # krb5.conf
    echo 'Configuring Kerberos'
    cat << EOF > /etc/krb5.conf
    [libdefaults]
    	default_realm = xx.xxx.COM
    # The following krb5.conf variables are only for MIT Kerberos.
    	krb4_config = /etc/krb.conf
    	krb4_realms = /etc/krb.realms
    	kdc_timesync = 1
    	ccache_type = 4
    	forwardable = true
    	proxiable = true
    # The following libdefaults parameters are only for Heimdal Kerberos.
    	v4_instance_resolve = false
    	v4_name_convert = {
    		host = {
    			rcmd = host
    			ftp = ftp
    		}
    		plain = {
    			something = something-else
    		}
    	}
    	fcc-mit-ticketflags = true
    [realms]
    	xx.xxx.COM = {
    		kdc = xxxxxxx.xx.xxx.COM
    		kdc = xxxxxxx.xx.xxx.COM
    		admin_server = xxxxxxx.xx.xxxx.COM
    	}
    [login]
    	krb4_convert = true
    	krb4_get_tickets = false
    EOF
    
    # ntp.conf
    echo 'Configuring NTP'
    sed -i.orig 's/^server/#server/g' /etc/ntp.conf
    
    cat << EOF >> /etc/ntp.conf
    server xxxxxxx.xx.xxxx.com
    server xxxxxxx.xx.xxxx.com
    EOF
    
    # smb.conf
    echo 'Configuring Samba'
    cp /etc/samba/smb.conf /etc/samba/smb.conf.orig
    cat << EOF > /etc/samba/smb.conf
    [global]
       workgroup = xxxx
       client signing = yes
       client use spnego = yes
       kerberos method = secrets and keytab
       realm = xx.xxxx.COM
       security = ads
       server string = %h server (Samba, Ubuntu)
       dns proxy = no
       log file = /var/log/samba/log.%m
       max log size = 1000
       syslog = 0
       panic action = /usr/share/samba/panic-action %d
       server role = standalone server
       passdb backend = tdbsam
       obey pam restrictions = yes
       unix password sync = yes
       passwd program = /usr/bin/passwd %u
       passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
       pam password change = yes
       map to guest = bad user
       usershare allow guests = yes
    EOF
    
    # sssd.conf
    echo 'Configuring SSSD'
    cat << EOF > /etc/sssd/sssd.conf
    [sssd]
    services = nss, pam, sudo
    config_file_version = 2
    domains = xx.xxxx.COM
    [domain/xx.xxxx.COM]
    id_provider = ad
    access_provider = ad
    cache_credentials = True
    override_homedir = /home/%d/%u
    default_shell = /bin/bash
    EOF
    
    sudo chown root:root /etc/sssd/sssd.conf
    sudo chmod 600 /etc/sssd/sssd.conf
    
    # hosts
    echo 'Configuring Hosts'
    cat << EOF >> /etc/hosts
    #xx.xxx.x.xx xxxxx.xx.xxxx.com xxxxxx
    #xx.xxx.xx.xx xxxxxx.xx.xxxx.com xxxxxxx
    EOF
    
    HOSTNAME=`hostname`
    sed -i.orig "s/${HOSTNAME}/${HOSTNAME}.ad.here.com ${HOSTNAME}/g" /etc/hosts
    
    # pam
    echo 'Configuring PAM'
    sed -i.orig '/session\s*required\s*pam_unix.so/a session required pam_mkhomedir.so skel=/etc/skel/ umask=0077' /etc/pam.d/common-session
    
    # lightdm
    echo 'Configuring LightDM'
    cat << EOF >> /usr/share/lightdm/lightdm.conf.d/50-unity-greeter.conf
    greeter-show-manual-login=true
    greeter-hide-users=true
    EOF
    cat << EOF >> /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf
    allow-guest=false
    EOF
    
    # restart services
    echo 'Restarting SMBD'
    systemctl restart smbd.service
    echo 'Restarting NMBD'
    systemctl restart nmbd.service
    echo 'Restarting NTP'
    systemctl restart ntp.service
    
    # join the domain
    echo 'Obtaining Kerberos ticket'
    sudo kinit xxxxxx
    echo 'Getting info about the obtained ticket'
    sudo klist
    echo 'Joining to the domain'
    sudo net ads join -k
    
    echo 'Restarting SSSD'
    systemctl restart sssd.service
    
    . /usr/share/fog/lib/funcs.sh
    

    ERROR:
    0_1515654212046_f636028f-cc93-4ccb-a7fb-863bff33eaf9-image.png


  • Moderator

    First let me say I’ve been working on a newish version of the post you linked, here: https://forums.fogproject.org/topic/11126/using-fog-postinstall-scripts-for-windows-driver-injection-2017-ed

    To know where its failing we will need to see your fog.sh script to know where its actually failing. The command not found command simply indicates the command (function) you used is not available in FOS.


 

488
Online

41.4k
Users

11.8k
Topics

112.1k
Posts