New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Set username/password via cron?
Hello,
As I am running a website monitoring script for my free shared hosting where I want to have a demo account that is available for everyone, I'd like to setup a cron that sets the username/password of the public user to demo/demo every 15 minutes. The reason for this is some folks having the time of their life changing demo account credentials. I want to prevent this by resetting them every 15 mins. How would I go about this?
Comments
Is this for cPanel? I believe cPanel has a demo mode itself.
No for phpservermonitor (monitor.ympker.net). So Id need to somehow overwrite the respective value in the existing mysqldb where username/pw of the certain user is defined.
In that case I assume you could just write a quick and easy php script to connect to mysql and run the sql command to do an update and then have that script called via cron.
Good idea :P I might just attempt to do that^^
Off the top of my head, may need some adjustment. Potential typos. Python obviously. Requires pymysql. Assumes password function in MySQL is the proper format for the password, may very well not be.
You could also just break the ability to change the credentials in a demo app.
just disable/remove the change password function!
cron what, cron linux?
mysql -uuser -ppass -hlocalhost database -E 'update blabla'
Not very safe to add PW but well, script will have it anyway also. Root might not even need one either for MySQL.
You can just create a
~/.my.cnf
file with the credentials then the password won't appear in any process lists.That's how you need to do it as god knows what will be added/injected into the DB and/or files. If you're doing a demo it needs to reinstall files/DB completely every X interval. Easy enough to setup a cronjob to run your installer script.
Linux
As monitor script runs itself every x time. You can just add a small code to update password when checking uptime. Update time would be much less than 15m and processing would also be less
Currently trying to add a bashscript to cron but @jetchirag idea is also good
Or why not just disable password update function?
I didnt look at the files yet but that would be an option, too^^
No problem but I did a look at files. If you want to go this way.
on file: src/psm/Service/User.php
remove line 398-400 but if there's an uupdate, you'll have to do it again (not a big task tbh).
It works :P Thanks! Ive been a bit lazy tbh but you've done a well job there mate!
Speaking of which if you have a BTC wallet I can send you some so you can go buy yourself a cup of coffee^^ You've earned it
Thanks, nevermind :P
P.S. I don't really have a BTC wallet. Never used it tbh :P