<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Script Archives - Vavai&#039;s Personal Notes</title>
	<atom:link href="https://www.vavai.net/tag/script/feed/" rel="self" type="application/rss+xml" />
	<link>https://vavai.net/tag/script/</link>
	<description>Life is our precious gift</description>
	<lastBuildDate>Sun, 28 Oct 2018 12:40:49 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>Script to Add Dynamic IP to /etc/hosts</title>
		<link>https://www.vavai.net/script-to-add-dynamic-ip-to-etc-hosts/</link>
					<comments>https://www.vavai.net/script-to-add-dynamic-ip-to-etc-hosts/#respond</comments>
		
		<dc:creator><![CDATA[Muhammad Rivai]]></dc:creator>
		<pubDate>Sun, 28 Oct 2018 12:40:49 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Script]]></category>
		<guid isPermaLink="false">http://v2.vavai.net/?p=2095</guid>

					<description><![CDATA[<p>I have a dynamic IP from my internet service provider and sometimes it takes longer to SSH to my server as it needs to resolve the address. On static IP, I can put the address into public DNS server to a quick resolving process,  but as it uses dynamic IP, I would need to use...</p>
<p>The post <a href="https://www.vavai.net/script-to-add-dynamic-ip-to-etc-hosts/">Script to Add Dynamic IP to /etc/hosts</a> appeared first on <a href="https://www.vavai.net">Vavai&#039;s Personal Notes</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I have a dynamic IP from my internet service provider and sometimes it takes longer to SSH to my server as it needs to resolve the address. On static IP, I can put the address into public DNS server to a quick resolving process,  but as it uses dynamic IP, I would need to use a different approach.<br />
<img fetchpriority="high" decoding="async" src="http://54.254.121.108/wp-content/uploads/2018/10/bash-1.jpg" alt="" width="640" height="270" class="alignnone size-full wp-image-2098" srcset="https://d3b35uem336dgh.cloudfront.net/wp-content/uploads/2018/10/bash-1.jpg 640w, https://d3b35uem336dgh.cloudfront.net/wp-content/uploads/2018/10/bash-1-300x127.jpg 300w" sizes="(max-width: 640px) 100vw, 640px" /><br />
As I have dynamic DNS from Synology (can also work with other DDNS provider), a little bash script below can help me to automatically add IP on an interval basis, replace the selected predefined row on /etc/hosts.<br />
Script : add-host-markasdj.sh<br />
[code lang=&#8221;bash&#8221;]<br />
FILE=&#8221;/etc/hosts&#8221;<br />
ip=`nslookup myhomesweethome.myds.me | grep -i addr | grep -v &#8220;#&#8221; | cut -d &#8220;:&#8221; -f2 | sed -e &#8216;s/^[[:space:]]*//&#8217;`<br />
if grep -q $ip $FILE;<br />
then<br />
	echo &#8220;Ignore, IP has been previously added&#8221;<br />
else<br />
	echo &#8220;$ip	myhomesweethome.myds.me&#8221; >> /etc/hosts<br />
	echo &#8220;$ip has been added to /etc/hosts&#8221;<br />
fi<br />
#echo &#8220;IP:$ip&#8221;<br />
[/code]</p>
<p>The post <a href="https://www.vavai.net/script-to-add-dynamic-ip-to-etc-hosts/">Script to Add Dynamic IP to /etc/hosts</a> appeared first on <a href="https://www.vavai.net">Vavai&#039;s Personal Notes</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.vavai.net/script-to-add-dynamic-ip-to-etc-hosts/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Script to Remove Over Quota Message from Zimbra Queue</title>
		<link>https://www.vavai.net/script-to-remove-over-quota-message-from-zimbra-queue/</link>
					<comments>https://www.vavai.net/script-to-remove-over-quota-message-from-zimbra-queue/#respond</comments>
		
		<dc:creator><![CDATA[Muhammad Rivai]]></dc:creator>
		<pubDate>Fri, 26 Oct 2018 14:19:30 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Zimbra]]></category>
		<guid isPermaLink="false">http://v2.vavai.net/?p=2087</guid>

					<description><![CDATA[<p>Sometimes we have a bunch of over quota message filling up Zimbra queue, with detail as below : 197CF170F9 59761 Wed Oct 24 09:49:48   email-palsu@vivianchow.id (host alt1.gmail-smtp-in.l.google.com[74.125.195.27] said: 452-4.2.2 The email account that you tried to reach is over quota. Please direct 452-4.2.2 the recipient to 452 4.2.2 https://support.google.com/mail/?p=OverQuotaTemp m3-v6si2776998pld.435 &#8211; gsmtp (in reply to...</p>
<p>The post <a href="https://www.vavai.net/script-to-remove-over-quota-message-from-zimbra-queue/">Script to Remove Over Quota Message from Zimbra Queue</a> appeared first on <a href="https://www.vavai.net">Vavai&#039;s Personal Notes</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Sometimes we have a bunch of over quota message filling up Zimbra queue, with detail as below :<br />
<em>197CF170F9 59761 Wed Oct 24 09:49:48   email-palsu@vivianchow.id</em><br />
<em>(host alt1.gmail-smtp-in.l.google.com[74.125.195.27] said: 452-4.2.2 The email account that you tried to reach is over quota. Please direct 452-4.2.2 the recipient to 452 4.2.2 https://support.google.com/mail/?p=OverQuotaTemp m3-v6si2776998pld.435 &#8211; gsmtp (in reply to RCPT TO command))</em><br />
<em>email-palsu@gmail.com</em><br />
The email message will be automatically removed from the queue after a while, depending on our queue lifetime setting on the server. If we want to automatically remove on the selected time interval, we can then set up crontab to run the following script :<br />
<strong>del-over-quota.sh</strong><br />
[code lang=&#8221;bash&#8221;]<br />
#!/bin/sh<br />
clear<br />
/opt/zimbra/postfix/sbin/postqueue -p | grep -A 1 &#8220;over quota&#8221; | grep @ | sort | uniq > /tmp/over-quota.txt<br />
USERS=`cat /tmp/over-quota.txt`<br />
echo &#8220;Looping for all users&#8221;<br />
for ACCOUNT in $USERS; do<br />
#Remove over quota queue<br />
echo &#8220;Account over quota : $ACCOUNT&#8221;<br />
pfdel $ACCOUNT<br />
echo &#8220;&#8221;<br />
done<br />
echo &#8220;All over quota queue has been removed successfully&#8221;<br />
[/code]<br />
The above script is run together with <a href="http://v2.vavai.net/2018/10/bash-script-for-spam-queue-removal-on-zimbra-mail-server-updated/">pfdel</a> script, so don&#8217;t forget to download and save pfdel script as well.</p>
<p>The post <a href="https://www.vavai.net/script-to-remove-over-quota-message-from-zimbra-queue/">Script to Remove Over Quota Message from Zimbra Queue</a> appeared first on <a href="https://www.vavai.net">Vavai&#039;s Personal Notes</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.vavai.net/script-to-remove-over-quota-message-from-zimbra-queue/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Script to Delete the Spam Queue on Zimbra with Confirmation</title>
		<link>https://www.vavai.net/script-to-delete-the-spam-queue-on-zimbra-with-confirmation/</link>
					<comments>https://www.vavai.net/script-to-delete-the-spam-queue-on-zimbra-with-confirmation/#respond</comments>
		
		<dc:creator><![CDATA[Muhammad Rivai]]></dc:creator>
		<pubDate>Sat, 20 Oct 2018 02:43:16 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Spam]]></category>
		<category><![CDATA[Zimbra]]></category>
		<guid isPermaLink="false">http://v2.vavai.net/?p=2047</guid>

					<description><![CDATA[<p>On previous script, we can delete spam from queue by passing sender or recipient address on the script : [code lang=&#8221;bash&#8221;] pfdel email-spammer [/code] But what about situation where spammer filling up queue with random sender and recipient, and it tooks time to delete each message. Yes, we can use Postfix powerful binary, with postsuper...</p>
<p>The post <a href="https://www.vavai.net/script-to-delete-the-spam-queue-on-zimbra-with-confirmation/">Script to Delete the Spam Queue on Zimbra with Confirmation</a> appeared first on <a href="https://www.vavai.net">Vavai&#039;s Personal Notes</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>On <a href="http://v2.vavai.net/2018/10/bash-script-for-spam-queue-removal-on-zimbra-mail-server-updated/">previous script</a>, we can delete spam from queue by passing sender or recipient address on the script :<br />
[code lang=&#8221;bash&#8221;]<br />
pfdel email-spammer<br />
[/code]<br />
<img decoding="async" class="alignnone size-medium wp-image-2049" src="http://v2.vavai.net/wp-content/uploads/2018/10/email-300x108.png" alt="" width="300" height="108" srcset="https://d3b35uem336dgh.cloudfront.net/wp-content/uploads/2018/10/email-300x108.png 300w, https://d3b35uem336dgh.cloudfront.net/wp-content/uploads/2018/10/email.png 640w" sizes="(max-width: 300px) 100vw, 300px" /><br />
But what about situation where spammer filling up queue with random sender and recipient, and it tooks time to delete each message. Yes, we can use Postfix powerful binary, with <strong>postsuper -d ALL</strong> but it will remove entire message, including normal message.<br />
Below is a modified script, to delete spam queue by confirming whether the message are legitimate or not. It will display sender and recipient so we can check each message accordingly.<br />
[code lang=&#8221;bash&#8221;]<br />
#!/bin/sh<br />
#Hapus Layar<br />
clear<br />
/opt/zimbra/postfix/sbin/postqueue -p | grep -A 1 &#8220;$1&#8221; | grep @ | sort | uniq | cut -d &#8220;:&#8221; -f3 | cut -d &#8221; &#8221; -f3 > /tmp/over-quota.txt<br />
USERS=`cat /tmp/over-quota.txt`<br />
echo &#8220;Looping for all users&#8221;<br />
for ACCOUNT in $USERS; do<br />
ACC1=`echo $ACCOUNT | awk -F@ &#8216;{print $1}&#8217;`;<br />
ACC2=`echo $ACCOUNT | cut -d &#8216;.&#8217; -f1`<br />
#echo $ACC1<br />
#echo $ACC2<br />
/opt/zimbra/postfix/sbin/postqueue -p | grep $ACCOUNT -A 3<br />
echo -n &#8220;Remove queue for account : $ACCOUNT [Y/N]? &#8221;<br />
read TANYA<br />
if [ $TANYA == Y ] || [ $TANYA == y ]; then<br />
pfdel $ACCOUNT<br />
fi<br />
echo &#8220;&#8221;<br />
done<br />
echo &#8220;Removal queue messages for $1 has been completed successfully&#8221;<br />
[/code]<br />
The script will also takes time if queue contains too many spam messages, so a better choice is to prevent spam by strengthening server anti spam and enforcing a tight security policy.</p>
<p>The post <a href="https://www.vavai.net/script-to-delete-the-spam-queue-on-zimbra-with-confirmation/">Script to Delete the Spam Queue on Zimbra with Confirmation</a> appeared first on <a href="https://www.vavai.net">Vavai&#039;s Personal Notes</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.vavai.net/script-to-delete-the-spam-queue-on-zimbra-with-confirmation/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Bash Script for Spam Queue Removal on Zimbra Mail Server (Updated)</title>
		<link>https://www.vavai.net/bash-script-for-spam-queue-removal-on-zimbra-mail-server-updated/</link>
					<comments>https://www.vavai.net/bash-script-for-spam-queue-removal-on-zimbra-mail-server-updated/#respond</comments>
		
		<dc:creator><![CDATA[Muhammad Rivai]]></dc:creator>
		<pubDate>Thu, 18 Oct 2018 13:00:03 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mail Server]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Spam]]></category>
		<category><![CDATA[Zimbra]]></category>
		<guid isPermaLink="false">http://v2.vavai.net/?p=2036</guid>

					<description><![CDATA[<p>I have a small script-got it from Internet-for Zimbra spam queue removal based on Postfix queue message removal. The script written on Perl language and become a mandatory script on each Zimbra server deployment, as a quick tools to remove spam message from queue caused by compromised account. As of Zimbra 8.7, there is a little...</p>
<p>The post <a href="https://www.vavai.net/bash-script-for-spam-queue-removal-on-zimbra-mail-server-updated/">Bash Script for Spam Queue Removal on Zimbra Mail Server (Updated)</a> appeared first on <a href="https://www.vavai.net">Vavai&#039;s Personal Notes</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I have a small script-got it from Internet-for Zimbra spam queue removal based on Postfix queue message removal. The script written on Perl language and become a mandatory script on each Zimbra server deployment, as a quick tools to remove spam message from queue caused by compromised account.<br />
<figure id="attachment_2038" aria-describedby="caption-attachment-2038" style="width: 1280px" class="wp-caption alignnone"><img decoding="async" class="wp-image-2038 size-full" src="http://54.254.121.108/wp-content/uploads/2018/10/phising.png" alt="" width="1280" height="977" srcset="https://d3b35uem336dgh.cloudfront.net/wp-content/uploads/2018/10/phising.png 1280w, https://d3b35uem336dgh.cloudfront.net/wp-content/uploads/2018/10/phising-300x229.png 300w, https://d3b35uem336dgh.cloudfront.net/wp-content/uploads/2018/10/phising-1024x782.png 1024w, https://d3b35uem336dgh.cloudfront.net/wp-content/uploads/2018/10/phising-768x586.png 768w" sizes="(max-width: 1280px) 100vw, 1280px" /><figcaption id="caption-attachment-2038" class="wp-caption-text">image from pixabay</figcaption></figure><br />
As of Zimbra 8.7, there is a little change on path for some Postfix binary. On previous version, Postfix binary located on <strong>/opt/zimbra/postfix/ </strong>but since version 8.7, the binary folder moved into <strong>/opt/zimbra/common/ </strong>so I take a little time to change the script.<br />
Below is an updated script, check for Zimbra version and change binary folder accordingly :<br />
[code lang=&#8221;bash&#8221;]<br />
#!/usr/bin/perl -w<br />
#<br />
# pfdel &#8211; deletes message containing specified address from<br />
# Postfix queue. Matches either sender or recipient address.<br />
#<br />
# Usage: pfdel sender-or-recipient-address<br />
#<br />
use strict;<br />
my $LISTQ;<br />
my $POSTSUPER;<br />
# Change these paths if necessary.<br />
system(&#8220;su &#8211; zimbra -c &#8216;zmcontrol -v&#8217; &gt; /tmp/zcs-ver.txt&#8221;);<br />
my $VER=`awk &#8216;/Release 6|Release 7|Release 8.0|Release 8.5|Release 8.6/&#8217; /tmp/zcs-ver.txt`;<br />
#print $VER<br />
if (length($VER) &gt; 0)<br />
{<br />
$LISTQ = &#8220;/opt/zimbra/postfix/sbin/postqueue -p&#8221;;<br />
$POSTSUPER = &#8220;/opt/zimbra/postfix/sbin/postsuper&#8221;;<br />
}<br />
else<br />
{<br />
$LISTQ = &#8220;/opt/zimbra/common/sbin/postqueue -p&#8221;;<br />
$POSTSUPER = &#8220;/opt/zimbra/common/sbin/postsuper&#8221;;<br />
}<br />
my $email_addr = &#8220;&#8221;;<br />
my $qid = &#8220;&#8221;;<br />
my $euid = $&gt;;<br />
if ( @ARGV != 1 ) {<br />
die &#8220;Usage: pfdel \n&#8221;;<br />
} else {<br />
$email_addr = $ARGV[0];<br />
}<br />
if ( $euid != 0 ) {<br />
die &#8220;You must be root to delete queue files.\n&#8221;;<br />
}<br />
open(QUEUE, &#8220;$LISTQ |&#8221;) ||<br />
die &#8220;Can&#8217;t get pipe to $LISTQ: $!\n&#8221;;<br />
my $entry = ; # skip single header line<br />
$/ = &#8220;&#8221;; # Rest of queue entries print on<br />
# multiple lines.<br />
while ( $entry = ) {<br />
if ( $entry =~ / $email_addr$/m ) {<br />
($qid) = split(/\s+/, $entry, 2);<br />
$qid =~ s/[\*\!]//;<br />
next unless ($qid);<br />
#<br />
# Execute postsuper -d with the queue id.<br />
# postsuper provides feedback when it deletes<br />
# messages. Let its output go through.<br />
#<br />
if ( system($POSTSUPER, &#8220;-d&#8221;, $qid) != 0 ) {<br />
# If postsuper has a problem, bail.<br />
die &#8220;Error executing $POSTSUPER: error &#8221; .<br />
&#8220;code &#8221; . ($?/256) . &#8220;\n&#8221;;<br />
}<br />
}<br />
}<br />
close(QUEUE);<br />
if (! $qid ) {<br />
die &#8220;No messages with the address &lt;$email_addr&gt; &#8221; .<br />
&#8220;found in queue.\n&#8221;;<br />
}<br />
exit 0;<br />
[/code]<br />
If you tend to lazy to copy-paste the script, get it from mine :<br />
[code lang=&#8221;bash&#8221;]<br />
wget https://www.vavai.com/pfdel<br />
chmod +x pfdel<br />
[/code]<br />
And to run it, just run this script with root permissions :<br />
[code lang=&#8221;bash&#8221;]<br />
./pfdel email-spammer<br />
[/code]<br />
ex :<br />
[code lang=&#8221;bash&#8221;]<br />
./pfdel spammersampah@vavai.com<br />
[/code]<br />
However, this is only a quick tools to remove spam, but more importantly is prevent spam from being filling into queue.</p>
<p>The post <a href="https://www.vavai.net/bash-script-for-spam-queue-removal-on-zimbra-mail-server-updated/">Bash Script for Spam Queue Removal on Zimbra Mail Server (Updated)</a> appeared first on <a href="https://www.vavai.net">Vavai&#039;s Personal Notes</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.vavai.net/bash-script-for-spam-queue-removal-on-zimbra-mail-server-updated/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Script for Export-Import Zimbra Mail Server Account &#038; Password</title>
		<link>https://www.vavai.net/script-for-export-import-zimbra-mail-server-account-password/</link>
					<comments>https://www.vavai.net/script-for-export-import-zimbra-mail-server-account-password/#comments</comments>
		
		<dc:creator><![CDATA[Muhammad Rivai]]></dc:creator>
		<pubDate>Fri, 06 Aug 2010 02:19:22 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[LDAP]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Zimbra]]></category>
		<guid isPermaLink="false">http://v2.vavai.net/?p=1229</guid>

					<description><![CDATA[<p>Zimbra save all account and profile information on the LDAP database. Zimbra has no function for only import and export it&#8217;s account, although they have bundled Zimbra to Zimbra migration command. The Zimbra to Zimbra migration command export all mailbox and account while I only need a list of account with some primary fields like...</p>
<p>The post <a href="https://www.vavai.net/script-for-export-import-zimbra-mail-server-account-password/">Script for Export-Import Zimbra Mail Server Account &#038; Password</a> appeared first on <a href="https://www.vavai.net">Vavai&#039;s Personal Notes</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><a class="highslide" onclick="return vz.expand(this)" href="http://v2.vavai.net/wp-content/uploads/2010/08/zimbra-opensuse1.jpg"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-1240" title="zimbra-opensuse1" src="http://v2.vavai.net/wp-content/uploads/2010/08/zimbra-opensuse1.jpg" alt="" width="125" height="125" /></a><br />
Zimbra save all account and profile information on the LDAP database. Zimbra has no function for only import and export it&#8217;s account, although they have bundled Zimbra to Zimbra migration command. The Zimbra to Zimbra migration command export all mailbox and account while I only need a list of account with some primary fields like password, first name, full name, etc, especially for testing purpose only.<br />
I decided to create a simple script that look for related information on Zimbra LDAP with the following algorithm :</p>
<ol>
<li>CheckÂ  Zimbra version, because Zimbra 5 and Zimbra 6 has different method for accessing LDAP and also these are a few changes on Zimbra CLI. Zimbra 6 need paramater for command while Zimbra 5 doesn&#8217;t need it, e.g, on Zimbra 5, running <strong>zmprov gaa</strong> will list all Zimbra account but on Zimbra 6 we must use <strong>zmprov -l gaa </strong>to display same result.</li>
<li>Export all  account profile to temporary parameter and loop for all account</li>
<li>Skip all system account : admin, ham, spam, galsync and wiki. All these system account doesn&#8217;t need to be exported because Zimbra will create all system account on installation process.</li>
<li>Get all account identity/fields from Zimbra LDAP by usingÂ  LDAPsearch command</li>
<li>Create a text file with zmp extension. This file will containsÂ  zmprov ca command with proper parameter from step 4</li>
<li>Create  ldif file for updating Zimbra LDAP password, because Zimbra LDAP using SSHA encryption and the better method for updating Zimbra LDAP password is using ldapmodify command.</li>
<li>Finish</li>
</ol>
<p>Algorithm for  Import Account</p>
<ol>
<li>Check whether user are already on Zimbra user environment or not</li>
<li>Check is there existingÂ  zmp and ldif file (the result from export script)</li>
<li>Import zmp file</li>
<li>Run ldapmodify command to change Zimbra LDAP password by usingÂ  ldif data</li>
<li>Finish</li>
</ol>
<p>Please remember that you must running exportÂ  script by using root privilegeÂ  but theÂ  import account must be run withinÂ  Zimbra user environment (su &#8211; zimbra).<br />
Look at following example to run Zimbra Account export script :<br />
[code language=&#8217;cpp&#8217;]<br />
su<br />
cd /srv<br />
wget -c http://vavai.com/wp-content/uploads/exim-acc-zcs.tar.gz<br />
tar -zxvf exim-acc-zcs.tar.gz<br />
cd exim-acc-zcs<br />
./export-acc-zcs.sh<br />
[/code]<br />
The above command will produceÂ  zcs-acc-add.zmp and zcs-acc-mod.ldif file. Copy all four file (the last two areÂ  script file) onto some folder on target server and run the following command to import the account and it&#8217;s profile :<br />
[code language=&#8217;cpp&#8217;]<br />
su<br />
su &#8211; zimbra<br />
cd /home/vavai<br />
./import-acc-zcs.sh<br />
[/code]<br />
Script has been sucessfully tested on  Zimbra 6.0.5, 6.0.6 dan 6.0.7 on SUSE Linux Enterprise Server 11 and openSUSE 11.<br />
<a class="highslide" onclick="return vz.expand(this)" href="http://54.254.121.108/wp-content/uploads/2010/08/export-account-zcs1.jpeg"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-1245" title="export-account-zcs" src="http://54.254.121.108/wp-content/uploads/2010/08/export-account-zcs1.jpeg" alt="" width="428" height="230" /></a><br />
Download Zimbra Account Export-Import Script by click on the download icon belows :<br />
<a href="http://vavai.com/wp-content/uploads/exim-acc-zcs.tar.gz"><img decoding="async" src="http://vavai.com/wp-content/uploads/2010/06/Download.png" alt="" /></a><br />
Script for export :<br />
[code language=&#8217;cpp&#8217;]<br />
#!/bin/sh<br />
#Hapus Layar<br />
clear<br />
echo -e &#8220;###################################################################################&#8221;<br />
echo -e &#8220;# Zimbra export-acc-zcs.sh ver 0.0.2                                              #&#8221;<br />
echo -e &#8220;# Skrip untuk export account Zimbra berikut profile dan password                  #&#8221;<br />
echo -e &#8220;# Masim &#8216;Vavai&#8217; Sugianto &#8211; vavai@vavai.com &#8211; http://www.vavai.com                 #&#8221;<br />
echo -e &#8220;# Untuk saran dan pertanyaan silakan menggunakan Milis Komunitas Zimbra Indonesia #&#8221;<br />
echo -e &#8220;# Link Komunitas : http://www.zimbra.web.id &#8211; http://www.opensuse.or.id           #&#8221;<br />
echo -e &#8220;###################################################################################&#8221;<br />
# /* Variable untuk bold */<br />
ibold=&#8221; 33[1m&#8221;&#8221;n===> &#8221;<br />
ebold=&#8221; 33[0m&#8221;<br />
# /* Parameter */<br />
echo &#8220;&#8221;<br />
echo -n &#8220;Enter Domain Name (ex : vavai.com) : &#8221;<br />
read NAMA_DOMAIN<br />
echo -n &#8220;Enter path folder for exported account (ex : /home/vavai/) : &#8221;<br />
read FOLDER<br />
# /* Membuat file hasil export dan mengisi nama domain */<br />
NAMA_FILE=&#8221;$FOLDER/zcs-acc-add.zmp&#8221;<br />
LDIF_FILE=&#8221;$FOLDER/zcs-acc-mod.ldif&#8221;<br />
rm -f $NAMA_FILE<br />
rm -f $LDIF_FILE<br />
touch $NAMA_FILE<br />
touch $LDIF_FILE<br />
echo &#8220;createDomain $NAMA_DOMAIN&#8221; > $NAMA_FILE<br />
# /* Check versi Zimbra yang digunakan */<br />
VERSION=`su &#8211; zimbra -c &#8216;zmcontrol -v&#8217;`;<br />
ZCS_VER=&#8221;/tmp/zcsver.txt&#8221;<br />
# get Zimbra LDAP password<br />
ZIMBRA_LDAP_PASSWORD=`su &#8211; zimbra -c &#8220;zmlocalconfig -s zimbra_ldap_password | cut -d &#8216; &#8216; -f3&#8243;`<br />
touch $ZCS_VER<br />
echo $VERSION > $ZCS_VER<br />
echo -e $ibold&#8221;Retrieve Zimbra User&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8221;$ebold<br />
grep &#8220;Release 5.&#8221; $ZCS_VER<br />
if [ $? = 0 ]; then<br />
USERS=`su &#8211; zimbra -c &#8216;zmprov gaa&#8217;`;<br />
LDAP_MASTER_URL=`su &#8211; zimbra -c &#8220;zmlocalconfig -s ldap_master_url | cut -d &#8216; &#8216; -f3&#8243;`<br />
fi<br />
grep &#8220;Release 6.&#8221; $ZCS_VER<br />
if [ $? = 0 ]; then<br />
USERS=`su &#8211; zimbra -c &#8216;zmprov -l gaa&#8217;`;<br />
LDAP_MASTER_URL=&#8221;ldapi:///&#8221;<br />
fi<br />
echo -e $ibold&#8221;Processing account, please wait&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8221;$ebold<br />
# /* Proses insert account kedalam file hasil export */<br />
for ACCOUNT in $USERS; do<br />
NAME=`echo $ACCOUNT`;<br />
DOMAIN=`echo $ACCOUNT | awk -F@ &#8216;{print $2}&#8217;`;<br />
ACCOUNT=`echo $ACCOUNT | awk -F@ &#8216;{print $1}&#8217;`;<br />
ACC=`echo $ACCOUNT | cut -d &#8216;.&#8217; -f1`<br />
if [ $NAMA_DOMAIN == $DOMAIN ] ;<br />
then<br />
OBJECT=&#8221;(&#038;(objectClass=zimbraAccount)(mail=$NAME))&#8221;<br />
dn=`/opt/zimbra/bin/ldapsearch -H $LDAP_MASTER_URL -w $ZIMBRA_LDAP_PASSWORD -D uid=zimbra,cn=admins,cn=zimbra -x $OBJECT | grep dn:`<br />
displayName=`/opt/zimbra/bin/ldapsearch -H $LDAP_MASTER_URL -w $ZIMBRA_LDAP_PASSWORD -D uid=zimbra,cn=admins,cn=zimbra -x $OBJECT | grep displayName: | cut -d &#8216;:&#8217; -f2 | sed &#8216;s/^ *//g&#8217; | sed &#8216;s/ *$//g&#8217;`<br />
givenName=`/opt/zimbra/bin/ldapsearch -H $LDAP_MASTER_URL -w $ZIMBRA_LDAP_PASSWORD -D uid=zimbra,cn=admins,cn=zimbra -x $OBJECT | grep givenName: | cut -d &#8216;:&#8217; -f2 | sed &#8216;s/^ *//g&#8217; | sed &#8216;s/ *$//g&#8217;`<br />
userPassword=`/opt/zimbra/bin/ldapsearch -H $LDAP_MASTER_URL -w $ZIMBRA_LDAP_PASSWORD -D uid=zimbra,cn=admins,cn=zimbra -x $OBJECT | grep userPassword: | cut -d &#8216;:&#8217; -f3 | sed &#8216;s/^ *//g&#8217; | sed &#8216;s/ *$//g&#8217;`<br />
cn=`/opt/zimbra/bin/ldapsearch -H $LDAP_MASTER_URL -w $ZIMBRA_LDAP_PASSWORD -D uid=zimbra,cn=admins,cn=zimbra -x $OBJECT | grep cn: | cut -d &#8216;:&#8217; -f2 | sed &#8216;s/^ *//g&#8217; | sed &#8216;s/ *$//g&#8217;`<br />
initials=`/opt/zimbra/bin/ldapsearch -H $LDAP_MASTER_URL -w $ZIMBRA_LDAP_PASSWORD -D uid=zimbra,cn=admins,cn=zimbra -x $OBJECT | grep initials: | cut -d &#8216;:&#8217; -f2 | sed &#8216;s/^ *//g&#8217; | sed &#8216;s/ *$//g&#8217;`<br />
sn=`/opt/zimbra/bin/ldapsearch -H $LDAP_MASTER_URL -w $ZIMBRA_LDAP_PASSWORD -D uid=zimbra,cn=admins,cn=zimbra -x $OBJECT | grep sn: | cut -d &#8216;:&#8217; -f2 | sed &#8216;s/^ *//g&#8217; | sed &#8216;s/ *$//g&#8217;`<br />
	if [ $ACC == &#8220;admin&#8221; ] || [ $ACC == &#8220;wiki&#8221; ] || [ $ACC == &#8220;galsync&#8221; ] || [ $ACC == &#8220;ham&#8221; ] || [ $ACC == &#8220;spam&#8221; ]; then<br />
    		echo &#8220;Skipping system account, $NAME&#8230;&#8221;<br />
	else<br />
		echo &#8220;createAccount $NAME passwordtemp displayName &#8216;$displayName&#8217; givenName &#8216;$givenName&#8217; sn &#8216;$sn&#8217; initials &#8216;$initials&#8217; zimbraPasswordMustChange FALSE&#8221; >> $NAMA_FILE<br />
    		echo &#8220;$dn<br />
changetype: modify<br />
replace: userPassword<br />
userPassword:: $userPassword<br />
&#8221; >> $LDIF_FILE<br />
    		echo &#8220;Adding account $NAME&#8221;<br />
	fi<br />
else<br />
	echo &#8220;Skipping account $NAME&#8221;<br />
fi<br />
done<br />
echo -e $ibold&#8221;All account has been exported sucessfully into $NAMA_FILE and $LDIF_FILE&#8230;&#8221;$ebold<br />
[/code]<br />
<strong>Script for import :</strong><br />
[code language=&#8217;cpp&#8217;]<br />
#!/bin/sh<br />
#Hapus Layar<br />
clear<br />
echo -e &#8216;###################################################################################&#8217;<br />
echo -e &#8216;# Zimbra import-zcs-acc.sh ver 0.0.1                                              #&#8217;<br />
echo -e &#8216;# Skrip untuk import data account Zimbra                                          #&#8217;<br />
echo -e &#8216;# Masim &#8216;Vavai&#8217; Sugianto &#8211; vavai@vavai.com &#8211; http://www.vavai.com                 #&#8217;<br />
echo -e &#8216;# Untuk saran dan pertanyaan silakan menggunakan Milis Komunitas Zimbra Indonesia #&#8217;<br />
echo -e &#8216;# Link Komunitas : http://www.zimbra.web.id &#8211; http://www.opensuse.or.id           #&#8217;<br />
echo -e &#8216;###################################################################################&#8217;<br />
# /* Variable untuk bold */<br />
ibold=&#8221; 33[1m&#8221;&#8221;n===> &#8221;<br />
ebold=&#8221; 33[0m&#8221;<br />
if [ &#8220;$USER&#8221; != &#8220;zimbra&#8221; ]<br />
then<br />
        echo -e $ibold&#8221;You need to be user zimbra to run this script&#8230;&#8221;$ebold<br />
	exit<br />
fi<br />
CURRENT_FOLDER=`pwd`;<br />
echo &#8220;&#8221;<br />
echo -e &#8220;Please verify that you have copied zcs-acc-add.zmp &#038; zcs-acc-mod.ldif on current folder !&#8221;<br />
echo -e &#8220;Current Folder : $CURRENT_FOLDER, Please change to your folder before running this script.&#8221;<br />
echo -e &#8220;Press ENTER to continue&#8230;&#8221;<br />
read jawab<br />
if [ -f ./zcs-acc-add.zmp ];<br />
then<br />
   if [ -f ./zcs-acc-add.zmp ];<br />
	then<br />
   		echo -e $ibold&#8221;Importing account&#8230;&#8221;$ebold<br />
		ZIMBRA_LDAP_PASSWORD=`zmlocalconfig -s zimbra_ldap_password | cut -d &#8216; &#8216; -f3`<br />
#		cat ./zcs-acc-add.zmp | su &#8211; zimbra -c zmprov<br />
		zmprov < $CURRENT_FOLDER/zcs-acc-add.zmp
		echo -e $ibold"Modify password..."$ebold
                ldapmodify -f "$CURRENT_FOLDER/zcs-acc-mod.ldif" -x -H ldapi:/// -D cn=config -w $ZIMBRA_LDAP_PASSWORD
#		su - zimbra -c '$LDAP_CMD'
		echo -e $ibold"Zimbra account has been modified sucessfully ..."$ebold
	else
   		echo "Sorry, file $CURRENT_FOLDER/zcs-acc-mod.ldif does not exists, import process will not be continue..."
		exit
	fi
else
   echo "Sorry, file $CURRENT_FOLDER/zcs-acc-add.zmp does not exists, import process will not be continue..."
   exit
fi
[/code]
</p>
<p>The post <a href="https://www.vavai.net/script-for-export-import-zimbra-mail-server-account-password/">Script for Export-Import Zimbra Mail Server Account &#038; Password</a> appeared first on <a href="https://www.vavai.net">Vavai&#039;s Personal Notes</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.vavai.net/script-for-export-import-zimbra-mail-server-account-password/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Object Caching 25/80 objects using Disk
Page Caching using Disk: Enhanced 
Content Delivery Network via Amazon Web Services: CloudFront: d3b35uem336dgh.cloudfront.net
Lazy Loading (feed)
Minified using Disk
Database Caching 14/39 queries in 0.016 seconds using Disk

Served from: www.vavai.net @ 2026-10-31 17:02:24 by W3 Total Cache
-->