#!/bin/bash ## replacement for "cp -fpuv" in webput, to issue WARNING for web-copy being newer than "source"-copy; Eugene Reimer 2009-12-14; ## and modify by discarding private-copy-only lines, and unyanking published-copy-only lines -- details below; ## ## USAGE EXAMPLE: ## webcp /etc/sbin/bc $DIR/programs ##typical use has dir as last opnd ## webcp /beans/00-README.htm $DIR/programs/beans-README.htm ##but not always ## webcp /beans/beans.zip /books/books.zip $DIR/programs ##multi-srcfile example-1 ## webcp /etc/sbin/{bc,scalepix} $DIR/programs ##multi-srcfile example-2 (handled same as preceding) N=$#; DSTARG=${!N} ##get N nbr-of-args, DSTARG the Nth-arg for((J=1; J$DST" ##provide info-msg similar to cp with -v cat $SRC |sed '/\t.*{in priv/d; /{in pub/s|^##||' >$DST ##==copy with private-only/published-only modifications, with braces and only-leading-"##" for safety touch -r$SRC $DST ##timestamp on DST to same as SRC ##if grep -q '{in p' $SRC;then dif $SRC $DST; fi ##debug fi done ##cp -fpuv "$@" ##copy-if-newer: the original method using cp-command with -u exit FIRST-USE PROBLEMS: =================== 2009-12-14: first use found 5 cases where web-copy NEWER than source-copy: WARNING: /er/website/plautdietsch/aa-intro-etc.htm NEWER than source-copy: /pix/er-HermanRempelDictionary/aa-intro-etc.htm WARNING: /er/website/plautdietsch/endefns.htm NEWER than source-copy: /pix/er-HermanRempelDictionary/endefns.htm WARNING: /er/website/plautdietsch/pddefns.htm NEWER than source-copy: /pix/er-HermanRempelDictionary/pddefns.htm WARNING: /er/website/programs/CanadaPost.pm NEWER than source-copy: /pix/pkg/Business-CanadaPost-1.04/lib/Business/CanadaPost.pm WARNING: /er/website/programs/find-unprintable-meaning-nonASCII NEWER than source-copy: /etc/sbin/find-unprintable-meaning-nonASCII CanadaPost.pm <--source lacked UTF-Conversion ==web-copy-Timestamp Sep 16 00:02 -- AND web-copy was UTF-converted!! the 3 plautdietsch files were identical except for TS ==web-copy-Timestamp Sep 16 00:02 => UTF-conversion involved?? find-unprintable-meaning-nonASCII identical except for TS ==web-copy-Timestamp Sep 16 00:02 => UTF-conversion involved?? --looks as though the web-files got TS-revision during UTF-conversion, but some other dirs done with TS-preservation--??-- --checked my UTF-conversion script: cvt-textfiles-to-utf8-charset, --checked its LOG of cvted files: /pix/er-Conversion-to-UTF-notes-etc/OUTPUT-20090915-cvt-to-utf8-LOG-actual-conversion --YUP, altho final version cvt script does NOT preserve timestamp; my earlier version did, then ran TS-revising fixups so my lftp uploads would work; --YUP, web-copy of CanadaPost.pm was converted, but the "source"-version was NOT (because I excluded /pix/pkg); --SUMMARY: all 5 were UTF-Conversion glitches; only one needed nontrivial fix: --fixed the 4 identical ones using touch-r --ran: cvt-textfiles-to-utf8-charset /pix/pkg/Business-CanadaPost-1.04 <--to utf-convert source-version of CanadaPost.pm ENHANCEMENTS NEEDED: ==================== Have long contemplated writing this "webcp" or "webinstall" script, for use webput, in order to: 1) add cpyright-notice, to program being copied; 2) remove "ER-only" or "NOCI-only" features, remarks, such as lengthy notes on old problems best left unpublished, short notes like "see ER-filename"; eg: webput cat+sed copying of calendar_ca.txt -- that one could use webcp-with-this-feature, for systematic commenting-out; eg: mk-calendar-covers shows another approach, handling ER-only features by testing $USER==ereimer, so that no removing/commenting-out is needed; eg: navER.css + navER.js each made by subsetting /noci/website/nav1-head.txt -- probably beyond the scope of this feature:-) ==some of these now handled 2010-11-24 via private-only and public-only conventions; 3) analyze bash-script for other ER-scripts being used, handling some by inlining, others by added "PREREQ" remark; eg: to-be-inlined: copy, remove, star, norm; eg: to-be-PREREQed: chg, rename, arr; <==have decided against the use of inlining... ==SEE: webcheck-bashscripts, which checks for missing prereqs; 4) support install-method other than "cp" -- see webput for candidates -- to make webput shorter & simpler (for the installer-script cases); CHANGE-LOG: =========== 2009-12-14: webput now uses this script; wrote it when I caught myself editing a web-copy rather than the source-copy (books-README.htm); 2010-11-24: new feature: discarding private-copy-only lines, and unyanking published-copy-only lines; is being used in weblinkcheck.cron, WEBGETLOGS.cron; BEWARE: of those strings spuriously triggering the sed-modifications; for added safety: using braces vs parens, and only leading "##" is being removed; added "\t" to prevent the cat|sed cmdline from discarding itself when webcp is used to copy webcp; klugeyness to a mind-boggling extreme:-) 2010-12-15: started getting 403 (Forbidden) on WEBPUT-LL bk-auto.cron, which were Non-World-Readable; fixed by revising attribs, but BEWARE of other such!! 2010-12-18: considering new option to remove EXEC-attrib on the copy; only needed if .cgi reconfiguring inadequate...