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.
Need help with a cP script
Hello,
I am wondering if someone here can help me with a small script.
I need to go into each cPanel user's public_html directory, download a scrip file (or copy from the same server) and execute it. (Basically trying to patch a security vulnerability across all sites). I can do one by one but wondering if there is a better way to do it.
So it be like,
1) Get a list of all cPanel users and Run in a loop 2) cd /home/$username/public_html 3) wget www.joomla.org/patch-001.sh (or cp /root/patch-001.sh /home/$username/public_html/) 4) sh patch-001.sh 5) sleep 10
Can someone here help me with something like this or point me in a direction what would be the best way to do it?
Thanks
Comments
Get list of all users - ls /var/cpanel/users
Run a for loop through this list. On phone, can't post the full script
Maybe you should not use it as root,
a bit of help for yourself
user=$(ls /var/cpanel/users)
runuser -l $user -c 'cd /home/$username/public_html'
I can write a python script to do this for $$