All Entries Tagged With: "script"
Script for restoring multiple accounts from backup
The following script can be used to restore multiple accounts from the backups. It is assumed that all the backup files are already present in the /home directory in the tar.gz format. #!/bin/bash ####################### for i in `ls | grep tar.gz | cut -d- -f2 | cut -d. -f1` do echo “Restoring $i….” /scripts/restorepkg $i [...]
Shell script for packaging all accounts
Issue : How can I run a ‘pkgacct’ for all the accounts on the server in one go? Solution: Here’s a simple script to package all the accounts on your server : #!/bin/bash IFS=”$” /bin/ls — /var/cpanel/users | /bin/grep -v “\.\|root\|mysql\|nobody\|cpanel” | while read CPUSER; do /scripts/pkgacct “${CPUSER}” done
Useful cPanel scripts and their functions
Following are the cPanel scripts and their functions. adddns – Adds a DNS zone. addfpmail – Add frontpage mail extensions to all domains without them. addfpmail2 -Add frontpage mail extensions to all domains without them. addnetmaskips – Add the netmask 255.255.255.0 to all IPs that have no netmask. addnobodygrp – Adds the group nobody and [...]
Script to auto-delete emails older than a year
Issue : Emails older than a year need to be deleted automatically. Solution : You can use ‘find’ against the standard mail folders : find -P /home/*/mail/*/*/cur -mtime ‘+365′ find -P /home/*/mail/*/*/new -mtime ‘+365′ Note : 365 is the number of days in a year. You can change this number as per your requirement. This [...]
Script for clearing unwanted queued emails from the server
Here is a small but handy script which will clear the queued emails from the server. exim -bpc exim -bpru | grep frozen | awk {‘print $3′}|xargs exim -Mrm exim -bpru | grep “<>” | awk {‘print $3′}|xargs exim -Mrm exim -bpru | grep “nobody” | awk {‘print $3′}|xargs exim -Mrm exim -bpru|awk {‘print $3′}|xargs [...]
Log cleaner script
This script will clear the apache logs, cpanel logs and the logs in /var. It will take a zipped backup before clearing logs. #!/bin/bash # Script to Clear Logs echo “Clearing Logs in /var…..” cd /var/log for i in `ls -lSh /var/log|grep -v gz|grep “\-rw”|head -15|awk {‘print $9′}` do cp -p “$i” “$i”.bak echo “”>$i [...]
Script to list all the open ports
This could be a very good utility to check the open ports in the server. #!/bin/sh export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin if [ -e /etc/master.passwd ]; then netstat -an | grep LISTEN | grep “*” | awk ‘{print $4 }’ | cut -d. -f2 | sort -n | uniq else netstat -an | grep LISTEN | grep -v [...]
Script for Reseller check and Adding Vhost
Description: The following script will determine the shared user type I.E normal shared user, reseller or resold. In addition the script will also display the number of number of ModRails or Mongrel instances and the port used. While entering a reseller or resold account name the details of Mongrel / ModRails instances of all the [...]

1800 810 6547