• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login
    1. Home
    2. aknisly
    A
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 6
    • Best 1
    • Controversial 0
    • Groups 0

    aknisly

    @aknisly

    1
    Reputation
    3
    Profile views
    6
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    aknisly Unfollow Follow

    Best posts made by aknisly

    • RE: Linux FOG Client, Hostname Changer not working

      @george1421 Done. It took digging deeper into BASH scripting, and thinking through what the script was attempting to do, but it finally worked. Notably, the 2-condition test in the ‘if’ statement was giving me grief until I separated it into two double brackets (two single brackets may have worked?). I know there are a dozen ways of doing this, but this worked for me. Also, the ‘$osId’ needed to be ‘$osid’, and the /etc/hostname needed to be in the mounted directory instead of in the FOS environment.
      For others wanting to use this, here is the complete script as I adapted it to work, with the debugging elements removed.

      #!/bin/bash
      . /usr/share/fog/lib/funcs.sh
      [[ -z $postdownpath ]] && postdownpath="/images/postdownloadscripts/"
      
      if [[ "$osid" == "50" ]] && [[ ! -z $hostname ]]
      then
           [[ ! -d /imagefs ]] && mkdir -p /imagefs
           mount /dev/sda5 /imagefs
           echo $hostname > /imagefs/etc/hostname
           sync
           umount /imagefs
      fi
      

      A few more notes for others trying to make something like this work:

      • For anyone else having trouble with scripting, the debugging option is a life-saver. I ended up putting a debugPause (preceded by an “echo” or similar output statement) after every line to narrow my problem down.
      • It took me longer than it should have to figure out the details of the ‘if’ statements in @george1421’s sample script. The -z checks for a null value (in this case for $hostname the “!” is not, so this is saying if the $hostname variable is not null, then… Here is a good guide on these.
        *@george1421 has listed the FOG variables available in FOS (FogOS) here. I didn’t find this in the wiki. In that same thread, he notes a way to get a pile of other variables from the FOG server by running a script.
        *For a short primer on the post-install script concept itself, this post and a few others in that thread were the best I found.

      Again, @george1421, many, many thanks for your prompt, patient help. I’ve just made a donation to the FOG project in your honor.

      If I could have an account for the wiki, I’d be happy to put some of this info together in a tutorial for changing hostname and post-install scripting.

      Who marks this as ‘solved’?

      posted in Linux Problems
      A
      aknisly

    Latest posts made by aknisly

    • RE: Linux FOG Client, Hostname Changer not working

      @sebastian-roth (Belated reply…) Thanks for this helpful explanation. I certainly am not critical of the unfinished work here–what you have already is one incredible work of science/art.
      I did take a look at the code, and have a rough idea of what is being attempted there. But it’s true that the post-install script is pretty low-hanging fruit once you get your head under the hood. If I hadn’t been able to get what I wanted with that, I’d be happy to help with the fog-client and the HostnameChanger module, but as it is, unfortunately, I’m pressed to move on to other priorities.
      I would be happy to make some notes in the wiki (which is still the first place I check) if that is an option. Apparently self-registering an account is disabled?
      I’d also like to mark this topic solved, but can’t figure out how. Can you do that?
      Again, huge kudos for this project. And 5-stars for responsive devs on the forum!

      posted in Linux Problems
      A
      aknisly
    • RE: Linux FOG Client, Hostname Changer not working

      @george1421 Done. It took digging deeper into BASH scripting, and thinking through what the script was attempting to do, but it finally worked. Notably, the 2-condition test in the ‘if’ statement was giving me grief until I separated it into two double brackets (two single brackets may have worked?). I know there are a dozen ways of doing this, but this worked for me. Also, the ‘$osId’ needed to be ‘$osid’, and the /etc/hostname needed to be in the mounted directory instead of in the FOS environment.
      For others wanting to use this, here is the complete script as I adapted it to work, with the debugging elements removed.

      #!/bin/bash
      . /usr/share/fog/lib/funcs.sh
      [[ -z $postdownpath ]] && postdownpath="/images/postdownloadscripts/"
      
      if [[ "$osid" == "50" ]] && [[ ! -z $hostname ]]
      then
           [[ ! -d /imagefs ]] && mkdir -p /imagefs
           mount /dev/sda5 /imagefs
           echo $hostname > /imagefs/etc/hostname
           sync
           umount /imagefs
      fi
      

      A few more notes for others trying to make something like this work:

      • For anyone else having trouble with scripting, the debugging option is a life-saver. I ended up putting a debugPause (preceded by an “echo” or similar output statement) after every line to narrow my problem down.
      • It took me longer than it should have to figure out the details of the ‘if’ statements in @george1421’s sample script. The -z checks for a null value (in this case for $hostname the “!” is not, so this is saying if the $hostname variable is not null, then… Here is a good guide on these.
        *@george1421 has listed the FOG variables available in FOS (FogOS) here. I didn’t find this in the wiki. In that same thread, he notes a way to get a pile of other variables from the FOG server by running a script.
        *For a short primer on the post-install script concept itself, this post and a few others in that thread were the best I found.

      Again, @george1421, many, many thanks for your prompt, patient help. I’ve just made a donation to the FOG project in your honor.

      If I could have an account for the wiki, I’d be happy to put some of this info together in a tutorial for changing hostname and post-install scripting.

      Who marks this as ‘solved’?

      posted in Linux Problems
      A
      aknisly
    • RE: Linux FOG Client, Hostname Changer not working

      @george1421 Wow! Whatever they’re paying you, it’s not enough…:-)

      RE: the leading # on the first line: <pounds forehead with open palm> Duh. I knew that. I just mindlessly followed the script as you had posted it.

      I love the debugging magic; that’s a game-changer. All is well up to line 8. I can’t figure out why, but I’m getting

      line 8: [: missing ']'
      

      Sorry for being slow…

      posted in Linux Problems
      A
      aknisly
    • RE: Linux FOG Client, Hostname Changer not working

      @george1421 Thanks very much for this quick and helpful response! A few sentences of explanation can bridge what feels like a wide chasm of knowledge.

      Unfortunately, I’ve not got this working yet. Here is what I’ve done:
      On the server…

      [admin@localhost postdownloadscripts]$ cat fog.postdownload 
      !/bin/bash
      ## This file serves as a starting point to call your custom postimaging scripts.
      ## <SCRIPTNAME> should be changed to the script you're planning to use.
      ## Syntax of post download scripts are
      . ${postdownpath}/fog.sethostname
      
      [admin@localhost postdownloadscripts]$ cat fog.sethostname 
      !/bin/bash
      . /usr/share/fog/lib/funcs.sh
      [[ -z $postdownpath ]] && postdownpath="/images/postdownloadscripts/"
      
      if [ "$osId" == "50" && ! -z $hostname ]; then
           [[ ! -d /ntfs ]] && mkdir -p /ntfs
           mount /dev/sda5 /ntfs
           echo $hostname > /etc/hostname
           sync
           umount /ntfs
      fi
      
      [admin@localhost postdownloadscripts]$ ls -la
      total 8
      drwxrwxrwx.  2 fogproject root  53 Dec  8 10:22 .
      drwxrwxrwx. 10 fogproject root 177 Dec  7 16:52 ..
      -rwxrwxrwx.  1 fogproject root 238 Dec  8 09:54 fog.postdownload
      -rwxrwxrwx.  1 fogproject root 294 Dec  8 10:22 fog.sethostname
      

      (I gave 777 to the fog.sethostname just in case, since fog.postdownload had those permissions.)

      On the host…

      pilgrim@pcsthinlinc:~$ df -h
      Filesystem      Size  Used Avail Use% Mounted on
      udev            1.9G     0  1.9G   0% /dev
      tmpfs           388M  1.5M  386M   1% /run
      /dev/sda5        15G  7.4G  6.0G  56% /
      tmpfs           1.9G     0  1.9G   0% /dev/shm
      tmpfs           5.0M  4.0K  5.0M   1% /run/lock
      tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
      /dev/sda1       480M  4.0K  480M   1% /boot/efi
      tmpfs           388M   16K  388M   1% /run/user/1000
      
      

      The image deployed to the host as expected, but as you can see, it didn’t get the ‘LAPTOP-10’ hostname. Does the fact that the server doesn’t list this host as a Linux OS have anything to do with it? I don’t understand why all of our hosts (both Windows and Linux) show the image OS as ‘unknown.’
      Screenshot at 2021-12-08 10-57-47.png
      The ‘Mint Thin Client’ image is correctly registered as Linux:
      Screenshot at 2021-12-08 10-59-23.png

      Are there logs that I can access?
      Thanks again!

      posted in Linux Problems
      A
      aknisly
    • Linux FOG Client, Hostname Changer not working

      I’m another one of the many who is getting stuck with the hostname changer. I’ve not found a solution among the myriad posts on the matter. The client installed without errors, and the log shows that it is working, although I wasn’t able to figure out the “Unable to parse sleep time” error.

      12/7/2021 4:41 PM Service Starting service
       12/7/2021 4:41 PM Bus Became bus client
      
       12/7/2021 4:41 PM Middleware::Response Success
       12/7/2021 4:41 PM Service Initializing modules
      
      ------------------------------------------------------------------------------
      ----------------------------------AutoLogOut----------------------------------
      ------------------------------------------------------------------------------
       12/7/2021 4:41 PM Client-Info Client Version: 0.11.16
       12/7/2021 4:41 PM Client-Info Client OS:      Linux
       12/7/2021 4:41 PM Client-Info Server Version: 
       12/7/2021 4:41 PM Middleware::Response Success
       12/7/2021 4:41 PM Bus::Client Connection established
      ------------------------------------------------------------------------------
      
      
      ------------------------------------------------------------------------------
      -----------------------------DefaultPrinterManager----------------------------
      ------------------------------------------------------------------------------
       12/7/2021 4:41 PM Client-Info Client Version: 0.11.16
       12/7/2021 4:41 PM Client-Info Client OS:      Linux
       12/7/2021 4:41 PM Client-Info Server Version: 
       12/7/2021 4:41 PM Middleware::Response Success
      ------------------------------------------------------------------------------
      
      
      ------------------------------------------------------------------------------
      --------------------------------DisplayManager--------------------------------
      ------------------------------------------------------------------------------
       12/7/2021 4:41 PM Client-Info Client Version: 0.11.16
       12/7/2021 4:41 PM Client-Info Client OS:      Linux
       12/7/2021 4:41 PM Client-Info Server Version: 
       12/7/2021 4:41 PM Middleware::Response Success
       12/7/2021 4:41 PM DisplayManager Module is not compatible with Linux
      ------------------------------------------------------------------------------
      
       12/7/2021 4:41 PM Service ERROR: Unable to parse sleep time
       12/7/2021 4:41 PM Service ERROR: Input string was not in a correct format.
       12/7/2021 4:41 PM Service Sleeping for 60 seconds
      
      

      I’ve unchecked and rechecked the 3 places I can find to enable this:

      • FOG Configuration>FOG Client - Hostname Changer
      • Client Settings>Service Configuration>Hostname Changer>Service Status
        *Hosts>Host Management Edit: <my host>Service Settings>Host module settings

      (Sidenote: I’m puzzled why the log shows entries for Auto Logout, Printer Manager, and Display Manager, even though I disabled those globally…)

      I also deleted and redeployed the image onto the host, with no change.

      We’re not able currently to use the FOG server as our DHCP server, although it’s not clear to me that this would resolve the issue.

      From the manual, it looks like the Windows Client GUI has an option to enable the Hostname Changer (Maybe this is out of date?), but the Linux CLI installation didn’t have any such option. (See installation log here.)

      I’ve read about using a post install script with the FOG API to retrieve the hostname from the server and change it on the host, but I think that’s beyond my limited scripting ability. If I could retrieve the hostname, I might be able to adapt a simple script. I thought this one would be the cat’s meow, but something failed, and I think that the one that wasn’t supposed to need a MySQL client may still actually need it. I realize that I could register all clients in the DHCP reservations, but that looks like a pretty big task for something that could be automated.

      Thanks much in advance!

      FOG server v. 1.5.7

      lsb_release -a
      LSB Version:	:core-4.1-amd64:core-4.1-noarch
      Distributor ID:	CentOS
      Description:	CentOS Linux release 7.6.1810 (Core) 
      Release:	7.6.1810
      Codename:	Core
      
      posted in Linux Problems hostname change linux client
      A
      aknisly