File: newmodules

package info (click to toggle)
wims 4.00-4%2Bsqueeze1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 85,260 kB
  • ctags: 7,825
  • sloc: xml: 361,058; ansic: 56,911; sh: 5,681; java: 2,805; perl: 1,743; cpp: 1,239; yacc: 1,011; makefile: 972; lisp: 514; asm: 47
file content (47 lines) | stat: -rw-r--r-- 1,729 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#! /bin/sh

if dh_testdir 2> /dev/null; then 
    echo "Good: we are in the main package directory." 
else 
    echo "you are not in the main package directory."
    exit 1
fi

if [ ! -d wims/public_html/modules ]; then
    echo "The directory wims/ does not exist; expanding the archive."
    mkdir -p wims
    (cd wims; tar xzf ../wims-3.64.tgz)
else
    echo "Good: the modules directory seems already uncompressed." 
fi

tempdir=$(mktemp -d)
oldmodulefiles=$tempdir/old.txt
currentmodulefiles=$tempdir/current.txt
newmodulefiles=$tempdir/new.txt
newmoduledirs=$tempdir/dirs.txt
tarfile=$tempdir/wims-modules-extra-$(date +%Y%m%d).tar

echo "building the file of old modules"
(cd wims/public_html/modules/; for d in $(ls | grep -v devel); do find $d -type f; done;)| sort > $oldmodulefiles

echo "building the file of current modules"
(cd /var/lib/wims/public_html/modules/; for d in $(ls | grep -Ev 'adm|devel|Change.*'); do find $d -type f 2> /dev/null; done;)| grep -Ev '~$|.orig$' | sort > $currentmodulefiles

echo "building the file of newer modules."
comm -2 -3 $currentmodulefiles $oldmodulefiles > $newmodulefiles

echo "building the file of new module directories"
cat $newmodulefiles | sed -n 's%\([^/]*/[^/]*/[^/]*\)/.*%public_html/modules/\1% p' | uniq >  $newmoduledirs

echo "The list of the new module files is at $newmodulefiles ($(wc -l $newmodulefiles | sed 's/[^0-9]//g') records)."
echo "their directories are in $newmoduledirs ($(wc -l $newmoduledirs | sed 's/[^0-9]//g') records)."

echo ""
echo -n "Building the archive for the new modules in $tarfile.gz ... "

chmod 755 $tempdir
chmod 644 $newmoduledirs
sudo su - wims -c "tar cf - --files-from $newmoduledirs" | gzip -c9 > $tarfile.gz

echo "Done."