SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2009-02-19 06:55:10

dannytatom
#! CrunchBanger
From: Ashdown, AR
Registered: 2009-01-10
Posts: 190

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. smile

#!/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
# dselect

Save it as ~/pkgup and run it with ./pkgup or, better yet, set it up as a daily cron job. smile

Last edited by dannytatom (2009-02-19 08:37:37)


.files
dnyy in IRC & Urban Terror

Offline

Be excellent to each other!

#2 2009-02-19 14:32:29

corenominal
root
From: Lincoln, UK
Registered: 2008-11-20
Posts: 4,887
Website

Re: Bash script to upload package list to ftp server

Nice script, thank you for sharing! smile

Offline

#3 2009-02-19 16:59:06

ZeroTruths
#! Junkie
Registered: 2008-12-31
Posts: 331

Re: Bash script to upload package list to ftp server

So if I understand correctly, this creates a backup of all of the installed packages and uploads them to an FTP server?


All in an effort to learn...
Delves deeper into code...

Offline

#4 2009-02-19 18:37:21

dannytatom
#! CrunchBanger
From: Ashdown, AR
Registered: 2009-01-10
Posts: 190

Re: Bash script to upload package list to ftp server

Nah, it just creates a list and uploads the list (http://im.dannytatom.com/pkglist) to an ftp server.  It wouldn't be hard to mod it to download all the packages, tar 'em up, then upload that but didn't have much reason to do that.


.files
dnyy in IRC & Urban Terror

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo