/opt/fog/.fogsettings MySQL user can't make changes
-
Trying to run the script located here: Re: [SCRIPTS] Customization of Ubuntu - "Fog Service" for Ubuntu
The Master runs fine, but neither of the “host_rename_fog” runs (or should it really be rename_host_fog? OP is VERY unclear). Running the non-MySQL script on latest LTS Ubuntu (OP didn’t say run as a post-download script on fog server) it stops at “checking hostname/domain configurations” and shoots back to bash. I think it’s because on line 79 it’s just done instead of echo “done” and it crashes out or something (blame bad code or changes in the latest ubuntu?)
when I run the MySQL version it stops at :
“check FOG MySQL database status… error
failed to connect to server… exiting”this goes to the fact that seems what’s written in fog’s config (/opt/fog/.fogsettings = fogmaster learned from https://wiki.fogproject.org/wiki/index.php?title=Password_Central) does not have the rights to change anything somehow, looking like the database locked itself out?
I can login to MySQL with fogmaster but it’s as if the user is a standard unprivileged user who can’t make changes to MySQL.
also running the below I get errors:
MariaDB [fog]> GRANT ALL PRIVILEGES ON fog.* TO ‘fogmaster’@‘localhost’;
ERROR 1044 (42000): Access denied for user ‘fogmaster’@‘localhost’ to database ‘fog’INSERT INTO users (uName,uPass,uCreateDate,uCreateBy,uType,uDisplay,uAllowAPI,uAPIToken) VALUES(‘fog’,‘$2y$11$A2D/RijXM.qL7KYrMVo7f.Gfomq6vO6NpL6pEHQIY1OzUci7wBOjC’,‘2017-11-23 9:48:00’,‘localAdmin’,0,‘fog’,1,‘’);
quit -
@dvorak said in /opt/fog/.fogsettings MySQL user can't make changes:
MariaDB [fog]> GRANT ALL PRIVILEGES ON fog.* TO ‘fogmaster’@‘localhost’;
ERROR 1044 (42000): Access denied for user ‘fogmaster’@‘localhost’ to database ‘fog’Well it’s supposed to be this way if you are logged into mysql as fogmaster. Privileges in MySQL are stored in the internal
mysql
database (not thefog
database!) and the fogmaster mysql user is intentionally created for writing tofog
but not to other DBs. So granting privileges to fogmaster can’t be done if logged into MySQL as fogmaster.INSERT INTO users (uName,uPass,uCreateDate,uCreateBy,uType,uDisplay,uAllowAPI,uAPIToken) VALUES(‘fog’,’$2y$11$A2D/RijXM.qL7KYrMVo7f.Gfomq6vO6NpL6pEHQIY1OzUci7wBOjC’,‘2017-11-23 9:48:00’,‘localAdmin’,0,‘fog’,1,’’);
What do you get when running this query?
when I run the MySQL version it stops at :
“check FOG MySQL database status… error
failed to connect to server… exiting”The fogmaster mysql user created is only allowed to connect through localhost (not from a remote system) with security in mind. You can either use the fogstorage mysql user (intended to be used on storage nodes) or mess with the fogmaster privileges. If you want to use the fogstorage user, find credentials in the FOG web UI -> FOG Configuration -> FOG Settings -> FOG Storage Nodes …
-
@sebastian-roth Thanks I will give this a go today. My main concern is just allowing the MySql (or non MySQL) script to run. My final objective is getting FOG’s host rename to work with Ubuntu… we have over 40 dual-boot computers we image in one lab (over 300 computers total), and on the Linux side, we have to change the hostnames and join AD manually. Would be nice to get this automated at some point.
Thanks for your help
-
@sebastian-roth
Update I was able to make progress by fixing up the code per-say. I think the OP of the code (ch3i) wrote up something from memory and not from actual tests, and possibly update or make note of any changes in syntax as programs update.For instance, hostname --fqdn gives an error “hostname: unrecognized option ‘–fqdn’ BusyBox v1.31.1” so I changed to ‘hostname -f’.
I was able to get pass the original MySQL errors using your advice, and using the fogstorage account instead. Running both scripts on ubuntu still stops without reason at “checking hostname/domain configurations”. When I run it on FOG (As a postdownloadscript), and it runs after cloning the image,it stops at :
“Check Mysql Configuration: Done
Check FOG Mysql Database Status: Done
Checking hostname/domain configurations *Rebooting system as task is completed”
Reboot: restarting systembut upon reboot, I have the same hostname I myself set prior to capturing the image. Fog has a different hostname set to the MAC that I never changed, so if the script worked my hostname should reflect what FOG has.
IT never makes it to the next part which should say “updating /etc/hostname” nor saying “Done” or “host not found in fog database”. So I am thinking it’s stuck at these lines:
######################################################### # Get interfaces ######################################################### NETWORK_CARDS=($(ls /sys/class/net | grep eth)) ######################################################### # Get host name and domain from FoG database ######################################################### FUNC_DOTS "Checking hostname/domain configurations" for ETH in ${NETWORK_CARDS[*]} do # read mac address MAC=$(cat /sys/class/net/$ETH/address) # get mac address information from fog web server wget http://$FOG_SERVER/$FOG_WEBROOT/service/hostname.php?mac=$MAC -O /tmp/hostname_check 2>/dev/null HOST_NAME="$(grep 'ok=' /tmp/hostname_check | cut -d "=" -f2)" HOST_DOMAIN_NAME="$(grep 'ADDom' /tmp/hostname_check | cut -d "=" -f2)" if [ "$HOST_NAME" != "" ] then echo "Done ($HOST_NAME.$HOST_DOMAIN_NAME)" sleep 3 # A hostname is found - quit the loop break else echo "Error" FUNC_DOTS "Host not found in FOG database" echo "exiting" sleep 3 exit fi done
Final Update
I got it to work!
As first mentioned, I had to update the syntax as it’s been over 7 years since the code was written by OP (ch3i). The update that crashed the above code was :NETWORK_CARDS=($(ls /sys/class/net | grep eth))
To get it to work I swapped it to :
NETWORK_CARDS=($(ls /sys/class/net ))
I learned thru google there was a change (systemd?) that made ls /sys/class/net not use ETH anymore, rather showing something like “enp0s31f6” which is the same as ETH0, but showing the exact location. The code was looking for ETH so just removing that line fixed it.
Now that it works, I feel I can turn the code into a snap-in or post-download script.