Skip to content

Instantly share code, notes, and snippets.

@mdpuma
Last active April 23, 2019 04:24
Show Gist options
  • Select an option

  • Save mdpuma/27a15043bc2fa083e4e805dbbd1678f5 to your computer and use it in GitHub Desktop.

Select an option

Save mdpuma/27a15043bc2fa083e4e805dbbd1678f5 to your computer and use it in GitHub Desktop.
cpanel useful commands
#!/bin/bash
# change ip address for accounts (included DNS records)
grep $OLD_IP /var/cpanel/users/* | cut -d: -f1 | xargs -n1 basename | xargs -tI{} /usr/local/cpanel/bin/setsiteip -u {} $NEW_IP
#!/bin/bash -xe
IFS=","
cat iplist.txt | while read -r ip user; do
/usr/local/cpanel/bin/setsiteip -u $user $ip
done
# standard ftp server which is included with cPanel have limit on files shown by command ls
# https://linux.die.net/man/8/pure-ftpd
# -L max files:max depth
# Avoid denial-of-service attacks by limiting the number of displayed files in a 'ls' and the maximum depth of a recursive 'ls'.
# Defaults are 2000:5 (2000 files displayed for a single 'ls' and walk through 5 subdirectories max).
#!/bin/bash
# Enable shell access for account from SSH, without accessing web WHM
whmapi1 modifyacct user=USER shell=true
#!/bin/bash
# show mysql databases usage by accounts
cd /var/lib/mysql;
ls | cut -d_ -f1 | sort -u | while read i; do
SIZE="`du -chsBM $i* | grep total | awk '{ print $1 }'`";
echo "$i: $SIZE";
done | sort -k2 -n
# show mysql databases count by accounts
cd /var/lib/mysql;
ls | cut -d_ -f1 | sort -u | while read i; do
COUNT="`ls -d $i* | wc -l`";
echo "$i: $COUNT";
done | sort -k2 -n
#!/bin/bash
cat /etc/userdomains | cut -d: -f2 | sort -u | xargs -I{} cl-quota -S 150000 -H 150000 -u {}
cl-quota -P | sed -E 's/\s{2,}/,/g' | cut -d ',' -f2 | xargs -tI{} cl-quota -S 150000 -H 150000 -p '{}'
#!/bin/bash
/usr/local/cpanel/scripts/update_local_rpm_versions --edit target_settings.munin unmanaged
# run this
/usr/local/cpanel/bin/checkallsslcerts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment