Update of /cvsroot/leaf/src/config/webconf/var/webconf/www
In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv1502/var/webconf/www
Modified Files:
lrcfg.back.cgi
Removed Files:
lrcfg.pkgdisks.cgi
Log Message:
lrcfg.back.cgi now works with configdb and moddb
lrcfg.pkgdisks.cgi no longer needed
Index: lrcfg.back.cgi
===================================================================
RCS file: /cvsroot/leaf/src/config/webconf/var/webconf/www/lrcfg.back.cgi,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** lrcfg.back.cgi 27 Oct 2004 20:58:12 -0000 1.1
--- lrcfg.back.cgi 25 Aug 2006 18:36:17 -0000 1.2
***************
*** 1,8 ****
#!/usr/bin/haserl
<? SESSIONID=${FORM_SESSIONID:-${SESSIONID}}
! [ "$FORM_cmd" = "BackupNow" ] && echo "Refresh: 2;
url=$SCRIPT_NAME?STAGE=1&SESSIONID=$SESSIONID&LOOP=$(( ${FORM_LOOP:=0} + 1 ))"
if [ "$FORM_STAGE" = "1" ]; then
if ! [ -f /tmp/$SESSIONID.backup.done ]; then
! echo "Refresh: 2;
url=$SCRIPT_NAME?STAGE=1&SESSIONID=$SESSIONID&LOOP=$(( ${FORM_LOOP:=0} + 1 ))"
echo "DONE=NO" >/tmp/$SESSIONID.vars
else
--- 1,8 ----
#!/usr/bin/haserl
<? SESSIONID=${FORM_SESSIONID:-${SESSIONID}}
! [ "$FORM_cmd" = "Backup" ] && echo "Refresh: 2;
url=$SCRIPT_NAME?STAGE=1&SESSIONID=$SESSIONID"
if [ "$FORM_STAGE" = "1" ]; then
if ! [ -f /tmp/$SESSIONID.backup.done ]; then
! echo "Refresh: 2;
url=$SCRIPT_NAME?STAGE=1&SESSIONID=$SESSIONID"
echo "DONE=NO" >/tmp/$SESSIONID.vars
else
***************
*** 11,100 ****
fi
title="Commit Changes to Read/Write Media" /var/webconf/lib/preamble.sh ?>
! <!-- $Id$ -->
<? # lrcfg.back settings
SESSIONID=${FORM_SESSIONID:-${SESSIONID}}
- get_settings () {
-
- COUNT=0
- FORM_pkg_count=""
- cat $CONFF | while read LINE ; do
- COUNT=$(( $COUNT + 1 ))
- pkg=$( echo $LINE | cut -f 1 -d'=' )
- echo FORM_wc_pkg_${COUNT}_name=\"$pkg\" >>$TEMPFILE
- fs=$( echo $LINE | cut -f 2 -d' ' )
- dev=$( echo $LINE | cut -f 3 -d' ' )
- echo FORM_wc_${COUNT}_dest="${dev}:${fs}" >>$TEMPFILE
- TYPE=Full
- [ -r $LRPKG/${pkg}.bktype ] && read TYPE < $LRPKG/${pkg}.bktype
- echo FORM_wc_${COUNT}_type=$TYPE >>$TEMPFILE
- # For some reason, variables here don not survive past this
block
- # so we just write the current count over and over and over
- FORM_pkg_count="$FORM_pkg_count $COUNT"
- echo FORM_pkg_count=\"$FORM_pkg_count\" >>$TEMPFILE
- done
-
- # Get the list of backup devices
- echo FORM_pkgdisks=\"$( cat $DEVF | sed 's/ /:/g' | tr "\n" " " )\"
>>$TEMPFILE
}
- # Attempt to update the various package configuration files
- update_lrcfg_files () {
-
- # Full or partial?
- for y in $FORM_pkg_count; do
- x=$( eval echo \$FORM_wc_pkg_${y}_name )
- rm $LRPKG/$x.bktype 2>/dev/null 1>/dev/null
- [ "$( eval echo \$FORM_wc_${y}_type )" = "Part" ] && \
- echo "Part" > $LRPKG/$x.bktype
- done
-
- # write CONFF
- rm -f $CONFF 2>/dev/null
- for y in $FORM_pkg_count; do
- x=$( eval echo \$FORM_wc_pkg_${y}_name )
- TARGET="$( eval echo \$FORM_wc_${y}_dest )"
- DEV=$( echo $TARGET | cut -f 1 -d":" )
- FS=$( echo $TARGET | cut -f 2 -d":" )
- echo $x=-t $FS $DEV >>$CONFF
- done
- }
-
TEMPFILE=/tmp/$SESSIONID.vars
touch $TEMPFILE
- echo "$( sed -n "1,/ListPkgs/{ /^#/d; /ListPkgs/d; p; }"
/usr/sbin/lrcfg.back )" >>$TEMPFILE
- . $TEMPFILE
case "$FORM_cmd" in
! "SelectEverything" )
! for x in $FORM_pkg_count; do
! echo FORM_wc_${x}_selected="Y" >>$TEMPFILE
! done
! ;;
!
! "UpdateSettings" )
! update_lrcfg_files
! get_settings
! ;;
! "List" )
! get_settings
! cat <<-EOF
! <!--
! #BEGIN WEBCONF SETTINGS LIST
! $( cat /tmp/$SESSIONID.vars )
! #END WEBCONF SETTINGS LIST
! -->
! </pre>
! EOF
! ;;
! "BackupNow" )
! update_lrcfg_files
echo "FORM_STAGE=1" >>/tmp/$SESSIONID.vars
;;
-
* )
! get_settings
;;
esac;
--- 11,42 ----
fi
title="Commit Changes to Read/Write Media" /var/webconf/lib/preamble.sh ?>
! <!-- $Id$ -->
<? # lrcfg.back settings
SESSIONID=${FORM_SESSIONID:-${SESSIONID}}
+ get_settings () {
+ # Taken from mount.back
+ DEVF="/var/lib/lrpkg/pkgpath.disks"
+ cat $DEVF 2>/dev/null | if read dev fs; then
+ echo fs=$fs >>$TEMPFILE
+ echo dev=$dev >>$TEMPFILE
+ fi
}
TEMPFILE=/tmp/$SESSIONID.vars
touch $TEMPFILE
+ get_settings
+
case "$FORM_cmd" in
! "Backup" )
echo "FORM_STAGE=1" >>/tmp/$SESSIONID.vars
;;
* )
! # Set the 2 databases to pre selected.
! FORM_wc_configdb=Y
! FORM_wc_moddb=Y
;;
esac;
***************
*** 103,140 ****
<?if SESSIONID=${FORM_SESSIONID:-${SESSIONID}}; . /tmp/$SESSIONID.vars; [
"$FORM_STAGE" = "1" ] ?>
<h1>Saving Packages</h1>
! <? # If the command is BackupNow start the subshell
SESSIONID=${FORM_SESSIONID:-${SESSIONID}}
!
. /tmp/$SESSIONID.vars
!
! if [ "$FORM_cmd" = "BackupNow" ]; then
! for x in $FORM_pkg_count; do
! if [ "$(eval echo \$FORM_wc_${x}_selected)" ]; then
! candidate="$candidate ${x}"
! namelist="${namelist} $( eval echo
\$FORM_wc_pkg_${x}_name)"
fi
done
!
!
# Empty candidate list?
if [ -z "$candidate" ]; then
echo '<div class="HeavyRed">No packages were selected for
backup</div>' > /tmp/$SESSIONID.status
! echo "<div class=\"HeavyBlue\">Selecting Packages for
backup.</div>"
touch /tmp/$SESSIONID.backup.done
else
echo "<div class=\"HeavyBlue\">Will attempt to back up the
following packages: $namelist</div>" >/tmp/$SESSIONID.status
!
# This is the magic... we run a subshell script in the
background.
# Even when this script dies, the subshell survives.
# With this subshell, we abuse /usr/sbin/lrcfg.back.script to
the limit
! # We also do everything in our power to find an excuse NOT to
do a
# backup.
! (
export PATH=/usr/sbin:/sbin:/usr/bin:/bin:$PATH
!
log () {
! if [ -n "$1" ]; then
echo "<span class=\"Heavy${1}\">$2</span>"
>>/tmp/$SESSIONID.status
else
--- 45,83 ----
<?if SESSIONID=${FORM_SESSIONID:-${SESSIONID}}; . /tmp/$SESSIONID.vars; [
"$FORM_STAGE" = "1" ] ?>
<h1>Saving Packages</h1>
! <? # If the command is Backup start the subshell
SESSIONID=${FORM_SESSIONID:-${SESSIONID}}
!
. /tmp/$SESSIONID.vars
!
! if [ "$FORM_cmd" = "Backup" ]; then
! for x in configdb moddb; do
! if [ "$(eval echo \$FORM_wc_${x})" ]; then
! name="$( grep "^${x}" /var/lib/lrpkg/backup 2>/dev/null
| cut -f2 -d = )"
! candidate="$candidate ${name}"
fi
done
!
# Empty candidate list?
if [ -z "$candidate" ]; then
echo '<div class="HeavyRed">No packages were selected for
backup</div>' > /tmp/$SESSIONID.status
! echo "<div class=\"HeavyBlue\">Selecting Packages for
backup.</div>"
touch /tmp/$SESSIONID.backup.done
else
echo "<div class=\"HeavyBlue\">Will attempt to back up the
following packages: $namelist</div>" >/tmp/$SESSIONID.status
!
# This is the magic... we run a subshell script in the
background.
# Even when this script dies, the subshell survives.
# With this subshell, we abuse /usr/sbin/lrcfg.back.script to
the limit
! # We also do everything in our power to find an excuse NOT to
do a
# backup.
! (
export PATH=/usr/sbin:/sbin:/usr/bin:/bin:$PATH
! export FS=$fs
! export DEV=$dev
!
log () {
! if [ -n "$1" ]; then
echo "<span class=\"Heavy${1}\">$2</span>"
>>/tmp/$SESSIONID.status
else
***************
*** 142,177 ****
fi
}
!
build_lrp () {
! # make /var/lib/lrpkg/mnt point to /tmp
! # and build a package
! rm -rf $PKGDIR 2>/dev/null >/dev/null
! ln -s /tmp $PKGDIR
! /usr/sbin/lrcfg.back.script $1 NO NO $2 2>&1
1>/dev/null
! rm $PKGDIR
! mkdir $PKGDIR
! if ! [ -r /tmp/$1.lrp ]; then
log "Red" "The package was not created in /tmp!"
return 1
fi
!
! if [ ! "$1" = "initrd" ] && [ -z "$( tar tzvf
/tmp/$1.lrp )" ]; then
log "Red" "The package was empty."
! rm -f /tmp/$1.lrp
return 1
fi
return 0
}
!
! mount_check () {
msg=$( mount -t "$1" "$2" $PKGDIR -o rw 2>&1)
if [ "$?" -gt 0 ]; then
! log "Red" "$msg"
! return 1
fi
umount $PKGDIR >/dev/null 2>&1
return 0
! }
smart_copy () {
--- 85,115 ----
fi
}
!
build_lrp () {
! # use apkg $1 to build the package in /tmp
! apkg $1 $2 /tmp 2>&1 1>/dev/null
! if ! [ -r /tmp/$2.lrp ]; then
log "Red" "The package was not created in /tmp!"
return 1
fi
!
! if [ -z "$( tar tzvf /tmp/$2.lrp )" ]; then
log "Red" "The package was empty."
! rm -f /tmp/$2.lrp
return 1
fi
return 0
}
!
! mount_check () {
msg=$( mount -t "$1" "$2" $PKGDIR -o rw 2>&1)
if [ "$?" -gt 0 ]; then
! log "Red" "$msg"
! return 1
fi
umount $PKGDIR >/dev/null 2>&1
return 0
! }
smart_copy () {
***************
*** 192,200 ****
return 0
}
!
do_backup () {
! log "Blue" "Backing up package $1 ...<br>"
! DEV=$( echo $3 | cut -f 1 -d":" )
! FS=$( echo $3 | cut -f 2 -d":" )
mount_check "$FS" "$DEV"
if [ $? -gt 0 ]; then
--- 130,137 ----
return 0
}
!
do_backup () {
! #<apkg flag to build lrp> <package name>
! log "Blue" "Backing up package $2 ...<br>"
mount_check "$FS" "$DEV"
if [ $? -gt 0 ]; then
***************
*** 202,206 ****
return 1
fi
!
build_lrp "$1" "$2"
if [ $? -gt 0 ]; then
--- 139,143 ----
return 1
fi
!
build_lrp "$1" "$2"
if [ $? -gt 0 ]; then
***************
*** 208,216 ****
return 1
fi
!
mount -t $FS $DEV $PKGDIR -o rw 2>&1 >/dev/null
! smart_copy "$1"
retcode="$?"
! umount $PKGDIR 2>&1 >/dev/null
if [ "$retcode" -gt 0 ]; then
log "Red" "Backup Failed<br>"
--- 145,153 ----
return 1
fi
!
mount -t $FS $DEV $PKGDIR -o rw 2>&1 >/dev/null
! smart_copy "$2"
retcode="$?"
! umount $PKGDIR 2>&1 >/dev/null
if [ "$retcode" -gt 0 ]; then
log "Red" "Backup Failed<br>"
***************
*** 220,241 ****
fi
}
!
PKGDIR=/var/lib/lrpkg/mnt
! for x in $candidate; do
! name="$( eval echo \$FORM_wc_pkg_${x}_name )"
! do_backup "$name" "$( eval echo \$FORM_wc_${x}_type)"
"$( eval echo \$FORM_wc_${x}_dest)"
done
!
touch /tmp/$SESSIONID.backup.done ) 2>/dev/null 1>/dev/null &
touch /tmp/$SESSIONID.script
fi
!
echo '<hr><div class="HeavyBlue"><b>Process Running. Please
wait...</b></div>'
! fi
if [ -z "$FORM_cmd" ]; then
[ -r /tmp/$SESSIONID.status ] && cat < /tmp/$SESSIONID.status
if [ "$DONE" = "YES" ]; then
! rm -f /tmp/$SESSIONID.*
echo '<hr><div class="HeavyBlue"><b>Process Complete</b></div>'
else
--- 157,182 ----
fi
}
!
PKGDIR=/var/lib/lrpkg/mnt
! # dev and fs are sourced from the SESSIONID.vars
! for name in $candidate; do
! type="$( grep "$name\$" /var/lib/lrpkg/backup | cut -f1
-d= || "NONE" )"
! [ "$type" == "configdb" ] && flag="-o"
! [ "$type" == "moddb" ] && flag="-d"
! [ -z "$flag" ] && log "Red" "Invalid backup flag for
$name"
! do_backup "$flag" "$name"
done
!
touch /tmp/$SESSIONID.backup.done ) 2>/dev/null 1>/dev/null &
touch /tmp/$SESSIONID.script
fi
!
echo '<hr><div class="HeavyBlue"><b>Process Running. Please
wait...</b></div>'
! fi
if [ -z "$FORM_cmd" ]; then
[ -r /tmp/$SESSIONID.status ] && cat < /tmp/$SESSIONID.status
if [ "$DONE" = "YES" ]; then
! rm -f /tmp/$SESSIONID.*
echo '<hr><div class="HeavyBlue"><b>Process Complete</b></div>'
else
***************
*** 251,307 ****
<!-- ---------------- The selection form ------------------------------->
<h1>Package Selection</h1>
! <p><span class="HeavyGreen"<b><u>Don't Panic</u></b></span>. If you are
unsure
! what to do, use the <b>SelectEverything</b> button to select all packages,
! then use the <b>BackupNow</b> button to back everything up.</p>
! <p>LEAF package backups can be quite complex. It is possible to store
! packages (and parts of packages) in multiple places, all at the same time.
! This web page simulates the <code>lrcfg.back</code> script for experienced
! users.</p>
<form action="<? echo -n $SCRIPT_NAME ?>" method=post>
! <input type=submit name=cmd value="SelectEverything">
! <input type=submit name=cmd value="BackupNow">
! <table>
! <tr><th>Selected</th><th>Package</th><th>Type</th><th>Backup Dev:FS</th></tr>
! <? SESSIONID=${FORM_SESSIONID:-${SESSIONID}}
! . /tmp/$SESSIONID.vars
!
! for x in $FORM_pkg_count; do
! echo "<tr><td>"
! echo -n "<input name=wc_${x}_selected type=checkbox value=\"Y\""
! [ "$(eval echo \$FORM_wc_${x}_selected)" ] && echo -n " checked"
! echo "></td><td><b>$( eval echo \$FORM_wc_pkg_${x}_name)</b>"
! echo "<input type=hidden name=wc_pkg_${x}_name value=\"$( eval echo
\$FORM_wc_pkg_${x}_name )\">"
! echo "</td><td>"
! echo "<select name=wc_${x}_type size=1>"
! TYPE=$( eval echo "\$FORM_wc_${x}_type")
! for y in Full Part; do
! echo -n "<option "
! [ $y = $TYPE ] && echo -n "selected"
! echo ">$y</option>"
! done
! echo "</td><td>"
! echo "<select name=wc_${x}_dest size=1>"
! for y in "" $FORM_pkgdisks; do
! echo -n "<option "
! [ "$y" = "$( eval echo \$FORM_wc_${x}_dest )" ] && echo -n
"selected"
! echo ">$y</option>"
! done
! echo "</td></tr>"
! done
! ?>
! </table>
!
! <input type=submit name=cmd value="UpdateSettings">
! <p>(Update packagedisk and backup type without doing a backup)</p>
! <? SESSIONID=${FORM_SESSIONID:-${SESSIONID}}
! . /tmp/$SESSIONID.vars
! for x in pkgdisks pkg_count STAGE; do
! echo "<input type=hidden name=${x} value=\"$( eval echo \$FORM_${x}
)\">"
! done
! ?>
</form>
! <? SESSIONID=${FORM_SESSIONID:-${SESSIONID}}
! rm /tmp/$SESSIONID.*; /var/webconf/lib/footer.sh ?>
<?fi # End the clause for NOT in backup loop ?>
--- 192,224 ----
<!-- ---------------- The selection form ------------------------------->
<h1>Package Selection</h1>
! <? . /tmp/$SESSIONID.vars ?>
! <p>This web page simulates the <code>lrcfg.back</code> script for experienced
! users.</br>Checked configuration databases will be copied to <em><? echo -n
$dev ?></em>.</p>
<form action="<? echo -n $SCRIPT_NAME ?>" method=post>
! <h1>Select Configurations</h1>
! <table width=70%>
! <?
! configdb_descr="System Configuration"
! moddb_descr="Kernel Modules"
! for x in configdb moddb; do
! echo "<tr><td align=left>"
! echo -n "<input name=wc_${x} type=checkbox value=\"Y\""
! [ "$(eval echo \$FORM_wc_${x})" ] && echo -n " checked"
! echo ">"
! # The name comes from /var/lib/lrpkg/backup
! echo "<td>"
! grep "^${x}" /var/lib/lrpkg/backup 2>/dev/null | cut -f2 -d= || echo
${x}
! echo "</td><td align=left>$( eval echo \$${x}_descr)</td>"
! echo "</tr>"
! done
! ?>
! </table>
! <h2></h2>
! <input type=submit name=cmd value="Backup">
! <input type=hidden name=STAGE value="<? echo -n $STAGE?>">
</form>
!
! <? rm /tmp/$SESSIONID.*; /var/webconf/lib/footer.sh ?>
<?fi # End the clause for NOT in backup loop ?>
--- lrcfg.pkgdisks.cgi DELETED ---
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
leaf-cvs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/leaf-cvs-commits