Pejman Moghadam / Scripts

Package Downloader - Slackeware 12.2

Public domain


#!/bin/bash

URL="http://www.slackware.at/data/slackware-12.2"
DIRS="a ap d e f k kde kdei l n t tcl x xap y"

for DIR in ${DIRS};do 
  read -p "Check ${URL}/slackware/${DIR}/ [y/N] ?" choice
  if [ "$choice" == "y" ]; then
    PKGS=$(links -dump "${URL}/slackware/${DIR}/" |\
      grep '\.tgz '                        |\
      sed -e 's,^ *,,'                     |\
      sed -e 's, .*,,' )
    for PKG in $PKGS; do
      if [ "$PKG" != "" ]; then
        NAME=$(echo $PKG | sed -e 's,\.tgz$,,')
        ls /var/log/packages/${NAME} > /dev/null 2>&1
        if [ "$?" == "2" ]; then
          echo -n "$NAME not installed"
          LIKE=$(echo "$NAME" | sed -e 's,[1-9].*,,')
          FILE=$(ls /var/log/packages/| egrep "^${LIKE}")
          if [ "$FILE" != "" ]; then
            echo "(but $FILE is installed)"
          else
            read -p "Download ${PKG} [y/N]?" choice
            if [ "$choice" == "y" ]; then
              wget -c "${URL}/slackware/${DIR}/${PKG}"
            fi
          fi
        fi 
      fi
    done
  fi
done

BY: Pejman Moghadam
TAG: package-management, bash-script, bash
DATE: 2010-08-09 14:31:01


Pejman Moghadam / Scripts [ TXT ]