LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   How to use rsync and upgradepkg... (https://www.linuxquestions.org/questions/slackware-14/how-to-use-rsync-and-upgradepkg-273735/)

halo14 01-04-2005 10:58 AM

How to use rsync and upgradepkg...
 
Hey, I just did a new install of slackware-current 1/3/05 (courtesy of 'ananke' from #slackware)

and I'm trying to figure out how to use rsync and then check and see about doing an upgradepkg * to stay up to date...

I want to do this because it seems like the "correct" way from what everyone is saying... and that swaret and slapt-get are both notorious for borking systems to an unusable state...

If someone could please post a HOWTO do this.. I think it would be of great use to myself and a number of other users.. thanks a lot..

dhave 01-04-2005 11:27 AM

I'm no expert (four whole months with Slackware, heh), but isn't it better to handle the updates manually so that you have a chance to read the comments in the changelog? It helps me to know my system a lot better. Also, I've realized that there's a lot of stuff that I really don't need now, but if I've read the changelog, I at least know it's there. And on Current, occasionally there's an update that comes with a caveat.

On the other hand, I'd still like to know more about the semi-automated rsync system, too, so I hope somebody responds with a good How-To.

Cedrik 01-04-2005 11:53 AM

There is a rsync howto in this site :
http://www.linuxquestions.org/questi...ticle&artid=80

cathectic 01-04-2005 01:09 PM

Quote:

I want to do this because it seems like the "correct" way from what everyone is saying... and that swaret and slapt-get are both notorious for borking systems to an unusable state...
You can use the automated tools (I use swaret, and prefer it over slackpkg. I haven't tried any of the others yet), *provided* you read the ChangeLog beforehand (which you should do anyway with any update of Slackware). Many problems with updates come from people who run these update tools blindly, miss vital packages, or don't follow Pat's instructions for changes that need to be made (such as the notorious 'Keyboard' to 'kbd' driver change from Xorg 6.7 to 6.8.1, which many people never saw about as they never read the ChangeLog.) These tools are an aid to updating if used wisely, but they are no replacement for doing your homework before and understanding what you're going to upgrade, and what changes you will need to make afterwards.

ringwraith 01-04-2005 05:15 PM

if you go to alt.os.linux.slackware on groups.google.com and search there, iirc there are some scripts you can run in conjunction with rsync. i still prefer to read the changelogs, use wget and proceed according to Pat's notes.

PDock 01-04-2005 07:41 PM

Fully support posts about need to read changelog first.

I do have a script which I only use with stable (but can be used with current [unwisely] ). Basic steps are: Mirror (rsync) Slackware ; in new /ourpatches directory link patches you want autoinstalled; modified init scripts check that directory on the server using a copy of upgradepkg called patchpkg which just downloads the package (see below); changes to init 1, uses Pat's upgradepkg to install; then reboots that computer. Note: this is designed for desktops that are turned on and off rather than servers or people crazy about uptime.


Here's the diff file which is 80% of the task just add a few more scripts and you don't need mine.
Code:

--- /sbin/upgradepkg 2004-05-30 00:22:41.000000000 +0000
+++ /sbin/patchpkg 2004-09-27 12:06:11.000000000 +0000
@@ -106,6 +106,10 @@
    # but don't actually perform the upgrades.
    DRY_RUN="true"
    shift 1
+  elif [ "$1" = "--patch" ]; then
+    # We're adding a --patch  mode that finds packages for networked hosts
+    PATCH="true"
+    shift 1
  else # no more args
    break;
  fi
@@ -174,15 +178,17 @@
 
 if [ ! -r $ROOT/var/log/packages/$OLD ]; then
  if [ ! "$INSTALL_NEW" = "yes" ]; then
-    if [ "$DRY_RUN" = "true" ]; then
-      echo "$OLD would not be upgraded (no installed package named $SHORT)."
-    else 
-      echo
-      echo "Error:  there is no installed package named $OLD."
-      echo "        (looking for $ROOT/var/log/packages/$OLD)"
-      echo
-    fi
+    if [ ! "$PATCH" = "true" ]; then #suppress error msg:
+      if [ "$DRY_RUN" = "true" ]; then
+        echo "$OLD would not be upgraded (no installed package named $SHORT)."
+      else 
+        echo
+        echo "Error:  there is no installed package named $OLD."
+        echo "        (looking for $ROOT/var/log/packages/$OLD)"
+        echo
+      fi
    ERRCODE=1
+    fi
  else # --install-new was given, so install the new package:
    if [ "$DRY_RUN" = "true" ]; then
      echo "$NEW would be installed (new package)."
@@ -231,6 +237,22 @@
    continue;
  fi
 fi

+# Check if in patch mode. If so then copy the package, shift 1 and continue-
+# loopback to check for more packages. We do NOT fall thru to actually do
+# the upgrade.
+
+if [ "$PATCH" = "true" ]; then
+  # Check/create directory
+  if [ ! -d $TMP/patch ]; then
+    rm -rf $TMP/patch # make sure it's not a symlink or something stupid
+    mkdir $TMP/patch
+    chmod 700 $TMP/patch # no need to leave it open
+  fi
+cp $INCOMINGDIR/$NEW.tgz $TMP/patch
+    shift 1
+    continue;
+fi
 
 # Showtime.  Let's do the upgrade.  First, we will rename all the
 # installed packages with this basename to make them easy to remove later:

oh heck here's rc.patch
Code:

#!/bin/sh
# Find/apply patches on a local network server.
#
# This is a script to upgrade small network/office installations
# for any security patches.
#
# Written for Slackware Linux by Patrick J. Volkerding <volkerdi@slackware.com>.

usage() {
  cat << EOF
Usage: rc.patch find|apply|usage

HOWEVER YOU MOST LIKELY DON'T WANT TO BE DOING THIS!!

rc.patch automates package upgrades for small networks.
rc.patch -find is initiated from rc.inet2.
rc.patch -apply is initiated from rc.K.
You may need to edit the mount point located at the beginning of this script.
You need to edit /etc/fstab to include:
Ourserver:/path/to/slack/ourpatches /mnt/patches nfs noauto,ro,rsize=8192,
  wsize=8192,timeo=14,intr
Of course /etc/exports on the server must also be modified.

It is expected an administrator will create a server directory /ourpatches.
AFTER reviewing the changelog or other upgrade texts, if a package
is appropriate for automated upgrading then and only then
will the administrator copy that package from /patches to /ourpatches.

If a patch, for a package already on the users computer, is found; the script
will: copy the package to the local drive; drop to init 1; apply the upgrade;
delete the package from the local drive; then reboot.

Symbolic links can be used on the server if space is a problem but they are
difficult to set up correctly. Assuming you use rsync with delete to obtain
upgrades/patches then you would create /ourpatches at the same level as /patches.
You must --exclude ourpatches/ when syncing or the directory will be deleted.
The symbolic link can not be absolute but must be in the form of
../patches/nameofpatch.tgz. The MOUNTPNT is set to the level above /patches and
/ourpatches, and cd $ MOUNTPNT needs to be changed to cd $ MOUNTPNT/ourpatches.
NOTE: there is no space between $ and MOUNTPNT (shown this way to avoid substitution)

EOF
}

#Edit the next line if needed
MOUNTPNT=/home/ftp/pub/Slackware-10.0

#This TMP file must be the same as shown in /sbin/upgradepkg
TMP=/var/log/setup/tmp


patches_find() {
  # Sanity checks.  Exit if there's no MOUNTPNT, or its not
  # defined in /etc/fstab.
  if [ ! -d $MOUNTPNT ]; then # no mount directory, exit:
    echo $MOUNTPNT ' not a valid mount point.'
    exit
  elif grep $MOUNTPNT /etc/fstab 1> /dev/null 2> /dev/null ; then
      true # mount defined, continue:
    else
      echo $MOUNTPNT ' not in /etc/fstab.'
      exit
  fi
 
  if grep $MOUNTPNT /proc/mounts 1> /dev/null 2> /dev/null ; then
    true # MOUNTPNT is already mounted, continue:
  else # MOUNTPNT is defined so try and mount, continue:
    mount $MOUNTPNT
  fi
 
  if grep $MOUNTPNT /proc/mounts 1> /dev/null 2> /dev/null ; then
    true # MOUNTPNT was successfully mounted, continue:
  else # MOUNTPNT :
    echo $MOUNTPNT ' defined in /etc/fstab does not mount; check export file'
    exit
  fi

  # If using symbolic links then edit next line to: cd $MOUNTPNT/ourpatches
  cd $MOUNTPNT/ourpatches
  /sbin/patchpkg --patch *.tgz
  cd
  umount $MOUNTPNT

  # Sanity check. No TMP/patch directory exit
  if [ ! -d $TMP/patch ]; then
    return
  fi
  init 1
}

patches_apply() {
  # Sanity check. No TMP/patch directory exit
  if [ ! -d $TMP/patch ]; then
    return
  fi
  cd $TMP/patch
  /sbin/upgradepkg *.tgz
  cd /
  rmdir --ignore-fail-on-non-empty $TMP/patch
  shutdown -r now
}

case "$1" in
'find')
  patches_find
  ;;
'apply')
  patches_apply
  ;;
'usage')
  usage
  ;;
*)
  usage
  ;;
esac

Still credit Pat cause his great scripts enabled writting this. Has been offered to Pat but was declined which is fine.
ppd


All times are GMT -5. The time now is 12:06 AM.