File:  [Paefchen] / home / as / .csh / cshrcupdate.csh
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Mon Jan 7 06:03:02 2008 UTC (16 years, 10 months ago) by as
Branches: MAIN
CVS tags: HEAD
Hello My Home ;)

# $Paefchen: home/as/.csh/cshrcupdate.csh,v 1.1 2008/01/07 06:03:02 as Exp $

# CSHRC_RELOAD: NO
# CSHRC_PROMPTONLY: YES

if (! $?AS_CSHRC_UPDATE_PKG_PATH) then
	set AS_CSHRC_UPDATE_PKG_PATH = "~/.csh"
endif

if (! $?AS_CSHRC_UPDATE_PKG_URL) then
	set AS_CSHRC_UPDATE_PKG_URL = 'http://as.hl.domino.sh/projekte/cshrc/'
endif

if (`alias cshrcupdate` == '') then
	aliass cshrcupdate ~/.csh/cshrcupdate.csh
else
	
	set _pkg_name = "cshrc-$AS_CSHRC_VERSION.tar.bz2"

	switch ($1) 
	case package:
		if (! -d $AS_CSHRC_UPDATE_PKG_PATH) then
			echo "Fehler: $AS_CSHRC_UPDATE_PKG_PATH existiert nicht"
			breaksw
		endif
		echo "erstell Pakett:"
		csh -c "cd ~; tar cvjf $AS_CSHRC_UPDATE_PKG_PATH/$_pkg_name .cshrc .csh/*.csh .csh/*.tcsh"
		printf "%-8s%-20s%s\n"  "$AS_CSHRC_VERSION" "$_pkg_name" "`date`" > $AS_CSHRC_UPDATE_PKG_PATH/VERSION
		breaksw

	case update:
		echo "Version laden..."
		cp_remote_file $AS_CSHRC_UPDATE_PKG_URL/VERSION /tmp/cshrc.install.version
		if (! -f /tmp/cshrc.install.version) then
			echo "Fehler: konnte $AS_CSHRC_UPDATE_PKG_URL/VERSION nicht laden."
			breaksw
		endif
		set _new_version = `awk '{print $1}' /tmp/cshrc.install.version`
		set _new_pkg = "$AS_CSHRC_UPDATE_PKG_URL"`awk '{print $2}' /tmp/cshrc.install.version`
		echo "alte Version: $AS_CSHRC_VERSION"
		echo "neue Version: $_new_version"
		echo "PKG laden..."
		cp_remote_file $_new_pkg /tmp/cshrc.install.pkg
		if (! -f /tmp/cshrc.install.pkg) then
			echo "Fehler: PKG konnte nicht geladen werden."
			breaksw
		endif
		echo "alte Version loeschen..."
		rm -v ~/.cshrc ~/.csh/*.csh ~/.csh/*.tcsh
		echo "PKG installieren..."
		csh -c "cd ~; tar xvjf /tmp/cshrc.install.pkg"
		echo "temporaere Files loeschen..."
		rm -v /tmp/cshrc.install.version /tmp/cshrc.install.pkg
		breaksw
	
	case install2host:
		if ($2 == "") then
			echo "Fehler: kein Host angegeben."
			breaksw
		endif
		scp -r ~/.csh* "${2}:"
		breaksw

	case version:
		echo $AS_CSHRC_VERSION
		breaksw

	case version-new:
		echo "Version laden..."
		cp_remote_file $AS_CSHRC_UPDATE_PKG_URL/VERSION /tmp/cshrc.install.version >& /dev/null
		if (! -f /tmp/cshrc.install.version) then
			echo "Fehler: konnte $AS_CSHRC_UPDATE_PKG_URL/VERSION nicht laden."
			breaksw
		endif
		echo `awk '{print $1}' /tmp/cshrc.install.version`
		rm /tmp/cshrc.install.version
		breaksw

	default:
		echo "Hilfe cshrcupdate: [package|update|version|version-new|install2host]"
	endsw

	unset _pkg_name _proc_get _new_version _new_pkg

endif