VMware Horizon Community
serverhack
Enthusiast
Enthusiast
Jump to solution

RunOnceScript does nothing until manual modifying

Hi all,

I have set up a master image with Ubuntu Desktop 16.04.3 and SSSD for AD integration. I have set-up a script to rejoin the computer to AD Computers OU and call it via the RunOnceScript at /etc/vmware/viewagent-custom-conf file.

After creating the pool and applied the personalization profile the computer account isn't created in AD; the logs tell that the script has been identified and:

2017-10-17T16:48:43.675Z DEBUG <Script Runner> [LinuxUtilities] Running script: /usr/lib/vmware/viewagent/bin/MonitorHostname.sh  Monitor Host name Process

2017-10-17T16:48:43.688Z DEBUG <Script Runner> [LinuxUtilities] waiting for process to terminate, script: /usr/lib/vmware/viewagent/bin/MonitorHostname.sh  Monitor Host name Process

2017-10-17T16:48:43.688Z DEBUG <Script Stdout> [LinuxUtilities] customize script path: /root/net-rejoin.sh  Monitor Host name Process

2017-10-17T16:48:43.688Z DEBUG <Script Stdout> [LinuxUtilities] host name: VDIVMWLnxBase2  Monitor Host name Process

2017-10-17T16:48:43.688Z DEBUG <Script Stdout> [LinuxUtilities] timeout seconds: 120  Monitor Host name Process

2017-10-17T16:48:43.695Z DEBUG <Script Stdout> [LinuxUtilities] execute the user script  Monitor Host name Process

agent service stopping..

2017-10-17T16:48:43.695Z DEBUG <Script Stdout> [LinuxUtilities] user script process: 1604  Monitor Host name Process

2017-10-17T16:48:43.703Z DEBUG <Script Stdout> [LinuxUtilities] timer-process pid: 1605  Monitor Host name Process

2017-10-17T16:48:43.704Z DEBUG <Script Stdout> [LinuxUtilities] starting to wait the user script finished  Monitor Host name Process

2017-10-17T16:48:43.712Z DEBUG <Script Runner> [LinuxUtilities] process terminated with rc 143, script: /usr/lib/vmware/viewagent/bin/MonitorHostname.sh  Monitor Host name Process

2017-10-17T16:48:43.713Z DEBUG <Script Runner> [LinuxUtilities] Script finished: /usr/lib/vmware/viewagent/bin/MonitorHostname.sh  Monitor Host name Process

2017-10-17T16:48:43.715Z DEBUG <Script Stdout> [LinuxUtilities] finished  Monitor Host name Process

2017-10-17T16:48:43.715Z DEBUG <Script Runner> [LinuxUtilities] thread finished...

