Go Back   openSUSE Forums > Archives > SLS Archives > ARCHIVES - Linux Tweaks > ARCHIVES - Tips, Tricks & Tweaks
Forums FAQ Members List Search Today's Posts Mark Forums Read


ARCHIVES - Tips, Tricks & Tweaks Post your tips, tricks and tweaks about SuSE Linux in here. Please do not ask questions here - this is for factual information

 
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-Oct-2007, 16:51
Jonathan R
Guest
 
Posts: n/a
Default

OK, so you copy this script;
Code:
#!/bin/sh
sqlite3 /var/cache/zypp/zypp.db vacuum
rpm --rebuilddb******** # takes long
for fn in****** /var/cache/zypp/zypp.db \
****************/var/lib/rpm/Packages** \
****************/var/lib/rpm/Filemd5s** \
****************/var/lib/rpm/Dirnames** \
****************/var/lib/rpm/Basenames
do
********cp $fn $fn.new || exit 1
********rm $fn
********mv $fn.new $fn
done
Script came from http://en.opensuse.org/SDB:Speed_up_..._Manager_Stack

Once this is done, if you want it to run with SuSEconfig, simply move the script to /sbin/conf.d/

Now, if you leave the script as is, it will run every single time SuSEconfig is invoked. If you don't want this, but still want it run run with SuSEconfig, you can add a counter to the above script, so that say, after 50 SuSEconfig runs, the script would run.

Here is a link on bash programming to give you some examples on counters; http://www.faqs.org/docs/Linux-HOWTO/Bash-...ntro-HOWTO.html
  #2 (permalink)  
Old 08-Oct-2007, 17:07
Jonathan R
Guest
 
Posts: n/a
Default

So, ok, I asked yaloki about the counter since I am new to bash scripting. Yaloki came up with this;
Code:
#!/bin/bash

# default value if not defined in /etc/sysconfig/zyppdefrag:
ZYPP_DEFRAG_EVERY=5

# read config but don't fail if the file doesn't exist
. /etc/sysconfig/zyppdefrag &>/dev/null

count=$(cat /var/adm/SuSEconfig/zyppdefrag-count 2>/dev/null || echo 0)
count=$(( $count + 1 ))
echo $count > /var/adm/SuSEconfig/zyppdefrag-count

[ "$count" -lt 10 ] && exit 0

sqlite3 /var/cache/zypp/zypp.db vacuum
rpm --rebuilddb******** # takes long
for fn in****** /var/cache/zypp/zypp.db \
****************/var/lib/rpm/Packages** \
****************/var/lib/rpm/Filemd5s** \
****************/var/lib/rpm/Dirnames** \
****************/var/lib/rpm/Basenames
do
********/bin/cp "$fn" "$fn.new" || exit 1
********/bin/rm "$fn"
********/bin/mv "$fn.new" "$fn"
done

echo 0 > /var/adm/SuSEconfig/zyppdefrag-count
Yaloki also wrote this, so that it is configurable in YaST.

Code:
## Path:********** System/Zypp/Defragmentation
## Description:****defragment the RPM and zypp databases
## Type:********** integer
## Default:********"5"
#
# After how many runs of SuSEconfig should the RPM
# and zypp databases be defragemented ?
#
ZYPP_DEFRAG_EVERY="5"
Make sure to place this one in /etc/sysconfig/zyppdefrag (which you may have to create)
  #3 (permalink)  
Old 08-Oct-2007, 17:32
Jonathan R
Guest
 
Posts: n/a
Default

And here is a picture.

[attachmentid=1798]


Now, if you do a lot of installing/upgrading or removing packages (like I do) then maybe an interval of 5 is ok, otherwise change the number to a higher value. If all you do is the security updates, setting the value to 50 might be more appropriate.
 

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




 

Search Engine Friendly URLs by vBSEO 3.3.0 RC2