Topic: Bash script to upload package list to ftp server
So I made my first bash script a few minutes ago and thought I'd share. It creates a list of installed packages then ups 'em to an ftp server. You'll need wput (it's small).
I haven't tried it on #! yet, but it works on my Arch box. Different commands of course, but I think these are the commands to do the same in Ubuntu. Correct me if I'm wrong. ![]()
#!/bin/bash
echo "Creating list of installed packages."
# Change 'user' to your username in the next 2 lines
sudo dpkg --get-selections | grep '[[:space:]]install$' | \awk '{print $1}' > /home/user/pkglist
filedir="/home/user/"
targetfile="pkglist"
host="ftp.yoursite.com/"
user="username"
pass="password"
echo "Uploading to $host."
cd $filedir
wput ftp://$user:$pass@$host/$targetfile
echo "Removing pkglist"
rm pkglist
echo "Done"
# After a fresh install, you can reinstall all packages by wget'n this file and running
# dpkg --set-selections < pkglist
# dselectSave it as ~/pkgup and run it with ./pkgup or, better yet, set it up as a daily cron job. ![]()
Last edited by dannytatom (2009-02-19 08:37:37)
dnyy in IRC & Urban Terror