dies ist ein kleines script für entfernte debian upgrades, wenn vor

ort kaum netz aber ein wechseldatenträger zur verfügung steht.
age 18 years ago
parent fec57c6d39
commit 5cdf4e88e8
  1. 109

@ -0,0 +1,109 @@
#!/bin/bash -e
COMMENT="# this script is part of apt-get-interim, a tool for updating a debian system
# without fast local net connection.
# there are three stages.
# first read in a list of needed packages.
# second download them on any debian system with fast internet connection.
# third install them on the origin debian system
# a bunch of scripts will be generated by apt-get-interim,
# so you simply have to start four scripts at all and everything will be fine :)
## send comments to age-at-systemausfall-dot-org"
USAGEHINT="apt-get-interim-update - APT for lousy connected boxes\n
usage: $0 DIR [ACTION]\n
\tDIR should be the path to your removeable media\n
\tACTION can be \"upgrade\", \"dist-upgrade\", \"install PACKAGELIST\"\n
\t\tdefault action is dist-upgrade"
# what apt-get action should be performed (e.g. upgrade, install package foo, ..)
#ACTION="install $2" ##where $2 is a file with packagenames or a package or ia list of packages in quotes
# which sources list should be used
[ -z "$1" ] && echo -e $USAGEHINT && exit 1
echo "your media: $MEDIUM"
[ ! -d $MEDIUM -o ! -w $MEDIUM -o ! -x $MEDIUM ] && echo -e "\tis not writeable!" && exit 1
[ ! -z "$2" ] && ACTION="$2"
echo "apt-get action: $ACTION"
SCRIPT1=${MEDIUM}/apt-get-interim_1_$(uname -n)
SCRIPT2=${MEDIUM}/apt-get-interim_2_$(uname -n)
SCRIPT3=${MEDIUM}/apt-get-interim_3_$(uname -n)
## generate stage 1 script for local update
cat > $SCRIPT1 <<EOF
# This file was auto-generated by apt-get-interim ${VERSION}
# stage 1:
# start this script on your debianbox with a slow internet connection,
# to update your package lists.
apt-get update || exit 1
cd $MEDIUM || exit 1
mkdir -p archives/partial
mkdir -p lists/partial
cp /var/lib/dpkg/status status
cp $SRCLIST sources.list
chmod 644 $SCRIPT1
chmod 744 $SCRIPT2
mv \$0 \${0}.done
echo "start the stage 2 script on a debian machine with fast access to your apt sources!"
chmod 744 $SCRIPT1
## generate remote apt.conf
Architecture "i386";
Get::Download-Only "true";
Dir {
State "${MEDIUM}";
State::status "status";
Cache::archives "${MEDIUM}/archives";
## generate stage 2 script to run on the remote machine
cat > $SCRIPT2 <<EOF
# This file was auto-generated by apt-get-interim ${VERSION}
# stage 2:
# start this script on a machine with fast access to the apt sources"
apt-get update
apt-get $ACTION
chmod 644 $SCRIPT2
chmod 744 $SCRIPT3
mv \$0 \${0}.done
echo "now get back home and install the fetched packages with the third script!"
## generate stage 3 script that back on local machine installs the fetched packages
cat > $SCRIPT3 <<EOF
# This file was auto-generated by apt-get-interim ${VERSION}
# stage 3:
# start this script fully deb loaded and back on your slow connected machine
export APT_CONFIG="$MEDIUM/apt.conf"
apt-get check
apt-get --no-d -o dir::etc::status=/var/lib/dpkg/status $ACTION
chmod 644 $SCRIPT3
mv \$0 \${0}.done
echo "that's it, see you next time.."
echo "three scripts were generated."
echo -e "ypu can start now the script for the first stage:\n\t$SCRIPT1"