Script to transfer an restore mass cPanel accounts.
cPanel Data transfer.
Setup the servers to ‘SSH without password.
The below given is the script to transfer.
#!/bin/bash
for i in `cat /etc/trueuserdomains | awk -F: ‘{print $2}’`
do
/bin/echo “$i”
/scripts/pkgacct $i
file=$(ls /home/cpmove*$i*)
/bin/echo “$file”
scp -P PORT $file root@IP:/root
wait
ls -lh $file
rm -rf $file
done
cPanel Data restoration.
The script is given below. Move to the location whether the cpmove files are located and then execute the following.
# ls cpmove-*.tar.gz | awk -F- ‘{print $2}’ | awk -F. ‘{print $1}’ > file
# for i in `cat file`; do /scripts/restorepkg $i; done
Creating a Ruby On Rails application in Cpanel
Ruby On Rails icon is there in cpanel theme from cpanel 11 onwards.
You can create a Ruby On Rails application in cpanel by following steps given below.
1. Login to cpanel
2. Click on the Ruby On Rails Icon in cpanel.
3. Fill in the “App Name” box with the application name you want to use.
4. Check the box for “Load on boot’.
5. Application Path will be automatically filled in as public_html/application_name.
You can create the application in this location itself. But, if you are installing this inside public_html, the configuration files will be public and everyone can access it. In order to avoid this, change the permission of the configuration files to 600. The main configuration file in which mysql passwords are stored is database.yml(Path: path_to_application/config/database.yml).
Or, you can install the application outside the public_html directory(in the home directory itself). Then you should set redirect to this application through apache to the mongrel port from the cpanel >> Ruby On rails>>Redirects. Mongrel is the default webserver for RoR applications, which will be installed in the server when we install ruby using using /scripts/installruby.
6. Select the environment. The default environment in which the application will be created is ‘production’.
7. Click “Create”.
Application will be created in the specified path.
All the newly created application will be using a port(>12000).
If the application name is test and installation directory /home/username/public_html/test, then you can access the application using http://domainname/test/public/ (Use ‘/’ at the end which is the good method).
How to enable viewing HTML content in Horde.
By default it is not possible for us to view the emails in HTML format using Horde webmail interface. All the html content will be displayed at the top of the page and will be requested to download.
To fix this issue, you have to enable “Inline HTML message viewing” for Horde in the server.
To enable “Inline html message viewing” you can perform the following steps:
1. Goto the horde imp configuration folder at /usr/local/cpanel/base/horde/imp/config
2. Edit the file mime_drivers.php using your favorite editor.
3. Change the following line
————————————————————
$mime_drivers['imp']['plain']['inline'] = false;
————————————————————
To
————————————————————
$mime_drivers['imp']['plain']['inline'] = true;
————————————————————
4. Restart the cpanel service in the server.
Now you will be able to view the html content using Horde webmail interface.
How to disable the the stats services(Analog or Awstats or Webalizer stats)
You can disable Analog or Awstats or Webalizer stats in a cpanel server via backend by editing the file “/var/cpanel/cpanel.config”.
Check for the variables skipanalog, skipawstats, skipwebalizer in the file and change the values of the variables to one. Now the variables should look like as follows:
skipanalog=1
skipawstats=1
skipwebalizer=1
Save the changes and restart the cpanel service in the server.
/etc/init.d/cpanel restart
Now the all the three stats will be disabled server wide.
Enable quotas in cpanel server
If quotas are not enabled for the partition, the following error will occur while doing a quotacheck in the server. In case of Cpanel server, /scripts/initquotas will throw the following error.
/scripts/initquotas
Quotas are now on
Updating Quota Files……
quotacheck: Can’t find filesystem to check or filesystem not mounted with quota option.
quotacheck: Can’t find filesystem to check or filesystem not mounted with quota option.
….Done
You need to follow the steps given below:
$ touch /quota.user /quota.group
$ chmod 600 /quota.*
$ mount -o remount /
$ quotaoff -a
$ vi /etc/fstab
( open ‘fstab’ file and add usrquota,grpquota to the partition where you want to have quota on. That is, for example, add the entry like:
/dev/ubd0 / ext3 defaults,noatime,usrquota,grpquota 1 0 )
$ quotaon -a
You should be able to run a quotacheck nor /scripts/initquotas in your cpanel server without any problem.