diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3417e77 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +# FreeBSD Ports Makefile For 'tloop' +# $Id: Makefile,v 1.1 2015/04/23 20:56:23 tundra Exp $ + +all: # Nothing to do, it's a shell script + +install: + ${BSD_INSTALL_SCRIPT} -o root -g wheel -m 755 tloop.sh ${PREFIX}/bin + ${BSD_INSTALL_MAN} tloop.1.gz ${PREFIX}/man/man1 diff --git a/TODO b/TODO new file mode 100644 index 0000000..2a6e461 --- /dev/null +++ b/TODO @@ -0,0 +1,4 @@ +# List of open To Do items for tloop +# $Id: TODO,v 1.1 2015/04/23 20:56:23 tundra Exp $ + + diff --git a/WHATSNEW.txt b/WHATSNEW.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/WHATSNEW.txt diff --git a/makefile b/makefile new file mode 100644 index 0000000..76a92a7 --- /dev/null +++ b/makefile @@ -0,0 +1,164 @@ +# Build a release of 'tloop' using 'make' +# Requires a modern 'make' like GNU. +# +# Copyright (c) 2015 TundraWare Inc., Des Plaines, IL 60018 USA +# All Rights Reserved. For Terms Of Use See: tloop-license.txt +# +# For Program Updates See: http://www.tundraware.com/Software/tloop +# +# $Id: makefile,v 1.1 2015/04/23 20:56:23 tundra Exp $ + + +# Uncomment One Of The Following For Early Releases + +#EARLY = Alpha +#EARLY = Beta +#EARLY = RC1 + +##### +# Definitions Relevant To This Program +##### + +PROGNAME = tloop +PROGMAIN = tloop.sh + +PROGFILES = ${PROGMAIN} # setup.py # Uncomment this if desired for python modules +PROGDOCS = ${PROGMAIN}.ps + +DOCS = tloop-license.txt \ + ${PROGNAME}.1.gz \ + ${PROGNAME}.html \ + ${PROGNAME}.pdf \ + ${PROGNAME}.ps \ + ${PROGNAME}.rst \ + ${PROGNAME}.txt \ + CHANGELOG.txt \ + Makefile \ + + +##### +# Nothing Should Need To Change Below This Line +##### + + +DIR = ${PROGNAME}-${VERSION} +HEADER1 = "WHATSNEW For '${PROGNAME}' ${VERSION} (`date`)" +HEADER2 = "----------------------------------------------------------------------" +RELEASES = "Releases" +TARBALL = ${DIR}.tar.gz +TMPFILE = tmpfile +VERSION = $(shell cvs log ${PROGMAIN} | grep ^head\: | cut -f2 -d " ")${EARLY} + + +##### +# Pattern Rules +##### + +### +# Document Production +### + +# Some Docutils installations keep the ".py" suffix for the various +# frontend programs, and some do not. It's even possible there are +# links from one to the other. Since the project can be checked out +# on any platform, we have to check for this every time we run the +# 'make'. This is irritating. + +2HTML = $(shell which rst2html.py rst2html 2>/dev/null | head -n 1) +2LATEX = $(shell which rst2latex.py rst2latex 2>/dev/null | head -n 1) --stylesheet=parskip --latex-preamble="\usepackage{fullpage}" +2ODT = $(shell which rst2odt.py rst2odt 2>/dev/null | head -n 1) +2MAN = $(shell which rst2man.py rst2man 2>/dev/null | head -n 1) + +# TeX/LaTeX Processing + +DVIPS = dvips +PDFLATEX = pdflatex +LATEX = latex + +%.dvi : %.latex + ${LATEX} $*.latex + +%.html : %.rst + ${2HTML} <$*.rst >$*.html + +%.latex : %.rst + ${2LATEX} $*.rst >$*.latex + +%.1 : %.rst + ${2MAN} <$*.rst >$*.1 + +%.1.gz: %.1 + @gzip -c <$*.1 >$*.1.gz + +%.odt : %.rst + ${2ODT} <$*.rst >$*.odt + +%.pdf : %.latex + ${PDFLATEX} $*.latex + ${PDFLATEX} $*.latex + ${PDFLATEX} $*.latex + +%.ps : %.dvi + ${DVIPS} $*.dvi + +%.txt: %.1 + @groff -man -Tascii $< | col -xb >$@ + +### +# Pretty Print Programs & Scripts +### + +%.pl.ps: %.pl + @enscript -Eperl --color -fCourier8 -i2 -L77 -C --mark-wrapped-lines=arrow -p$@ $< + +%.py.ps: %.py + @enscript -Epython --color -fCourier8 -i2 -L77 -C --mark-wrapped-lines=arrow -p$@ $< + +%.sh.ps: %.sh + @enscript -Esh --color -fCourier8 -i2 -L77 -C --mark-wrapped-lines=arrow -p$@ $< + + +##### +# Actual Build Rules +##### + +FORCE: + +CHANGELOG.txt: FORCE + @cvs log ${PROGMAIN} >CHANGELOG.txt + +WHATSNEW.txt: FORCE + @printf "%s\n%s\n\n" ${HEADER1} ${HEADER2} | cat - $@ >${TMPFILE} + @mv ${TMPFILE} $@ + @jmacs $@ + @cvs commit -m${HEADER1} $@ + +docs: ${DOCS} ${PROGDOCS} + @chmod 644 ${DOCS} ${PROGDOCS} + @chmod 644 *.gz *.txt + +release: docs WHATSNEW.txt ${PROGFILES} + @mkdir ${DIR} + -@mkdir ${RELEASES} 2>&1 >/dev/null + @cp -pv WHATSNEW.txt ${PROGFILES} ${DOCS} ${PROGDOCS} ${DIR} + @tar -czvf ${TARBALL} --exclude CVS ${DIR} + @rm -rf ${DIR} + @mv ${DIR}.tar.gz ${RELEASES} + +##### +# Housekeeping +##### + +clean: + @rm -rf *~ *.1 *.1.gz *.aux *.core *.dvi *.latex *.log *.out tmpfile *.toc + +version: + @echo ${VERSION} + +scrub: clean + @rm -rf ${DIR} ${PROGFILES} ${DOCS} ${PROGDOCS} ${TARBALL} ${TMPFILE} + +init: scrub + cvs update + + diff --git a/tloop-license.txt b/tloop-license.txt new file mode 100644 index 0000000..8cfcf1a --- /dev/null +++ b/tloop-license.txt @@ -0,0 +1,99 @@ +$Id: tloop-license.txt,v 1.1 2015/04/23 20:56:23 tundra Exp $ + +In order to use, study, modify, or copy 'tloop', you must read +and agree to all the licensing terms below. If you do not agree with +or do not understand *ANYTHING* you see in this document, you are NOT +granted a license to use, study, modify, or copy 'tloop'. By +using, studying, modifying, or copying 'tloop', you are agreeing +to all the terms of the 'tloop' LICENSE below in their entirety. + + + 'tloop' LICENSE AGREEMENT + + +1) DEFINITIONS + +Throughout this Agreement, the term 'tloop' is used to mean: + +Anything included in the 'tloop' software distribution package +from TundraWare Inc. This includes scripts, programs, documentation, +license text and all other files provided in that original software +distribution package. + +Throughout this Agreement the term "User" is used to mean any person +who is enagaged in any of the following activities: + + a) Uses any files found in the 'tloop' software distribution + in any way. + + b) Reads the 'tloop' documentation. + + c) Reads or studies the 'tloop' program source code or + supporting files. + + d) Makes use of any part of the 'tloop' software distribution + for any purpose. + + e) Duplicates and/or distributes the 'tloop' software distribution. + + +2) OWNERSHIP + +'tloop' Is Copyright (c) 2015 TundraWare Inc., Des Plaines, IL 60018 USA +All Rights Reserved. + + +3) TERMS + +Permission is hereby granted to the User for the duplication and use +of 'tloop' so long as ALL the following conditions are met: + + a) There is no license fee for any use of 'tloop' + whether personal, commercial, non-profit, or government *so + long as you abide by the terms of this license agreement*. + Voluntary donations are always welcome. Information on how to + contribute can be obtained by contacting: + + tloop@tundraware.com + + b) The User of 'tloop' understands and agrees that this is + EXPERIMENTAL SOFTWARE which is provided "AS-IS" with no + warranties expressed or implied by TundraWare Inc. + + c) The User acknowledges 'tloop' has NOT been tested for: + + i) Correct operation + + ii) Freedom from unintended consequences + + iii) Any operation or condition which might cause damage, + compromise, or disruption to the User's or other: + hardware, software, networks, or data, or which might + cause any breach of system security of such systems, + software, and networks. + + d) By using 'tloop' in any way, the User does so at their + own risk and agrees to hold TundraWare Inc. harmless for any + damage, direct or indirect, that this software may or does + cause to the User's computational environment, including, but + not limited to, the User's or others' hardware, software, + network, or data. THE USER FURTHER AGREES TO HOLD TundraWare Inc. + INC. HARMLESS FOR ANY ECONOMIC DAMAGE OR ANY OTHER ADVERSE + CONSEQUENCE, DIRECT OR INDIRECT, CAUSED BY THE USE OF + 'tloop'. + + e) If duplicated and/or distributed, no fee beyond reasonable + duplication charges may be charged for 'tloop'. No + commercial use of 'tloop' which involves any + remuneration beyond these duplication charges is permitted. + + f) Any distributed copies of 'tloop' must include all the + originally provided software, documentation, and licensing + information in their original distribution format and + packaging without any modifications. + +By using any part or all of 'tloop', you are agreeing to be +bound by this license. + +IF YOU DO NOT UNDERSTAND, OR CANNOT ABIDE BY ANY OF THESE CONDITIONS, +DO NOT USE 'tloop'. diff --git a/tloop.rst b/tloop.rst new file mode 100644 index 0000000..f697d02 --- /dev/null +++ b/tloop.rst @@ -0,0 +1,70 @@ +NAME +---- + +**tloop** - Manage Loopback Devices __DESCRIPTION__ Image Mounts For Linux + + +SYNOPSIS +-------- + +tloop.sh [-hv] + + +DESCRIPTION +----------- + +Long description + + +OPTIONS +------- + + -h Print help information + -v Print detailed program version information and exit + + +OTHER +----- + +You must have a reasonably current version of ``the shell interpreter`` installed. + + +BUGS AND MISFEATURES +-------------------- + +None known as of this release. + + +COPYRIGHT AND LICENSING +----------------------- + +**tloop** is Copyright (c) 2015 TundraWare Inc., Des Plaines, IL 60018 USA + +For terms of use, see the ``tloop-license.txt`` file in the +program distribution. + +If you install **tloop** on a FreeBSD system using the 'ports' +mechanism, you will also find this file in:: + + /usr/local/share/doc/tloop + +AUTHOR +------ + +:: + + Tim Daneliuk + tloop@tundraware.com + + +DOCUMENT REVISION INFORMATION +----------------------------- + +:: + + $Id: tloop.rst,v 1.1 2015/04/23 20:56:23 tundra Exp $ + +You can find the latest version of this program at: + + http://www.tundraware.com/Software/tloop + diff --git a/tloop.sh b/tloop.sh new file mode 100755 index 0000000..61072fb --- /dev/null +++ b/tloop.sh @@ -0,0 +1,293 @@ +#!/bin/sh +# tloop.sh - Manage Loopback Devices __DESCRIPTION__ Image Mounts For Linux +# Copyright (c) 2015 TundraWare Inc., Des Plaines, IL 60018 USA +# All Rights Reserved. For Terms Of Use See: tloop-license.txt +# For Program Updates See: http://www.tundraware.com/Software/tloop +# $Id: tloop.sh,v 1.1 2015/04/23 20:56:23 tundra Exp $ + +# Embed the source control ID string for use by program + +CVSID='$Id: tloop.sh,v 1.1 2015/04/23 20:56:23 tundra Exp $' + +# -------------------------------------------------------------------------- # +# Program Information # +# -------------------------------------------------------------------------- # + +COPYRIGHT="Copyright (c) 2015 TundraWare Inc., Des Plaines, IL 60018 USA" +VERSION=`echo ${CVSID} | cut -d " " -f 3` + + +# -------------------------------------------------------------------------- # +# Script Interface Definition # +# -------------------------------------------------------------------------- # + +##### +# Inputs And Command Line Arguments +##### + +# -h Prints help information +# -v Prints program version information + +##### +# Outputs +##### + + +# - Error output is written to stderr + + +##### +# Side Effects +##### + + +# -------------------------------------------------------------------------- # +# Variables, Constants, Literals, And Strings # +# -------------------------------------------------------------------------- # + +##### +# Program Related Stuff +##### + +HELPTEXT="tloop.sh ${VERSION} - Manage Loopback Devices __DESCRIPTION__ Image Mounts For Linux \n\ + Usage: tloop.sh -XYZhv \n\ + where, \n\ + \n\ + -X Option X \n\ + -Y Option Y \n\ + -Z Option Z \n\ + -h Print Help Information \n\ + -v Print Version Information \n\ +" + +##### +# Error Messages +##### + +eBADARGS="Invalid Command Line Argument!" + + +##### +# Stuff Needed By promptuser() Function Below +##### + +ORIGIFS=$IFS # Save current field separator +DL=';' # Prompt field delimiter +YN="Y y N n Yes yes No no YES NO" + + +# -------------------------------------------------------------------------- # +# Function Definitions # +# -------------------------------------------------------------------------- # + +##### +# Print An Error Message +##### + +ErrorMsg() +{ + printf "${*}\n" >&2 +} + +# End of 'ErrorMsg()' + + +##### +# Print An Informative Message +##### + +PrintMsg() +{ + printf "${*}\n" +} + +# End of 'PrintMsg()' + + +##### +# Print Usage Information +##### + + +Usage() +{ + PrintMsg "${HELPTEXT}" +} + +# End of 'Usage()" + + +##### +# Prompt User With Optional Response Validatation +##### + +# tpromptuser.sh - User Prompting From Shell With validation +# Copyright (c) 2010-2012, TundraWare Inc, Des Plaines, IL USA +# All Rights Reserved. +# For Updates: http://www.tundraware.com/Software/tpromptuser +# Id: tpromptuser.sh,v 1.113 2012/06/06 02:26:15 tundra Exp + +##### +# You are hereby granted a non-exclusive license to do whatever you +# like with this software so long as you understand this is +# *EXPERMENTAL SOFTWARE* that has not been thoroughly tested. It may +# cause harm to your systems, data, and/or network. It may compromise +# your security. It may cause other, unspecified, kinds of harm to +# your IT environment or business. In other words: +# +# USE THIS AT YOUR OWN RISK!!!!!! +##### + +# Takes a list of prompts as arguments + +tPromptUser() + +{ + + for x in $* + do + eval record=\$$x # Get the prompt record + IFS=$DL # Get individual fields + read prompt default answers <Default Response (If user just hits Enter)Legal Answers (space separated) +# Notes: +# +# 1) An empty Prompt field means there will be no prompt displayed +# +# 2) An empty Default Response field means that, if the user hits enter, +# the response is blank +# +# 3) An empty Legal Answers field mean the routine will accept *any* input +# +# 4) It's up to you to make sure the Default Response is a legit answer. +# It is NOT checked against the Legal Answers list. +# +# When the call to tPromptUser returns, the user's response will be stored +# *in the variable* that contained the prompting information. + + +# Examples + +foo="Would you like to foo?${DL}Y${DL}" # Empty last field means accept anything +bar="Would you like to bar?${DL}\!${DL}${YN}" +baz="Would you like to baz?${DL}n${DL}${YN} yup" +bat="Would you like to bat?${DL}${DL}nope" + + +tPromptUser "foo bat" +PrintMsg "foo: ${foo}, bat: ${bat}" +tPromptUser "bar baz" +PrintMsg "bar: ${bar}, baz: ${baz}" +