liprepoctl.sh 825 Bytes
Newer Older
1 2 3 4 5
#!/bin/bash

ACTION="$1"
FILENAME="/etc/apt/sources.list.d/lipoffline.list"
ACTIVATED=`test -e "$FILENAME"`
6

7 8 9
. /etc/lsb-release
DIST_CODENAME=$DISTRIB_CODENAME
DIST_VERSION=$DISTRIB_RELEASE
10 11 12 13

function install_repo()
{
	echo "# offline repository of the linux install party
14
deb [ trusted=yes ] file://$1/archives $DIST_CODENAME lip" > "$FILENAME"
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
}

function uninstall_repo()
{
	rm -f "$FILENAME"
}

case $ACTION in
	"on")
		if [ -z "$2" ]; then
			echo "No repository location specified!"
			exit 2
		fi
		install_repo "$2"
		apt-get update
		echo "Repository is now active, remember to call \"$0 off\" to deactivate it when you are done."
		;;
	"off")
		uninstall_repo
		apt-get update
		echo "Repository is now inactive."
		;;
	"check")
		echo "State: $ACTIVATED"
		;;
	*)
		echo "Unknown action $ACTION"
		exit 1
		;;
esac