AS you can see it seems the the agent service stops suddenly (don't know why).

At that moment I can see the RUNONCE value at /etc/vmware/viewagent-config.txt is TRUE, but the computer account hasn't been created in AD.

If I change the RUNONCE value to FALSE and restart the VM (os the agent service) then the MonitorHostname Service executes the script and the computer account is included in AD:

2017-10-17T17:04:43.446Z INFO  <main> [StandaloneAgent] Starting Monitor Host name Process

2017-10-17T17:04:43.448Z DEBUG <Script Runner> [LinuxUtilities] Running script: /usr/lib/vmware/viewagent/bin/MonitorHostname.sh  Monitor Host name Process

2017-10-17T17:04:43.450Z DEBUG <Script Runner> [LinuxUtilities] waiting for process to terminate, script: /usr/lib/vmware/viewagent/bin/MonitorHostname.sh  Monitor Host name Process

2017-10-17T17:04:43.450Z DEBUG <Script Stdout> [LinuxUtilities] customize script path: /root/net-rejoin.sh  Monitor Host name Process

2017-10-17T17:04:43.450Z DEBUG <Script Stdout> [LinuxUtilities] host name: VDIVMWLnxBase2  Monitor Host name Process

2017-10-17T17:04:43.451Z DEBUG <Script Stdout> [LinuxUtilities] timeout seconds: 120  Monitor Host name Process

2017-10-17T17:04:43.452Z DEBUG <Script Stdout> [LinuxUtilities] execute the user script  Monitor Host name Process

2017-10-17T17:04:43.452Z DEBUG <Script Stdout> [LinuxUtilities] user script process: 1459  Monitor Host name Process

2017-10-17T17:04:43.452Z DEBUG <Script Stdout> [LinuxUtilities] timer-process pid: 1460  Monitor Host name Process

2017-10-17T17:04:43.452Z DEBUG <Script Stdout> [LinuxUtilities] starting to wait the user script finished  Monitor Host name Process

2017-10-17T17:04:48.085Z DEBUG <Script Stdout> [LinuxUtilities] Using short domain name -- DEMOLAB  Monitor Host name Process

2017-10-17T17:04:48.085Z DEBUG <Script Stdout> [LinuxUtilities] Joined 'TESTDSKP02' to dns domain 'demolab.local'  Monitor Host name Process

2017-10-17T17:04:48.088Z DEBUG <Script Stdout> [LinuxUtilities] user script finished, return value is 0  Monitor Host name Process

2017-10-17T17:04:48.088Z DEBUG <Script Stdout> [LinuxUtilities] Unset timer  Monitor Host name Process

2017-10-17T17:04:48.088Z DEBUG <Script Stdout> [LinuxUtilities] timer killed..  Monitor Host name Process

2017-10-17T17:04:48.089Z DEBUG <Script Runner> [LinuxUtilities] process terminated with rc 0, script: /usr/lib/vmware/viewagent/bin/MonitorHostname.sh  Monitor Host name Process

2017-10-17T17:04:48.089Z DEBUG <Script Runner> [LinuxUtilities] Script finished: /usr/lib/vmware/viewagent/bin/MonitorHostname.sh  Monitor Host name Process

2017-10-17T17:04:48.092Z DEBUG <Script Stdout> [LinuxUtilities] finished  Monitor Host name Process

2017-10-17T17:04:48.092Z DEBUG <Script Runner> [LinuxUtilities] thread finished...

That's the behavior for every desktop in the pool, Am I missing anything? I'd like not to be modifying every RUNONCE value in all VMs.

Thanks and regards,

Jorge

Reply
0 Kudos
1 Solution

Accepted Solutions
txiong
VMware Employee
VMware Employee
Jump to solution

Hi Jorge,

Would you please upload the DCT bundle? Thanks.

Here is the workflow to use RunOnceScript to join cloned Linux VM to AD, just for your reference

1. Prepare the Linux template VM, and join it to AD.

2. Install Horizon Agent on it:

     - RUNONCE value is "false" by default in /etc/vmware/viewagent-config.txt

     - Installer will record current hostname to /etc/vmware/viewagent-config.txt

3. Do NOT put the template VM to any deskotp pool.

4. Set RunOnceScript in /etc/vmware/viewagent-custom.conf, and power off the Linux template VM

5. In vCenter, create a Customiztion Specification for Linux OS, which will change cloned VM's hostname to VM name. See step #2 in Overview of Bulk Deployment of Linux Desktops

6. Clone Linxu VMs from the template VM with GUI or vCenter API based script, ensure the  Customiztion Specification is specified

7. When the VM is clloned:

    1). In the 1st startup, before Horizon Agent service started, Customiztion Specification will be applied, which will change hostname to VM name value, and reboot the machine

    2). In the 2nd startup, when Horizon Agent service started, it will detect that current hostname is different form the recorded one in /etc/vmware/viewagent-config.txt. Then service will execute the RunOnceScript, which will re-join the cloned VM to AD. After execution, it will set RUNONCE to "true" in /etc/vmware/viewagent-config.txt, which means that RunOnceScript has ben done, and will not try to run it from now on.

8. After the last VM is cloned and hostname is changed, create the desktop pool as Create a Manual Desktop Pool for Linux 

View solution in original post

Reply
0 Kudos
3 Replies
serverhack
Enthusiast
Enthusiast
Jump to solution

Anybody?? Smiley Sad

Reply
0 Kudos
txiong
VMware Employee
VMware Employee
Jump to solution

Hi Jorge,

Would you please upload the DCT bundle? Thanks.

Here is the workflow to use RunOnceScript to join cloned Linux VM to AD, just for your reference

1. Prepare the Linux template VM, and join it to AD.

2. Install Horizon Agent on it:

     - RUNONCE value is "false" by default in /etc/vmware/viewagent-config.txt

     - Installer will record current hostname to /etc/vmware/viewagent-config.txt

3. Do NOT put the template VM to any deskotp pool.

4. Set RunOnceScript in /etc/vmware/viewagent-custom.conf, and power off the Linux template VM

5. In vCenter, create a Customiztion Specification for Linux OS, which will change cloned VM's hostname to VM name. See step #2 in Overview of Bulk Deployment of Linux Desktops

6. Clone Linxu VMs from the template VM with GUI or vCenter API based script, ensure the  Customiztion Specification is specified

7. When the VM is clloned:

    1). In the 1st startup, before Horizon Agent service started, Customiztion Specification will be applied, which will change hostname to VM name value, and reboot the machine

    2). In the 2nd startup, when Horizon Agent service started, it will detect that current hostname is different form the recorded one in /etc/vmware/viewagent-config.txt. Then service will execute the RunOnceScript, which will re-join the cloned VM to AD. After execution, it will set RUNONCE to "true" in /etc/vmware/viewagent-config.txt, which means that RunOnceScript has ben done, and will not try to run it from now on.

8. After the last VM is cloned and hostname is changed, create the desktop pool as Create a Manual Desktop Pool for Linux 

Reply
0 Kudos
serverhack
Enthusiast
Enthusiast
Jump to solution

Thanks txiong,

as you described the last thing I have to do is set the RUNONCESCRIPT to the VM before converting it to template and create the pool; if I start the VM with the RunOnceScript set the next time it will not function correctly.

Best regards.

Reply
0 Kudos