dphys-config/FAQ0000644000175500017550000000260511336573665012476 0ustar neilneilhttp://neil.franklin.ch/Projects/dphys-config/FAQ author Neil Franklin, last modification 2010.02.16 copyright ETH Zuerich Physics Departement use under either modified/non-advertising BSD or GPL license Frequently* Asked Questions (FAQ) for the dphys-config configuration manager * not really frequent, but that is what such files are called Q: Why are you making this program? A: To automatically install/update and remove config files, on 100s of hosts, based on an list of config files fetched from an server, listing places to put them, and scripts to trigger Q: Will this work on my $DISTRIBUTION? A: This script should work on any Unix system which can wget (for HTTP access) to an server full of host specific config files or symlinks to group/site specific ones. It has only been tested on our Debian Linux 3.1 (sarge) systems and on FreeBSD 6.1. Q: Why is this called dphys-config? A: Departement of PHYSics - CONFIGuration tool Q: Where can I get code? A: The current (read: in edit, sometimes not functional) from: http://neil.franklin.ch/Projects/dphys-config/ or: http://neil.franklin.ch/Projects/dphys-config.tar.gz or Various milestones/releases (read: archives, working) from: http://neil.franklin.ch/Projects/dphys-config-/ or: http://neil.franklin.ch/Projects/dphys-config-.tar.gz where last milestone/release is =20100216 dphys-config/INSTALL0000644000175500017550000000301011336573712013155 0ustar neilneilhttp://neil.franklin.ch/Projects/dphys-config/INSTALL author Neil Franklin, last modification 2010.02.16 copyright ETH Zuerich Physics Departement use under either modified/non-advertising BSD or GPL license To install/config/use dphys-config do the following: Source install ============== 1. Download and unpack the .tar.gz archive file from: http://neil.franklin.ch/Projects/dphys-config.tar.gz or http://neil.franklin.ch/Projects/dphys-config-.tar.gz where last milestone/release is =20100216 make make install Configuration ============= 1. ensure that wget is installed 2. install this software 3. make HTTP server space which will host the config files and file list (dir, HTTP server config, DNS, etc), such as http://server/configs/sarge/* 4. in the virtual servers base directory, make for each host an directory, such as http://server/configs/sarge//* 5. in this host directory put an file listing the files to be installed; with each line formatted: file-on-server:path-on-target:script-to-run as many hosts have the same files, hardlink or symlink them to an file in an http://server/configs/sarge//* directory 6. set up the config file /etc/dphys-config - where your file list and config files are to be found 7. run the /usr/bin/dphys-config script at every startup: - /usr/bin/dphys-config init and daily from cron: - 0 3 * * * root /usr/bin/dphys-config cron > /dev/null 2>&1 For details read the included dphys-config.1 man page. dphys-config/Logfile0000644000175500017550000010523712114160321013425 0ustar neilneilhttp://neil.franklin.ch/Projects/dphys-config/Logfile - done and todo author Neil Franklin, last modification see last entry near bottom copyright ETH Zuerich Physics Departement use under either modified/non-advertising BSD or GPL license background is the dphys-admin project, read its Logfile at: http://nic.phys.ethz.ch/projects/dphys-admin/Logfile as part of that wrote this tool to do auto-loading of config for packages here only log of the events pertaining to making this tool 2005.04.28 Thu looking at dphys-admin example config and dphys-local-admin generated config note that dphys-local-admin also sets /etc/default/dphys, also needs change only contains url-path for accessing config files on config server heeb discussion about /etc/default/dphys and what packages use it according to new policy all dphys-setup-* use local files, no net access only dphys-local-* fetches stuff from server, used by older packages has led to proliferation of dphys-local-* packages, work, duplicate code heeb uses dphys-common-tools lib now, common code, has url-path hardcoded bring up suggestion of single downloader, dphys-config, with url-path in it on server then file with list file-on-server:path-on-target:script-to-run will require per-package config files, no splitting/processing is cleaner, but means that keyboard needs setting twice (X and console) split out /etc/default/dphys to separate dphys-local-etc-default-dphys to be left there, so long still old-style packages use it add that to top of /pub/debian-local/share/main.pkglist to be safe senguen discuss paths for config files we will use http://server/configs/sarge// which will then be /pub/debian-local/configs/sarge// 2005.04.29 Fri forked dphys-config project off from dphys-admin while starting up that removed 3.0 remark from README make dphys-config so it will work on woody and sarge, so path version depend no file contains "woody" or "sarge", only /etc/debian_version "3.0" or "3.1" so path http://server/configs/`cat /etc/debian_version`// and with http://server/configs/sarge// comfort symlink makesourcepackage generated project directory Makefile new title line, README adapted from dphys-admin, Logfile started 2005.05.12 Thu further generating project, FAQ, INSTALL sketched out what features need to go in 2005.05.13 Fri further generating project, index.html.*, makefile make tar dphys-config.example setting CONF_BASEURL for server and subdir needed to read configs, so not settable by dphys-config so set it by dphys[2|3] end[firstrun|2ndstage] by writing into file this also solves the `cat /etc/debian_version` problem dphys[2|3] dependant [woody|sarge] string in above action started coding dphys-config all sh script boilerplate taken from makesourcepackage (dphys-admin is perl) while at it more code unification, added stuff missing in some places download list of config files to process, file tests copied from dphys-admin test runs download, wget of 404 files faills to give error message 2005.05.19 Thu further coding dphys-config, missing wget error message was missing "!" made /pub/debian-local/configs/woody/pomfrey/conf_list dir and test conf_list despite 1 line loops runs twice, 1st for conffile, 2nd for place is because -d sets line end, not field separator using IFS= fails with syntax error, use cut, this works allow $SCRIPT to be a full command with parameters, strip for some stuff allow commented out lines and empty lines in config files list made an cron.d script and started init.d script how pass cron/init.d to dphys-admin? not at all, own scripts for such cases same for special stuff like dphys-admin, own init.d and cron.d for timing 2005.05.20 Fri dphys-config finished init.d script, run early before daemons search all dphys-local-* packages for functions they do decide what to offer in dphys-config, and what to expect in scripts dphys-local-admin: generate /etc/dphys-admin URL base (now superfluous as we load), and email adress -> get 2 files dphys-local-afs: get /etc/openafs/CellServDB file from server generate /etc/default/afs.conf from config vars -> get a file dphys-local-anacronconf: generate /etc/cron.d/anacron to start anacron -> file, with randomised time already in it dphys-local-aptconf: generate /etc/apt/sources.list -> get file (or files) dphys-local-auth: get /etc/ssh/* and chown/chmod, inst /etc/pam.d/* files generate /etc/pam_ldap.conf with config var in it, host in group generate /etc/cron.allow from NIS -> all get files (host specific) dphys-local-autofs: generate auto.master and restart /etc/init.d/autofs -> files and trigger script (or direct restart command) dphys-local-console-keymap: get config, run /usr/sbin/install-keymap -> leave or install an file and run script dphys-local-debconf: just set critical and noninteractive -> done already dphys-local-devfsconf: generate /etc/devfs/compat_symlinks -> get file and we are dropping devfs -> so no need anyway dphys-local-dhclient: generate /etc/dhclient.conf -> get file after 10 scripts it seems, copy+script is enough worst case make an (reduced) package with just special actions man page dphys-config.8, from dhys-admin, but as sh also from dphys-pkgtools while doing this noticed inconsistent terminology and missing functions main->common (better to read) and conf_list->dphys-config (more obvious) config files may need paths making (else error and not there) if file installed under same name (usual) dont require duplicate typing have an option for removing config files not needed any more 2005.05.26 Thu for better user visible naming changes: main->common, pre|post->hostpre|hostpost, conf_list->dphys-config.list make directory for new config files for place path ending in / add file name, save user typing while man page added example where full name needed, same name, diff dir added for debugging an directory base, so can test in /tmp/.../ test runs, fixes, OK improved man page wording and formatting, pass to senguen to check over 2005.05.27 Fri on pomfrey make /etc/dphys-config config file, as no dphys-local-config wanted package version 20050527.122702-1, changelog: "initial release" fails to install /usr/sbin/dphys-config was Makefile, still had # in each line, from when generating intro to senguen, how to use it, explained exact site layput, ideas make /pub/debian-local/configs/woody/`hostname` directories for all added symlinks to ../SITE/dphys-config.list made empty (only comments) SITE/dphys-config.list file all hosts made /etc/dphys-config file with server location existing dphys-admin pkglist file added dphys-config so it gets installed with senguen ported some dphys-local-* packages, see how it performs noticed good thing to oder some files into directories under SITE can copy by dir/file syntax, but in /tmp/dphys-config-*/ needs mkdir -p files wgetted have current time, lose edit time, tried -N, same, leave it if command is multiple separated by ; shell fails to split them, use eval 2005.06.09 Thu fixed debian/dphys-config.init, removed unneccessary and effectless parameter was still /usr/sbin/dphys-config init, from editing old dphys-admin script if no scripts found, not just warning, also don't run missing script improved error messages, log fatal and warning, for when running cron/init.d packaged version 20050609.173645-1, changelog: "fix init.d, no script don't run, improve err msg, syslog fatal/warning" 2005.06.10 Fri on system install with config before admin, using scripts only fetched by admin gives time dependency, admin packages need config, so must be this way config already doesn't run script, and then gives warning, ignore it user can avoid warning if using /bin/sh -c "if [ ... ] ; then ... ; fi" then admin fetched packages must run script on install (postinst/init.d) if it finds an preexisiting (non-purge remove or config) file there document this behaviour and solution in man page packaged version 20050610.134347-1, changelog: "improved man page, gotchas, dphys-config vs dphys-admin install time" 2005.06.16 Thu problem with wget -N and -O options clashing, -N not really usefull, remove it packaged version 20050616.130021-1, changelog: "bugfix wget without -N, some verbose output now as info" senguen request optimise output, -v all, no -v installing/script, -q nothing made wget retry each file 3 times, and put out error if not finding server at present we have with 150 hosts and 30 files up to 5 faillures every night packaged version 20050616.152551-1, changelog: "changed cron.d time to avoid 04:00 net reconfig troubles" 2005.06.17 Fri above wget 3 times also fails, now explicit loop, call 3 times and evaluate only return on 200 or 404 status, everything else log and abort packaged version 20050617.130219-1, changelog: "bugfix config overwrite partial with files when DNS sporadic fails" spread load of 150 systems over an hour like dphys-admin call with none|"none"|"cron"|"init" mode, on cron delay by rand file permissions of installed files, man page document chown/chmod usage packaged version 20050617.142523-1, changelog: "randomised cron run times to spread load, man documented chown/chmod" 2005.06.30 Thu senguen no // in path, fixed generating CONFPLACE packaged version 20050630.105838-1, changelog: "fixed // in install paths" 2005.07.01 Fri also handle large files, such as entire kernel.tar.gz files so keep all downloaded "temporary" files, for wget -N, permanent work dir no delete of temp dir at end, so move from /tmp to /var/cache wget no -O, so use (cd ; wget), so no file renaming, no .common, use .merged test run, works in /tmp/dphys-config.debug, but pam.d/* screwed is missing -O which contained pam.d/, dir needs to go into cd handle chown/chmod problems, now that temporary files are permanent packaged version 20050701.155459-1, changelog: "handle large files, only fetch once, unless file changed" 2005.07.07 Fri corrected some outdated comments 2005.09.08 Thu all scripts added exit 0 at end, following new policy makefile install .example man page document options -q -v -D -h set INSTALL = to ???????? (= none yet) packaged version 20050708.144751-1, changelog: "fix for sarge chown/chmod -f bug" 2005.09.15 Thu improved man page gotchas section wording 2005.09.23 Fri on booting errors, because can not access config files server is because identd is only started by inetd with is rc2.d/S20, we have S18 delay execution until after S20, will need restarting updated S20 daemons needs to run before dphys-admin (S24), so run as S22, changed debian/*.init packaged version 20050923.171624-1, changelog: "bugfix rc2.d/S?? runlevel, after S20 of inetd and identd" 2005.09.29 Thu still failed, works on newly installed, but not on updated preexisting is fault of update-rc.d, does no install if existing link, no remove old fix this by doing an mv by hand, als all new machines work right 2005.10.13 Thu extended man page with more examples, loading scripts, improved wording also suggested method for making/copying an new host packaged version 20051013.151800-1, changelog: "improved man page, describe scripts and host copying" 2005.12.22 Thu changed CMD_* stuff to same new system as in dphys3 2006.06.29 Thu fixed -D bug, shift 1 after the if DEBUG_$1 tests, as in dphys3 and msp added set -e after config stuff, as now in all other scripts add robustness against non-0 return values, || /bin/true in some places added debug output of exit value of called scripts systematic command|script -> command naming for triggerable command chmod/chown of temp config files only if script run, else never reason 2006.06.30 Fri added support for uninstalling outdated config files run the facultative script as pre uninstall instead of post install yes, we are now up to the full abilities of Debian package install/remove just here for single non-packaged config files, and list file driven and with host specific assembly of each file from 3 parts pre/all/post when uninstalling only remove the target file its temporary files can not be located for sure, leave them in /var/cache when testing erroneous line with : at beginning, does nonsense should issue an error message and abort, same if no : or nothing after same also if no config file part could be retrieved, file(s) missing but allow any of the 3 parts to be missing, inkl the main/site one man page updated to reflect uninstall ability, added more examples packaged version 20060630.155509-1, changelog: "added ability to remove config files, with pre uninstall commands" 2006.07.02 Sun problem with recursive dpkg call hanging after update was because dphys-admin -> apt-get update -> dpkg -> dphys-config postinst -> init.d -> dphys-config init -> dphys-scripts -> dpkg (recursive) problem is using dpkg in dphys-scripts, instead of using dphys-admin `` stuff actually dphys-scripts itsself is a violation of dphys-config idea from dphys-config should not run stuff that changes dpkg (u/i/r/p) state while looking at this switched off debugging output which was left on packaged version 20060702.003332-1, changelog: "bugfix switched off debugging which was left enabled" 2006.07.27 Thu correct site and host directory tests, so it aborts if not there for command return value != 0 output and log an note added {} syntax to filed for commands to trigger it is substituted for the full filename of the file being (un)installed 2006.07.28 Fri {} syntax tested, updated man page, update/upgrade on our site simplified dphys-config.list using {} packaged version 20060728.131953-1, changelog: "bugfix Server reachability tests, added {} feature" for running triggered commands use /bin/sh -c instead of eval saves user typing /bin/sh -c whenever an if [ ] is needed and also safer than with subshell, variables of script not damagable 2006.08.03 Thu tested /bin/sh -c noticed foo:/root: instead of foo:/root/: gives user-incomprehensible errors check for such user errors, warn user and auto-correct them updated man page to not have /bin/sh -c "" in its script test example added -f option, to only run an filtered set of dphys-config.list lines saves time when just one/few config file(s) has been updated updated man page packaged version 20060803.105525-1, changelog: "triggered command full shell without sh -c "", added -f filter option" unified code for handling running external commands into run_command_safely () unified code for downloading/merging into fetch_and_merge_config_file () for variable amount and position of backtick/if/include brainstorming with heeb, only if first line #@dphys-config-preprocess ... ... with ... ... give selection and row of preprocessor modules to call this allows normal configfiles to stay unchanges, no accidents and per file user selecton how much needs to possibly be escaped `stuff` for substituting with stdout of an command, such as /bin/hostname #@if ; for host specific, condition may be [ ] #@include extension to generalise host[pre|post] 2006.08.04 Fri /bin/sh -c code change has been distributed, simplify dphys-config.list bug report, upgrade error on 30 of 150 hosts, CONFPLACE seems to be not set all of astro department (exept one) and just 2 others (and one special case) special case is most likely because having own dphys-config.list.hostpost upgraded "non-absolute place" from NOTE to WARNING, added log of it ensure that tests on CONFFILE_NAME and CONFPLACE defend against spaces debug run shows that /bin/grep ${CONF_LINEFILTER} is the culprint CONF_LINEFILTER set to .* for no filtering, and globbed after substitution so first filename in . becomes filter, rest files read instead of stdin packaged version 20060804.112852-1, changelog: "bugfix CONF_LINEFILTER missglobbed screwing config list" backtick/if/include preprocessor completed, extensive testing, works expanded man page with preproc options 2006.08.10 Thu senguen Bugreport that dphys-config fails on newly install hosts config files do not get installed, downgrade to 20060728 version works both newer source restored on server, diffs, just small stuff, should work pomfrey upgraded again to 20060804, test, works, must be new install problem try new install 20060728 fails on config lines without sh -c but only one warning, must have abborted before the second one is /usr/sbin/install-keymap `/bin/cat /etc/install-keymap` returns 128 known bug, Debian Bug ID 339005, surfaced here because of set -e 20060804 version has set +e and set -e to combat such stuff new try, again gets 20060728, makesourcepackage -ui is failing to upload rsync produces error 23, but transfers, makesourcepackage -u transfers makelocalsite deletes 20060804 instead of 20060728, is file date 20060728 has date of 0809 from restoring, so newer, 20060804 deleted delete 20060728 manually and reindex, try new install, works 20060804 try shows abbort after first triggered script, is an missed edit exit 0 -> return 0, not return ${RETVAL} else script abborts after return works now as it should, all installed, but no output for - lines while here add missing message when running - lines to current packaged version 20060810.132054-1, changelog: "bugfix missed exit 0 to return 0 in run_triggered_commands ()" further with preprocessor stuff testing, seems to work old, not used any more, file sections remain in the cache need to be replaced on server by empty files, not deleted, error prone wget can not delete them after now getting 404 when recieving an 404 delete the not fetched file, if existing but this fails because filename not known in broken_net_wget_or_die () and adding annother parameter makes code more bloated, less readable alternative get rid of caches version before fetching, or after installing or even at beginning all, or after run all, no cache at all, only spool|tmp has additional advantage of no need of copying over permissions to cache may produce more server load, but wget is doing 200 anyway, no cache effect and at roughly 1M of files per host not really relevant anyway removed all caching, deleted old cache directory now SYS_WORKDIR in /var/tmp, delete it at end of run test run shows warnings in syslog, from non-zero return values own scripts add exit 0 Debian stuff add || /bin/true to commands 2006.08.11 Fri test if still warning output in syslog, none any more noticed dphys-config-* scripts log that they have run add option and code for doing this, so log shows that we run, as no own log packaged version 20060811.111000-1, changelog: "preprocessor backticks/if/include, no cache" added all previous "packaged version ????????.??????-?, changelog:" lines same also done to all other projects, consistent better docs publish dphys-config-* scripts, added missing exit 0 updated comments in script to use new {} and sh -c handling features dphys-config-quota added missing set -e and needed || /bin/true copied all my scripts to SITE.example/local/sbin dir of dphys-config project and made in SITE.example an dphys-config.list and other files used by it 2006.08.17 Thu index.html.en extended with all dphys-config-* scripts, and their config files /etc/quota -> /etc/dphys-config-quota.list, config and script updated Makefile copy SITE.example to /u/s/d/dphys-config/examples dphys-config-usb-mouse merged into dphys-config-x, only if USB mouse used was already in, now just redundant old leftover, deleted dphys-config-x and dphys-config-filesys also log error messages into syslog while at it systematic adding of exit 1 after all ERROR and FATAL convert out site to using #@include instead of .host[pre|post] 2006.08.18 Fri processing for #@include screws up when * in line, expands with directory same problem as with grep .*, checked up all ${} and added "" where needed while test run without preprocessor tags error processing #@dphys-config-preprocess line, fails because cut -f 2- no " ", broken checked up all cut -f and added tests for if needed data there packaged version 20060818.153432-1 changelog: "bugfix ${} globbing * in data, bugfix cut -f 2- full line no delimitor" 2006.08.25 Fri finished convertig our site to use #@include instead of .host[pre|post] remove .host[pre|post] feature for -2/3 server load and -1/2 runtime get rid of .merged suffix, use everywhere the remaining ex main file name copy dphys-config.list to /etc, not just in /var/tmp, as that is now deleted allows better debugging of dphys-config.list generation, as it stays visible when missing #@include file no NOTE: warning, annoys users, little value packaged version 20060825.142020-1 changelog: "removed .host[pre|post] feature, dphys-config.list in /etc, no NOTE:" 2006.09.08 Fri dphys-config.8 lintian man page warning fixed, \ before - because groff crap 2006.09.14 Thu get ready for publication as an official Debian Linux ?.? (etch) package reworked and updated documentation, FAQ, INSTALL, README, index.html.en senguen wants to make own debian/* as lintian complains about native package looked into any information lost if deleting debian/* to avoid collision debian/changelog is all info duplicated in this Logfile, deleted it debian/control is just wget depends and docu text, add to other docs clearer in FAQ and man page, added to INSTALL and README debian/copyright is nearly same as in README, updated that debian/dphys-config.cron.d is simple example, move to main dir and removed debian/rules stuff #@rc.d@ start 22 2 . add to Makefile installation into examples directory debian/dphys-config.docs is nothing, deleted it debian/dphys-config.init is simple example, move to main dir add to Makefile installation into examples directory debian/rules has nothing specific, deleted it while editing man page noticed that it still refers to .host[pre|post] update this to the new situation, partial rewrite, clarifications while editing noticed terminology used uninstall vs remove standardise on remove, and on postinstall and preremove, not postinst analog to all other *.example rename SITE.example to site.example as only producing an "upstream" and senguen doing "maintainer" version remove FAQ and INSTALL and index.html.en references to my old packages 2006.09.15 Fri released 1st (and feature completed) milestone modified index.html and FAQ and INSTALL to show the milestone release no Debian packaging any more, senguen does this now, no changelog entry copy to ../dphys-config-20060915, made tar file of that remade ../dphys-config.tar.gz archive for current state senguen while "upstream" packaging made suggestion move /usr/sbin to /usr/bin as it can also be used for distributing users dotfiles to multiple homes change all sbin to bin and also all man page .8 to .1 add support for user configs ~/.dphys-config and ./dphys-config copy changes to milestone/release 1, make new tar of release 2006.09.21 Thu make place for storing dphys-config.list to variable, so can be user writable don't source ./dphys-config, danger of endless recursion, and near useless when user don't use /etc/dphys-config.list, go for ~/.dphys-config.list Debian sid sed 4.1.5 newly fails caucious \{\}, because old basic regex style sarge sed 4.1.2. still processed \{\}, remove both \, now works on both 2006.10.05 Thu index.html.en small text fixes, Link to official Debian package in Sid more checking for potential escaping problems, aggressive use of "" all echo and CMD*PRINT* which have variables which may derive from user data for VAR in "${VARS}" ; do fails, all ov VARS in one loop run so need to do this without "", so with tr filter ${VARS} only valid chars systematic rename to ${[SYS_]CONF[LIST|FILE][|_NAME|_URL|_PLACE]} shrink space devoted to site.example in index.html.en, for more releases update index.html.en and man page with what has changed since last release 2006.10.12 Thu senguen porting to FreeBSD finds no /bin/gzip and /bin/true, has both in /usr/bin (urgh) we already set PATH, revise that, add /usr/local (for FreeBSD ports) after that remove all absolute paths to commands, not only from Code but also all example scripts, man page examples, Makefile /bin/sh has no keyword function, sh and bash work without it, drop it why does damn bash not warn of this, when running called as /bin/sh? /bin/sh also fails on "~/.xxx", has to be given ~/."xxx" to work 2006.10.13 Fri after all bugfixes and changes new release updated FAQ, INSTALL, README, index.html.en copy to ../dphys-config-20061013, made tar file of that remade ../dphys-config.tar.gz archive for current state 2006.10.19 Thu better automated test for missing "${VAR}", found one automated search for possible missed cases, sed /\\$/N trouble 2006.10.20 Fri better automated test for missing "${VAR}", found annother one also replace ${TICK} processing with better, using set -e, prevent abbort while doing so found bug in #@if condition/line splitting, fixed as only fetched by senguen, no distribution, redo 2nd release no dphys-config-20061013 any more, just dphys-config-20061020 as 2nd 2006.12.22 Fri as part of taking this over als personal project, after leaving job moved everything from www.phys.ethz.ch/~franklin to neil.franklin.ch website changes all URLs to refer to new home, expanded links to other projects we decided that I will keep on maintaining this project (and dphys-swapfile) as I also use these 2 projects at home on my own non-Debian systems 2007.06.12 Tue added functioning (not wget based) support for file: URLs, corrected man page 2007.06.13 Wed trying to use new functionality, fixed wrong cut specification in file: test 2009.05.17 Sun bugfixes for 2 reported bugs by Axel Beckert wget returns HTTP status code server dependant, sometimes ok instead of OK so filter out only the numeric code, do not use the textual message using "| while read LINE ; do" screws up spaces, processed as separators add IFS= before read, and also -r after read, prevent mutilations this reported 3 times in preprocessing, but also once in own input file 2009.05.18 Mon Axel Beckert reports above bugfixes are OK he is also from today on the new official Debian maintainer for dphys-config reported that the behavior fixed by above -r is reported Debian bug 510910 request for new feature, option set hostname, is not `hostname` inside chroot this chroot is used for installing xen guests/vhosts, also good for tests new option -c (configname) and config variable CONF_CONFNAME=`hostname` documented option in help, also both of them in man page while at it als drop deleting old tmp cache dir, no hosts with this any more and the system variable SYS_OLD_WORKDIR used only for it 2009.05.19 Tue Axel Beckert reports bashism, usage of local, not Posix sh compatible and Lintian scan of man page finds 2 missed cases of - without using \- 2009.05.29 Fri checked if other projects have local problem, only used that in dphys-config dphys-config chaged all local VAR1=expr1 VAR2=expr2 to n*2 separate lines local VAR1; VAR1=expr; local VAR2; VAR2=expr2 dphys-config.1 .* at line begin problem, place an "any" before it and 2 cases of options beginning with - not escaped with \- but also more cases, not flagged, not options, but some - in commands in the end place an \ in front of every -, circumvent groff brokenness want all to be minus, and if hyphen desired anyway use \(hy this problem is in all dphys-* projects, is only an nuissance, not a bug lead others for the moment, fix whenever an project needs other fixes dphys-config also added wish for SYS_WORKDIR using mktemp as commented out 2nd variant, no test, as in SYS_* section, keep it simple 2009.06.05 Fri Axel Beckert tests and feedback suggested CONF_TMP_DIR for /var/tmp or /tmp, good idea, added it added also to dphys-config.example, while at it also added CONF_CONFNAME and updated man page with CONF_TMP_DIR suggested CONF_* option for PID or mktemp based workdir filename generation added also to dphys-config.example, and updated man page remove second variant of #SYS_WORKDIR=`mktemp ...` which requires user edit instead in code test for CONF_USE_MKTEMP=yes and then extend with mktemp 2009.06.27 Sat Axel Beckert tests and feedback (ready for release, but with patches) change mktemp switch to be automatic, use if present, no config option so now no need any more for an Debian patch to the option fixed in code (test with "which"), man page, and config example suggested set CONF_BASEURL to use example.net domain, reserved for non-use is better so, no possibly valid (if unlikely) non-domain host name consistency then changed man page example from .example.org to .example.net test for unset CONF_BASEURL and abort with explicit error message instead of aborting after many wget errors, and error msg only in servername allows Debian maintainer to drop his init.d and cron.d tests and these were only testing for presence of /etc/dphys-config anyway and so prevent him from installing an commented out example file init.d example also use > /dev/null 2>&1 like in cron.d example, consistant so that no error message, if not configured (possibly only used by users) also cron.d drop /usr/sbin like in init.d, also consistant updated man page with suggested variants and expanded explanations 2009.06.29 Mon just while last testing a new bug report came one example script uses echo -e , yet annother bashism also then Axel Beckert discovered an test -a/-o , in other example did search, also found test -a/-o in main dphys-config script 2009.07.02 Thu search for other echo -e usage in old (pre-)pkgtools Makefile, removed from makelocalsite, because bashism in older versions of swapfile, also removed, as not even used for anything many cases in dphys2, all versions, but that is woody-only, long dead so only active use remains this one case, change to get all correct no test host here or ETH, so no fix, change to #$/bin/bash, as only example checkbashisms also disallows echo -n but debian accepts this used often, various init.d, makelocalsite, dphys-swapfile, dphys2, dphys3 lots of work to change everywhere, if missing usually only visual effect correction either printf dependant (since when is this?) or allways visual so leave this the way it is, as standard practise, very old systems may fail test -a/-o also used in many projects, lots of work to change them all -a in d-c examp, dphys-kernel-packages (many), dphys-pkgtools, dphys2, dphys3 -o in dphys-config, d-c example, dphys-pkgtools, dphys2, dphys3 but dphys-config is only currently used stuff, only fix it here replaced [ cond -o cond ] with ( [ cond ] || [ cond ] ) 2+1 times replaced [ cond -a cond ] with ( [ cond ] && [ cond ] ) 2 times 2009.09.26 Sat after all bugfixes and changes, and my holiday and Axels done, new release testing "current" 2 months showed no problems, no new Debian bug reports updated FAQ, INSTALL, index.html.en (incl Debian Maintainer name change) copy to ../dphys-config-20090926, change that Makefile, made tar file of that remade ../dphys-config.tar.gz archive for current state 2010.01.06 Wed Axel Beckert reports new Lintian complains about 2 man page spellings one is according to Google used by 7.5% of writers, leave that the other is used by 2%, where leave/change threashold, 1% or 3% older historic language dispute case shown to be unter 0.1%, fix that used in multiple projects, but all others dead ones, only fixes here 2010.01.18 Mon Axel Beckert reports Bug, reported by Guerkan Senguen parsing wget output fails if LANG= ist set and not to =C is fundamental wget brokenness, no reliable tests on exitcode possible curl as replacement ist not commonly installed, no 2 code variants so fix will be to set LANG=C before calling wget or better, catch potential other bugs, set it at beginning, for all also requests DEBUG_* for keeping (last) wget calls output file 2010.01.21 Thu fix personal failled->failed spelling, as below 0.1% used variant used 8 times in dphys-config comments (2) and error messages (6) dont bother fix one use in site.example/local/sbin/dphys-config-x comment fix personal usefull->usefull spelling, 2% is under "common" 3% threshold dphys-config (1), dphys-config.1 (3), index.html.en (5) add/change LANG=C to/in main process environment, so wget also gets it reorganised set-e/PATH/LANG commenting to be one "setup" block add new DEBUG_* option, keep (last) wget calls output file wget -o option is actually not stderr, rename file to @wget.output 2010.02.16 Tue after all bugfixes and changes, and my holiday gone testing "current" 3.5 weeks showed no problems, no new bug reports updated FAQ, INSTALL, index.html.en (incl fixing some awkward HTML syntax) copy to ../dphys-config-20100216, change that Makefile, made tar file of that remade ../dphys-config.tar.gz archive for current state 2013.01.10 Thu Axel Beckert reports Bug in backtick preprocessing, Quoted once too many times as result spaces and options are considered part of command name, fails also reports that wget faillure warning keeps triggering hobbit system monitor would prefer it to just be an informational output also questions whether it is still maintained, or if he should take it over is still in productive use by me, so it is still maintained, stays here 2013.01.11 Fri Axel Beckert mails all the details and 4 diffs he used to fix it backtick preprocessing changed from SUBST="`"${TICK}"`" to SUBST="`${TICK}`" after-wget WARNINGs downgraded to NOTEs, as only transient net failures and if all 3 rounds fail it is will give an full FATAL error anyway also information about his interactive testing extension, sounds usefull mail discussion, what/howmuch of this to use, or what else instead also information about his hobbit direct calling stuff, rejected can not be added in my version, as no possibility of me testing it also discussion of adding testing suite, I have at present no time for such this would have to be something external, come from him as contribution possibly as separate programm/script, with its docs, all in subdirectory also reports potential interest of future rewrite in perl that would have to be an separate fork/replacement, as 100% new code 2013.03.01 Fri slightly improved 2 messages "config" to "list" and "config" to "file" and also 2 from "config list" to "list" and "config file list" to "file" the later of these actually is false output, as it is not the list ------ project status doing: todo: possible extensions: dphys-config/Makefile0000644000175500017550000000417010542756503013573 0ustar neilneil# http://neil.franklin.ch/Projects/dphys-config/Makefile # author Neil Franklin, last modification 2005.12.22 # This Makefile is copyright ETH Zuerich Physics Departement, # use under either modified/non-advertising BSD or GPL license # --- various site dependant user config variables # for creating an [-].tar.gz archive DIR = dphys-config # --- no user configurable stuff below here # /usr/local added for FreeBSD, because their ports end up in there PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin PREFIX = $(DESTDIR)/usr BINDIR = $(PREFIX)/bin LIBDIR = $(PREFIX)/lib/dphys-config SBINDIR = $(PREFIX)/sbin MAN1DIR = $(PREFIX)/share/man/man1 MAN7DIR = $(PREFIX)/share/man/man7 MAN8DIR = $(PREFIX)/share/man/man8 DOCDIR = $(PREFIX)/share/doc/dphys-config EXADIR = $(DOCDIR)/examples # --- code for acting out the various make targets all: @# man pages need making and deleting of compressed versions @gzip -9 -c dphys-config.1 > dphys-config.1.gz clean: @rm -f dphys-config.1.gz distclean: clean install: @# programs and man pages need installing to and deleting from system @mkdir -p $(BINDIR) @cp -p dphys-config $(BINDIR) @mkdir -p $(MAN1DIR) @cp -p dphys-config.1.gz $(MAN1DIR) @mkdir -p $(EXADIR) @cp -p dphys-config.example $(EXADIR) @cp -pr site.example $(EXADIR) @cp -p cron.d.example $(EXADIR) @cp -p init.d.example $(EXADIR) uninstall: @rm -f $(EXADIR)/init.d.example @rm -f $(EXADIR)/cron.d.example @rm -rf $(EXADIR)/site.example @rm -f $(EXADIR)/dphys-config.example @rmdir $(EXADIR) @rm -f $(MAN1DIR)/dphys-config.1.gz @rm -f $(BINDIR)/dphys-config # --- project management stuff .PHONY: tar tar: @# package this project into an .tar.gz for one nice download @echo packaging source and doc files into an .tar.gz ... @(cd ..; tar zcf $(DIR).tar.gz \ $(DIR)/FAQ $(DIR)/INSTALL $(DIR)/Logfile $(DIR)/Makefile \ $(DIR)/README $(DIR)/cron.d.example $(DIR)/dphys-config \ $(DIR)/dphys-config.1 $(DIR)/dphys-config.example \ $(DIR)/index.html.de $(DIR)/index.html.en \ $(DIR)/init.d.example $(DIR)/site.example ) dphys-config/README0000644000175500017550000000311110542756667013020 0ustar neilneilhttp://neil.franklin.ch/Projects/dphys-config/README author Neil Franklin, last modification 2006.12.22 This text (and all dphys-config) are copyright ETH Zuerich Physics Departement, use under either modified/non-advertising BSD or GPL license Introduction to dphys-config configuration file manager for Unix systems Aim This program is aimed at automatically installing/updating and removing of configuration files to our 100s of systems, driven by an simple file and place and script list. Preconditions This program should work on any Unix system which has wget installed. But has only been tested on our Debian Linux 3.1 (sarge) systems and FreeBSD 6.1. Tools This project has produced an script for fetching config files from an config web site, preprocessing them, installing them in the correct places and then triggering postinstall scripts. The same script can also remove config files not needed any more, after triggering preremove scripts. And an init.d script and cron job that run this script at boot and every night, so hosts stay updated. Code This project is fully open source. Documentation gets written together with the code. Everything I write is immediately available for download. Current version is what I am working on, if I write a bug you crash the next day. Older stable versions are archived as Milestones. State Working package, in productive use on over 100 machines. Installation There is a installation guide at: http://neil.franklin.ch/Projects/dphys-config/INSTALL Questions There is a FAQ file at: http://neil.franklin.ch/Projects/dphys-config/FAQ dphys-config/cron.d.example0000644000175500017550000000140511221427027014660 0ustar neilneil# /etc/cron.d/dphys-config - nightly trigger automatic config updates # authors dsbg and franklin, last modification 2009.06.27 # copyright ETH Zuerich Physics Departement # use under either modified/non-advertising BSD or GPL license SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # daily early morning autoupgrade of config files of our systems # after 03:00, when users are assumed to be least active # before 04:00 so that finished long before dphys-admin starts # by 1 hour, because random sleep 0..59min to spread load on pkg server # no direct output, so no mailed error message if not configured # errors will still be recorded to syslog, enough, as not run-critical 0 3 * * * root dphys-config cron > /dev/null 2>&1 dphys-config/dphys-config0000755000175500017550000007506012114160005014440 0ustar neilneil#!/bin/sh # /usr/bin/dphys-config - install/update config files and trigger commands # author Neil Franklin, last modification 2013.03.01 # copyright ETH Zuerich Physics Departement, # use under either modified/non-advertising BSD or GPL license # this script is intended to be run as an normal user ### ------ configuration for this site # first CONF_* various site or user dependant user config variables # then DEBUG_* various debugging settings # last SYS_* various system internal values # some of these are overridable by command line options # --- CONF_* various site or subnet dependant user config variables # base directory for temporary files # some prefer /var/tmp for size and safety, works everywhere # some prefer /tmp for speed or boot-time auto-delete CONF_TMP_DIR=/var/tmp # base directory for config files on server # set to something that will produce an error message without site config CONF_BASEURL=http://not-configured-server.example.net/not/configured/directory # configuration name to use, usually host name, unless chroot or vhost or test CONF_CONFNAME=`hostname` # only process lines matching this grep regexp, default do all CONF_LINEFILTER=".*" # log what we have done CONF_LOG_DONE=yes # --- DEBUG_*, various debugging settings # these can be set to "yes" by -D option, followed by name without DEBUG_ # such as like this: dphys-config -D PRINT_STEP ... # set this to sleep after displaying each steps header #DEBUG_SLEEP=yes # set this to output debug state info after each step #DEBUG_PRINT_STEP=yes # set this to wait after each debug state info #DEBUG_WAIT_STEP=yes # set this to have debug dry runs install not in /, avoid killing system #DEBUG_INSTALL_BASE=${CONF_TMP_DIR}/dphys-config-debug-install # set this to leave temporary directories undeleted after working #DEBUG_LEAVE_TEMPDIRS=yes # set this to leave wget output file that was parsed # this requires also DEBUG_LEAVE_TEMPDIRS, else file gone with directories #DEBUG_LEAVE_WGET_OUTPUT=yes # --- SYS_*, various system internal values # name of config file list file on server SYS_CONFLIST_NAME=dphys-config.list # where we want to do all the download/merge/diff-test stuff # this must be a directory that root can access (not a root-squash NFS mount) SYS_WORKDIR=${CONF_TMP_DIR}/dphys-config-$$-work ### ------ actual implementation from here on # no user settings any more below this point # --- get ready to work # report as many called program errors as possible set -e # sanitise this place, else some commands may fail # must be before any commands are executed, incl config/input processing # /usr/local added for FreeBSD, because their ports end up in there PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin export PATH # also sanitise this, else wget output parsing fails on some systems LANG=C export LANG # --- tidy up some commands, make systematic # stuff that goes wrong, not expected by user, not in data output, use >&2 # so also with $0 in case this script was called by an other script # something within the system that user does not expect, give up CMD_FATAL="echo $0: FATAL:" # something from users input, user will correct this and continue CMD_ERROR="echo $0: ERROR:" # something we can continue with, but may be wrong, and user may not suspect it CMD_WARNING="echo $0: WARNING:" # something most likely not wrong, but tell user for the odd case it is wrong CMD_NOTE="echo $0: NOTE:" # normal stuff users expect, so to stdout as normal output, no $0, no marking CMD_INFO="echo" # stuff users asked for, so add to stdout as normal output, no $0, but mark it CMD_DEBUG="echo DEBUG:" # and also put out some permanent messages, in case running as cron/init.d job BASENAME="`basename "$0"`" # something within the system that user does not expect, give up CMD_LOG_FATAL="logger -t ${BASENAME} -p user.error FATAL:" # something from users input, user can possibly correct this and continue CMD_LOG_ERROR="logger -t ${BASENAME} -p user.error ERROR:" # something we can continue with, but may be wrong, and user may not suspect it CMD_LOG_WARNING="logger -t ${BASENAME} -p user.warning WARNING:" # something most likely not wrong, but tell user for the odd case it is wrong CMD_LOG_NOTE="logger -t ${BASENAME} -p user.notice NOTE:" # normal stuff users expect, so no marking CMD_LOG_INFO="logger -t ${BASENAME} -p user.info" # stuff users asked for, but mark it as special CMD_LOG_DEBUG="logger -t ${BASENAME} -p user.debug DEBUG:" # other stuff we may want to use CMD_SLEEP="sleep 2" CMD_WAIT="read -p ---DEBUG-wait-after-step--- dummy" # set config option controllable stuff CMD_INFO_PRINT="${CMD_INFO}" CMD_VERBOSE_PRINT=true # set debug option controllable stuff if [ "${DEBUG_SLEEP}" = yes ] ; then CMD_DEBUG_SLEEP="${CMD_SLEEP}" else CMD_DEBUG_SLEEP=true fi if [ "${DEBUG_PRINT_STEP}" = yes ] ; then CMD_DEBUG_PRINT="${CMD_DEBUG}" else CMD_DEBUG_PRINT=true fi if [ "${DEBUG_WAIT_STEP}" = yes ] ; then CMD_DEBUG_WAIT="${CMD_WAIT}" else CMD_DEBUG_WAIT=true fi # --- config file stuff # what we are, program and package name NAME=dphys-config PNAME=dphys-config # check user config file(s), let user override settings if [ -e /etc/"${PNAME}" ] ; then . /etc/"${PNAME}" fi if [ -e ~/."${PNAME}" ] ; then . ~/."${PNAME}" fi # --- control variable output # set config option controllable stuff if [ "${CONF_LOG_DONE}" = yes ] ; then CMD_LOG_IF_DONE="${CMD_LOG_INFO}" else CMD_LOG_IF_DONE=true fi # --- parse command line # so long next parameter is a set of options (= begins with an - character) while [ "`echo "$1" | cut -c 1`" = - ] ; do # extract options from parameter (cut off the "-") OPTS="`echo "$1" | cut -c 2-`" shift 1 # so long still unprocessed option characters while [ "${OPTS}" != "" ] ; do # first option to process OPT="`echo "${OPTS}" | cut -c 1`" # and rest of options for later OPTS="`echo "${OPTS}" | cut -c 2-`" case "${OPT}" in c) # configname: use this set of files config instead of hostname set CONF_CONFNAME="$1" shift 1 ;; f) # filter: only process lines matching this grep regexp CONF_LINEFILTER="$1" shift 1 ;; q) # quiet: don't inform user what we are doing CMD_INFO_PRINT=true ;; v) # verbose: detailed inform user what we are doing CMD_VERBOSE_PRINT="${CMD_INFO}" ;; D) # Debug: set an debug option to yes eval "DEBUG_$1"=yes if [ "DEBUG_$1" = DEBUG_SLEEP ] ; then CMD_DEBUG_SLEEP="${CMD_SLEEP}" fi if [ "DEBUG_$1" = DEBUG_PRINT_STEP ] ; then CMD_DEBUG_PRINT="${CMD_DEBUG}" fi if [ "DEBUG_$1" = DEBUG_WAIT_STEP ] ; then CMD_DEBUG_WAIT="${CMD_WAIT}" fi shift 1 ;; h) # help: give out help how this script can be used cat << END-HELP-TEXT Usage is: $0 [options] options: -c configname: use this set of config files instead of hostname set -f filter filter: only process lines matching this grep regexp -q quiet: don't give user an running report of what we are doing -v verbose: give user detailed running report -D Debug: activate an debug option, see source for operation -h help: output this text, and then abort operation mode none or "none" or "init" (run directly) or "cron" (delay 0..59min) END-HELP-TEXT exit 0 ;; *) # not one of our recognized options ${CMD_ERROR} "unknown option: ${OPT}" >&2 ${CMD_INFO} >&2 # call self with -h to display help "$0" -h >&2 exit 1 ;; esac done done # do not use elif [ "" = "" -o "" = "" ] ; as some shells test fails on this if [ "$1" = "" ] ; then MODE=none elif ( [ "$1" = cron ] || [ "$1" = init ] ) ; then MODE="$1" else ${CMD_ERROR} "unknown mode (or even multiple) given: $1" >&2 ${CMD_INFO} >&2 # call self with -h to display help "$0" -h >&2 exit 1 fi ${CMD_DEBUG_PRINT} "options parsed" ${CMD_DEBUG_WAIT} # --- spread config file server load # avoid load peak on the file server from over 100 machines at same time # delay cron jobs of various machines up to 1 hour, do not affect init jobs # therefore we random wait for 0..3599 seconds before working if [ "${MODE}" = cron ] ; then DELAY=`perl -e 'print int(rand(3600)), "\n"'` ${CMD_INFO} "waiting ${DELAY}s (0-3599s) for our time slot ..." sleep "${DELAY}" ${CMD_INFO} "waiting done, continuing ..." fi # --- wget handle unreliable network, DNS faillures or DNS not reachable broken_net_wget_or_die () { # our many thanks to the net admins for their unreliable net # and the resulting unreachable DNS, for client->host and host client auth # with 150 hosts times 30 files, is produces up to 5 failed hosts per run # later this subroutine also got used to "fix" the missing file: URLs in wget local URL URL="$1" local DIR DIR="$2" ${CMD_DEBUG_PRINT} "URL=${URL} DIR=${DIR}" ${CMD_DEBUG_WAIT} # support for file: URLs which wget does not know about if [ "`echo "${URL}" | cut -c 1-5`" = "file:" ] ; then local FILE FILE="`echo "${URL}" | cut -c 6-`" # URL ends in /, this is directory existance test, generate fake index.html if [ "`echo "${FILE}" | rev | cut -c 1`" = "/" ] ; then # we later only test for file existance of index.html, so non-HTML is OK (cd "${DIR}"; ls -al "${FILE}" > index.html 2> /dev/null) else local FILEBASE FILEBASE="`basename "${FILE}"`" (cd "${DIR}"; cp -p "${FILE}" "${FILEBASE}") fi return 0 fi # check if we can work if ! which wget > /dev/null ; then ${CMD_FATAL} "failed to find wget, can not work, aborting ..." >&2 ${CMD_LOG_FATAL} "failed to find wget, can not work, aborting ..." exit 1 fi local TRY for TRY in 1 2 3 ; do # wget gives back 1 for both DNS failure (bad) and simple 404 (expected) # also we need to expect 403 if we managed to reach the server # but it then failed to resolve our IP address # and also for any other access violation problems # such as admin giving wrong file permissions # better only continue if we got 200 (got file) or 404 (no file) # this fails safe, can never break config files # uses an temp file for wget output, split on that to see which happened local WGET_OUTPUT WGET_OUTPUT="${SYS_WORKDIR}/@wget.output" # -N so we do not re-fetch unchanged files, important when large files # -N and -O do not like each other, so use an (cd ; wget) (cd "${DIR}"; wget -N -o "${WGET_OUTPUT}" "${URL}" || true) local DNS_STAT DNS_STAT="`grep '^Resolving .*... failed: Host not found.$' \ "${WGET_OUTPUT}" | tr -d ' '`" # the 6th field is the numeric HTTP return code # do not depend on 7th field, textual code, can vary depending on server local HTTP_STAT HTTP_STAT="`grep '^HTTP request sent, awaiting response... ' \ "${WGET_OUTPUT}" | tail -n 1 | cut -f 6 -d ' '`" if [ "${DEBUG_LEAVE_WGET_OUTPUT}" != yes ] ; then # offer to leave this to investigate bugs rm "${WGET_OUTPUT}" fi ${CMD_DEBUG_PRINT} "DNS_STAT=${DNS_STAT} HTTP_STAT=${HTTP_STAT}" # 2 similar "elif" as some shells built-in [ command fail on -o operator if [ "${DNS_STAT}" != "" ] ; then # having these as WARNING triggers one users hobbit system monitor # is unnecessary for what are just transient network errors, use NOTE # especially as all 3 attemps failing will fall into below FATAL ${CMD_NOTE} "failed try ${TRY} to resolve server for URL ${URL}" >&2 ${CMD_LOG_NOTE} "failed try ${TRY} to resolve server for URL ${URL}" elif ( [ "${HTTP_STAT}" = 200 ] || [ "${HTTP_STAT}" = 404 ] ) ; then # we managed to get a file, or there is no file, both are OK for us return 0 else # same downgrade from WARNING to NOTE as above ${CMD_NOTE} "failed try ${TRY} to retrieve file from" \ "URL ${URL}, with HTTP status ${HTTP_STAT}" >&2 ${CMD_LOG_NOTE} "failed try ${TRY} to retrieve file from" \ "URL ${URL}, with HTTP status ${HTTP_STAT}" fi done ${CMD_FATAL} "failed entirely to retrieve file from URL ${URL}," \ "with HTTP status ${HTTP_STAT}, aborting ..." >&2 ${CMD_LOG_FATAL} "failed entirely to retrieve file from URL ${URL}," \ "with HTTP status ${HTTP_STAT}, aborting ..." exit 1 } # --- check for neccessary configuration done by user ${CMD_INFO_PRINT} "checking configuration for user setting CONF_BASEURL ..." ${CMD_DEBUG_SLEEP} if `echo "${CONF_BASEURL}" | \ grep -q 'http://not-configured-server.example.net/'` ; then # CONF_BASEURL still has not configured setting, so we can not work with it ${CMD_ERROR} "user config variable CONF_BASEURL has not been set to an" \ "valid base directory for config files on your server, aborting ..." >&2 ${CMD_LOG_ERROR} "user config variable CONF_BASEURL has not been set to an" \ "valid base directory for config files on your server, aborting ..." exit 1 fi # --- check for config file server ${CMD_INFO_PRINT} "checking file server for configuration ${CONF_CONFNAME} ..." ${CMD_DEBUG_SLEEP} # use mktemp if users system has it installed # some systems need $$ PIDs as no utility is present, works everywhere # others can use mktemp, preferable as this prevents race conditions # in this case just add mktemp on to end of name with $$ in it, use both if [ "`which mktemp 2> /dev/null`" != "" ]; then SYS_WORKDIR="`mktemp -d "${SYS_WORKDIR}.XXXXXXXXXX"`" fi # make work space for this and other temporary files mkdir -p "${SYS_WORKDIR}" # prevent access to just-wget-ed temporary files with wrong permissions chmod 700 "${SYS_WORKDIR}" # check for valid server URL, read directory with all hosts in it rm -f "${SYS_WORKDIR}/index.html" broken_net_wget_or_die "${CONF_BASEURL}/" "${SYS_WORKDIR}" # do not rely on the contents of index.html being actual HTML # can be ls -al output in case of file:/ URLs # so only use this file for existance test, no parsing its content if [ ! -f "${SYS_WORKDIR}/index.html" ] ; then ${CMD_FATAL} "failed to find server dir ${CONF_BASEURL}, aborting ..." >&2 ${CMD_LOG_FATAL} "failed to find server dir ${CONF_BASEURL}, aborting ..." exit 1 fi # server subdirectory for this hosts configuration CONFHOST_URL="${CONF_BASEURL}/${CONF_CONFNAME}" # check for valid host name, read directory of this host rm -f "${SYS_WORKDIR}/index.html" broken_net_wget_or_die "${CONFHOST_URL}/" "${SYS_WORKDIR}" if [ ! -f "${SYS_WORKDIR}/index.html" ] ; then ${CMD_FATAL} "failed to find host dir for ${CONFHOST_URL}, aborting ..." >&2 ${CMD_LOG_FATAL} "failed to find host dir for ${CONFHOST_URL}, aborting ..." exit 1 fi ${CMD_DEBUG_PRINT} "`ls -al "${SYS_WORKDIR}/index.html"`" ${CMD_DEBUG_WAIT} # --- fetch config file from server to spool and preprocess it fetch_and_preprocess_config_file () { local URL URL="$1" local WORK WORK="$2" ${CMD_DEBUG_PRINT} "URL=${URL} WORK=${WORK}" ${CMD_DEBUG_WAIT} # ensure first that work dir is there, in case config file in an new subdir local DIR DIR="`dirname "${WORK}"`" mkdir -p "${DIR}" # get the file broken_net_wget_or_die "${URL}" "${DIR}" if [ ! -f "${WORK}" ] ; then # config file not fetched, so we can not work on it ${CMD_ERROR} "no config file ${URL} fetched to ${WORK}" >&2 ${CMD_LOG_ERROR} "no config file ${URL} fetched to ${WORK}" exit 1 fi ${CMD_DEBUG_PRINT} "`ls -al "${WORK}"`" ${CMD_DEBUG_WAIT} # preprocessor stuff # header calls for preprocessing, with syntax similar to the #! shell trigger local HEAD HEAD="`head -n 1 "${WORK}"`" if `echo "${HEAD}" | grep -q '^#@dphys-config-preprocess'` ; then # use rest of file, purged of header, which is never part of output sed -ne '2,$p' "${WORK}" > "${WORK}.temp" mv "${WORK}.temp" "${WORK}" # what preprocessing actions the user wants, and in which row to run them # extract from HEAD format: #@dphys-config-preprocess [preprocessor...] # add an space after "${HEAD}" to circumvent cut -f 2- -d ' ' brokenness # if no preprocessor was listed by user, and so possibly no space in line local PREPROCS PREPROCS="`echo "${HEAD} " | cut -f 2- -d ' ' | tr -c -d 'a-z '`" ${CMD_DEBUG_PRINT} "HEAD=${HEAD} PREPROCS=${PREPROCS}" # no "${PREPROCS}", else intervening and trailing spaces end up in PREPROC # and that would then really confuse case # split junk will simply feed nonsense to case, and get caught by *) local PREPROC for PREPROC in ${PREPROCS} ; do case "${PREPROC}" in backtick) # replace backtick expressions with stdout generated by running them ${CMD_VERBOSE_PRINT} "preprocessing for backtick ..." ${CMD_DEBUG_SLEEP} local LINE # IFS= to avoid read doing separator processing (mangles spaces) # and -r to prevent \ interpretation (mangles line contents) cat "${WORK}" | while IFS= read -r LINE ; do # syntax taken from the shell backtick, which is also used here # may have multiple substitutions on one line, so use while loop while echo "${LINE}" | grep -q '`' ; do # the '\` here need the \ because of the `` subshell local FRONT FRONT="`echo "${LINE}" | cut -f 1 -d '\`' `" local TICK TICK="`echo "${LINE}" | cut -f 2 -d '\`' `" local REST REST="`echo "${LINE}" | cut -f 3- -d '\`' `" # prevent non zero return from user given command from killing us set +e local SUBST SUBST="`${TICK}`" RETVAL="$?" set -e if [ "${RETVAL}" != 0 ] ; then ${CMD_WARNING} "backtick returned non zero: ${RETVAL}" >&2 ${CMD_LOG_WARNING} "backtick returned non zero: ${RETVAL}" fi LINE="${FRONT}${SUBST}${REST}" done echo "${LINE}" >> "${WORK}.temp" done mv "${WORK}.temp" "${WORK}" ;; if) # if condition met, leave rest of line, else delete it ${CMD_VERBOSE_PRINT} "preprocessing for if ..." ${CMD_DEBUG_SLEEP} local LINE cat "${WORK}" | while IFS= read -r LINE ; do # extract from LINE format: #@if condition ; line-to-leave if echo "${LINE}" | grep -q '^#@if ' ; then # end of command part with ; analog to shell if/while/for if ! echo "${LINE}" | grep -q ';' ; then ${CMD_ERROR} "#@if config line \"${LINE}\" has no \";\"" >&2 ${CMD_LOG_ERROR} "#@if config line \"${LINE}\" has no \";\"" exit 1 fi local COND COND="`echo "${LINE}" | cut -f 1 -d ';'`" LINE="`echo "${LINE}" | cut -f 2- -d ';'`" # purge command, which is not part of condition COND="`echo "${COND}" | cut -f 2- -d ' '`" # strip leading spaces after ; from line while [ "`echo "${LINE}" | cut -c 1`" = " " ] ; do LINE="`echo "${LINE}" | cut -c 2-`" done set +e if sh -c "${COND}" ; then echo "${LINE}" >> "${WORK}.temp" fi set -e else echo "${LINE}" >> "${WORK}.temp" fi done mv "${WORK}.temp" "${WORK}" ;; include) # replace line with contents of section file named on rest of line ${CMD_VERBOSE_PRINT} "preprocessing for include ..." ${CMD_DEBUG_SLEEP} local LINE cat "${WORK}" | while IFS= read -r LINE ; do if echo "${LINE}" | grep -q '^#@include ' ; then local SECTION SECTION="`echo "${LINE}" | cut -f 2 -d ' '`" broken_net_wget_or_die "${URL}.${SECTION}" "${DIR}" if [ -f "${WORK}.${SECTION}" ] ; then ${CMD_DEBUG_PRINT} "`ls -al "${WORK}.${SECTION}"`" fi ${CMD_DEBUG_WAIT} if [ -f "${WORK}.${SECTION}" ] ; then cat "${WORK}.${SECTION}" >> "${WORK}.temp" #else # NOTE: this output is more annoying than useful, disable it #${CMD_NOTE} "no config file section ${URL}.${SECTION} ..." >&2 #${CMD_LOG_NOTE} "no config file section ${URL}.${SECTION} ..." fi else echo "${LINE}" >> "${WORK}.temp" fi done mv "${WORK}.temp" "${WORK}" ;; *) ${CMD_WARNING} "unknown preprocessor \"${PREPROC}\", " \ "ignoring it ..." >&2 ${CMD_LOG_WARNING} "unknown preprocessor \"${PREPROC}\"," \ "ignoring it ..." ;; esac ${CMD_DEBUG_PRINT} "`ls -al "${WORK}"`" ${CMD_DEBUG_WAIT} done fi return 0 } # --- download config file list ${CMD_INFO_PRINT} "downloading configuration list ${SYS_CONFLIST_NAME} ..." ${CMD_DEBUG_SLEEP} # file list url on server CONFLIST_URL="${CONFHOST_URL}/${SYS_CONFLIST_NAME}" # temp file here on host CONFLIST="${SYS_WORKDIR}/${SYS_CONFLIST_NAME}" # get the config file list, it lists what config files are to be processed fetch_and_preprocess_config_file "${CONFLIST_URL}" "${CONFLIST}" # file here on host if [ "`whoami`" != root ] ; then # being run by an user for personal files, not as root for system # FreeBSD sh fails to substitute if the ~ is inside the "" CONFLIST_PLACE=~/."${SYS_CONFLIST_NAME}" else CONFLIST_PLACE="/etc/${SYS_CONFLIST_NAME}" fi # need to prevent diff below from complaining about missing previous file # if file nonexistant generate, empty, hopefully this will not break anything if [ ! -e "${CONFLIST_PLACE}" ] ; then ${CMD_INFO_PRINT} "will be installing new list at ${CONFLIST_PLACE}" ${CMD_DEBUG_SLEEP} # empty file ensures it is different (new one from server is not empty) touch "${CONFLIST_PLACE}" fi # only if file has changed do we do anything # diff is missnamed, successful finding difference regarded as faillure # that makes ist an "equal" test, not an "difference" test :-) # so ! in here despite wanting to do the if stuff in case of difference if ! diff "${CONFLIST_PLACE}" "${CONFLIST}" > /dev/null ; then ${CMD_INFO_PRINT} "updating old or installing new list" \ "${SYS_CONFLIST_NAME} as ${CONFLIST_PLACE} ..." ${CMD_DEBUG_SLEEP} cp -pf "${CONFLIST}" "${CONFLIST_PLACE}" ${CMD_DEBUG_PRINT} "`ls -al "${CONFLIST_PLACE}"`" ${CMD_DEBUG_WAIT} fi # --- process each config file ${CMD_INFO_PRINT} "processing individual config files from the list ..." ${CMD_DEBUG_SLEEP} # cut get rid of comments and grep empty lines (may be emptied comment lines) # and allow user to select/filter subset of lines to be processed # IFS= to avoid read doing separator processing (mangles spaces) # and -r to prevent \ interpretation (mangles line contents) cut -f 1 -d '#' "${CONFLIST_PLACE}" | grep -v '^ *$' | \ grep "${CONF_LINEFILTER}" | while IFS= read -r LINE ; do ${CMD_DEBUG_PRINT} "LINE=${LINE}" ${CMD_DEBUG_WAIT} # extract from LINE format: file-name:place-on-target[:command-to-trigger] if ! echo "${LINE}" | grep -q ':' ; then ${CMD_ERROR} "config line \"${LINE}\" has no \":\" to split on" >&2 ${CMD_LOG_ERROR} "config line \"${LINE}\" has no \":\" to split on" exit 1 fi # file-name: work on this file # if this is set to -, then remove an now unused config file CONFFILE_NAME="`echo "${LINE}" | cut -f 1 -d ':'`" # needs to be set, but may be unset if an : is right at begin of line if [ "`echo "${CONFFILE_NAME}" | tr -d ' '`" = "" ] ; then ${CMD_ERROR} "config line \"${LINE}\" has no file name before \":\"" >&2 ${CMD_LOG_ERROR} "config line \"${LINE}\" has no file name before \":\"" exit 1 fi # place-on-target: put result here CONFFILE_PLACE="`echo "${LINE}" | cut -f 2 -d ':'`" # needs to be set, but may be unset if mothing between the first 2 : if [ "`echo "${CONFFILE_PLACE}" | tr -d ' '`" = "" ] ; then ${CMD_ERROR} "config line \"${LINE}\" has no config place" \ "between first and second \":\"" >&2 ${CMD_LOG_ERROR} "config line \"${LINE}\" has no config place" \ "between first and second \":\"" exit 1 fi # command-to-trigger: run this facultatively # run post installing (or pre removing) an config file # if no second : on line or nothing after it this is automatically blank # if more than 2 : on line include the rest of them into this with 3- CMDTRIG="`echo "${LINE}" | cut -f 3- -d ':'`" ${CMD_DEBUG_PRINT} "CONFFILE_NAME=${CONFFILE_NAME}" \ "CONFFILE_PLACE=${CONFFILE_PLACE} CMDTRIG=${CMDTRIG}" ${CMD_DEBUG_WAIT} ${CMD_VERBOSE_PRINT} "processing config file ${CONFFILE_NAME} ..." ${CMD_DEBUG_SLEEP} # final file place here on host stuff # ensure that it is an absolute filename if [ "`echo "${CONFFILE_PLACE}" | cut -c 1`" != / ] ; then ${CMD_WARNING} "correcting non-absolute \"${CONFFILE_PLACE}\", add /" >&2 ${CMD_LOG_WARNING} "correcting non-absolute \"${CONFFILE_PLACE}\", add /" fi # allow debug runs as normal non-root user, and without overwriting stuff CONFFILE_PLACE="${DEBUG_INSTALL_BASE}${CONFFILE_PLACE}" # test for only directory name (ends in /), add base file name to it if [ "`echo "${CONFFILE_PLACE}" | rev | cut -c 1`" = / ] ; then # user gave directory, add filename to it # add no / after "${CONFFILE_PLACE}" as it is already contained in it # explicit user request that no // is displayed in resulting names CONFFILE_PLACE="${CONFFILE_PLACE}${CONFFILE_NAME}" else # user gave no directory, but check for forgotten / if [ -d "${CONFFILE_PLACE}" ] ; then ${CMD_WARNING} "place without / at end, but is existing directory" >&2 ${CMD_LOG_WARNING} "place without / at end, but is existing directory" CONFFILE_PLACE="${CONFFILE_PLACE}/${CONFFILE_NAME}" fi fi # expand an {} in commands to trigger to the full name of the file installed # syntax in copied from the find -exec ; command if echo "${CMDTRIG}" | grep -q '\{\}' ; then # hide slashes in path, to not confuse sed s command SED_CONFFILE_PLACE="`echo "${CONFFILE_PLACE}" | sed -e '/\//s@@\\\/@g'`" CMDTRIG="`echo "${CMDTRIG}" | sed -e "/{}/s//${SED_CONFFILE_PLACE}/g"`" fi if [ "${CONFFILE_NAME}" != - ] ; then # install an config file # file url on server CONFFILE_URL="${CONFHOST_URL}/${CONFFILE_NAME}" # temp file here on host CONFFILE="${SYS_WORKDIR}/${CONFFILE_NAME}" # get the actual config file to be processed fetch_and_preprocess_config_file "${CONFFILE_URL}" "${CONFFILE}" # ensure first that target dir is there, case new config file in new dir mkdir -p "`dirname "${CONFFILE_PLACE}"`" # prevent diff complaining fix, as for config list if [ ! -e "${CONFFILE_PLACE}" ] ; then ${CMD_INFO_PRINT} "will be installing new file at" \ "${CONFFILE_PLACE}" ${CMD_DEBUG_SLEEP} # empty file ensures it is different (new one from server is not empty) touch "${CONFFILE_PLACE}" fi # only if file has changed do we do anything, as for config list if ! diff "${CONFFILE_PLACE}" "${CONFFILE}" > /dev/null ; then ${CMD_INFO_PRINT} "updating old or installing new file" \ "${CONFFILE_NAME} as ${CONFFILE_PLACE} ..." ${CMD_DEBUG_SLEEP} cp -pf "${CONFFILE}" "${CONFFILE_PLACE}" ${CMD_DEBUG_PRINT} "`ls -al "${CONFFILE_PLACE}"`" ${CMD_DEBUG_WAIT} # run the facultative postinstall command trigger stuff if [ "`echo "${CMDTRIG}" | tr -d ' '`" != "" ] ; then ${CMD_INFO_PRINT} "triggering postinstall command \"${CMDTRIG}\" ..." ${CMD_DEBUG_SLEEP} # prevent non zero return from user given command from killing us set +e sh -c "${CMDTRIG}" RETVAL="$?" set -e if [ "${RETVAL}" != 0 ] ; then ${CMD_WARNING} "command returned non zero: ${RETVAL}" >&2 ${CMD_LOG_WARNING} "command returned non zero: ${RETVAL}" fi ${CMD_DEBUG_PRINT} "`ls -al "${CONFFILE_PLACE}"`" ${CMD_DEBUG_WAIT} fi fi else # remove an config file # only if file still exists do we do anything if [ -e "${CONFFILE_PLACE}" ] ; then ${CMD_INFO_PRINT} "removing old config file ${CONFFILE_PLACE} ..." ${CMD_DEBUG_SLEEP} # test for only directory name (ends in /), possibly dangerous leftover if [ "`echo "${CONFFILE_PLACE}" | rev | cut -c 1`" = "/" ] ; then ${CMD_WARNING} "would remove entire directory ${CONFFILE_PLACE}," \ "may be partially edited list file entry, DANGEROUS, leaving it," \ "add the files name after the / to delete an single file," \ "remove / after dir name to really delete entire directory" >&2 ${CMD_LOG_WARNING} "would remove entire directory ${CONFFILE_PLACE}," \ "may be partially edited list file entry, DANGEROUS, leaving it," \ "add the files name after the / to delete an single file," \ "remove / after dir name to really delete entire directory" else # run the facultative preremove command trigger stuff if [ "`echo "${CMDTRIG}" | tr -d ' '`" != "" ] ; then ${CMD_INFO_PRINT} "triggering preremove command \"${CMDTRIG}\" ..." ${CMD_DEBUG_SLEEP} set +e sh -c "${CMDTRIG}" RETVAL="$?" set -e if [ "${RETVAL}" != 0 ] ; then ${CMD_WARNING} "command returned non zero: ${RETVAL}" >&2 ${CMD_LOG_WARNING} "command returned non zero: ${RETVAL}" fi fi ${CMD_INFO_PRINT} "removing config file ${CONFFILE_PLACE} ..." ${CMD_DEBUG_SLEEP} ${CMD_DEBUG_PRINT} "`ls -ald "${CONFFILE_PLACE}"`" ${CMD_DEBUG_WAIT} rm -rf "${CONFFILE_PLACE}" fi fi fi done # --- finish off ${CMD_INFO_PRINT} "tidying up from working ..." ${CMD_DEBUG_SLEEP} ${CMD_DEBUG_PRINT} "+++ begin workdirectory listing +++" if [ "${DEBUG_PRINT_STEP}" = yes ] ; then ls -al "${SYS_WORKDIR}" 2> /dev/null fi ${CMD_DEBUG_PRINT} "+++ end workdirectory listing +++" ${CMD_DEBUG_WAIT} # remove temporary directory and its contents, to save space # must be after debug printout if [ "${DEBUG_LEAVE_TEMPDIRS}" != yes ] ; then # but offer to leave this to investigate bugs rm -rf "${SYS_WORKDIR}" fi ${CMD_LOG_IF_DONE} "has updated/installed/removed config files" exit 0 dphys-config/dphys-config.10000644000175500017550000004640411326077700014611 0ustar neilneil.\" /usr/share/man/man1/dphys\-config.1(.gz) .\" author Neil Franklin, last modification 2010.01.21 .\" copyright ETH Zuerich Physics Departement .\" use under either modified/non\-advertising BSD or GPL license .\" all appearances of an minus/options/wordseparators are written as \- .\" avoid groff brokenness, which else makes U+2010 instead of U+002D .TH DPHYS\-CONFIG 1 "2010.01.21" "D\-PHYS Configuration Tools" .SH NAME dphys\-config \- daily auto\-install/update and/or remove config files .SH SYNOPSIS .B dphys\-config [\fB\-f\fP \fIfilter\fP] [\fB\-cqvD\fP] .PP .B dphys\-config \fB\-h\fP .SH DESCRIPTION dphys\-config installs/updates and/or removes config files. It also triggers commands after an new/updated config file is available or before an existing config file will disappear. It can be run by hand, from cron and/or from init.d. .PP Get an list of config files from an configuration server. For each file in the list retrieve that file from the same server, and only install it if it is new or changed relative to what is already here. If a file is newly installed (or changed) then run an postinstall script, which may trigger actions which are wanted to process the new config (such as inserting data from an config file into an database). Also remove unwanted files. If doing so first run an preremove script to tidy up stuff. .PP This is part of the D\-PHYS (ETH Zuerich, Departement of Physics) automatic system operation and maintenance setup. .SH OPTIONS .TP .B \-c configname: Use this set of config files instead of hostname set. Useful for chroot or vhost installs, or for tests. .TP .B \-f \ filter filter: Only process lines which match the filter spec. .TP .B \-q quiet: Don't produce an running report of activities. .TP .B \-v verbose: Give large volume output, where sensible. .TP .B \-D Debug: Activate an debug option. See source for how to use this. .TP .B \-h help: Output help text, and then abort operation. .SH CONFIG The config files \fI/etc/dphys\-config\fP (sitewide) and \fI~/.dphys\-config\fP (personal) allow the admin and users to set up the working environment for \fBdphys\-config\fP. .PP These config files are sh script fragments full of assignments, which are sourced, in above row, later config files assignments overriding earlier ones. Standard sh syntax rules apply. Assignments are: .TP .B CONF_TMP_DIR Sets the base directory in which all temporary files are stored. It defaults to \fI/var/tmp\fP (for enough size and safe operation). Some users may like to use \fI/tmp\fP for higher speed (tmpfs) or automatic deletion at boot time. Standard sh syntax rules apply. Assignments are: .TP .B CONF_BASEURL Sets the base URL to which all */\fI\fP/\fI\fP combinations are added when \fBwget\fP\-ing config files. This can be an \fIhttp:\fP or \fIftp:\fP or whatever other type of URL which \fBwget\fP understands and can fetch an file from. Additionally it can be an \fIfile:\fP (this may be from an NFS server) URL, in which case wget is bypassed and the files fetched directly using \fBcp\fP. It defaults to the error message generating and aborting invalid setting of \fIhttp://not\-configured\-server.example.net/not/configured/directory\fP, as there is no sensible default possible. You must set this to where ever your config files should be taken from. .TP .B CONF_CONFNAME Selects the name for which set of configuration files shall be used for this host. Defaults to \fI`hostname`\fP. .TP .B CONF_LINEFILTER Sets an regexp which selects which lines from the config file list are processed. Defaults to \fI.*\fP (all). .TP .B CONF_LOG_DONE Log to syslog that dphys\-config has run. Good to see if cron and/or init.d have done their job. Defaults to \fIyes\fP. .PP The config file list \fIdphys\-config.list\fP, which is found via above settings, and is downloaded to \fI/etc/dphys\-config.list\fP or \fI~/.dphys\-config.list\fP, then allows the admin to list what config files are to be fetched and installed/updated or removed, and what scripts to run for them. These can be each given for the entire site (= all hosts) and/or group and/or each host, or even merged from site+group+host subsections. .SH FILES .TP .B /etc/dphys\-config site admin config .TP .B ~/.dphys\-config users personal config .TP .B /etc/dphys\-config.list roots config file list gets stored here .TP .B ~/.dphys\-config.list users config file list gets stored here .TP .B $CONF_BASEURL/`hostname`/dphys\-config.list site\-global (all hosts) common (usually, or group\-global or host specific) config file list .TP .B $CONF_BASEURL/`hostname`/dphys\-config.list.* facultative host\-specific (usually) or group\-specific include\-able subsection(s) to be added to above config file list dphys\-config.list. We often use *.group (one per group of users) and *.host (per host), sometimes also *.base (all host types) and *.workstation (only workstation hosts) subsections .B $CONF_BASEURL/`hostname`/ actual config files referred to in config file list, common section (usually the only section) .B $CONF_BASEURL/`hostname`/.* facultative host\-specific (usually) or group\-specific include\-able subsection(s) to be added to above config file .SH CONFIG FILE LIST The config file list to be used for checking what files need to be installed/updated or removed and its subsections included by #@include lines are merged to one list file, analog to \fBcpp\fP #include. .PP These are all fetched via \fBwget\fP (or \fBcp\fP for file:), adding their names to the user\-defined base URL in \fICONF_BASEURL\fP, and then merged. So \fICONF_BASEURL\fP can be any URL that \fBwget\fP understands http: or ftp: or whatever else, or file:. .PP The format of the resulting concatenated file must consist of lines, one per config file, of following format: .TP \fBfile\-name\fP:\fBplace\-on\-target\fP:\fBcommand\-to\-trigger\fP .TP Where the 3 fields have following meanings: .RS .TP .B file\-name Name of the config file to be installed/updated. Must be only the base part of the filename on the server, without URL and hostname before it, and without any .* subsection endings after it, as these are all auto\-added whenever they are needed. If this is set to \fI\-\fP the line specifies an config file to be removed .TP .B place\-on\-target Full directory or full filename (directory+filename) of where the file is to be placed on the target system. If only an directory is given (any name that ends in /), then the above file\-name (inclusive any directories in it) will be automatically added to it. For removing this must be the full filename (or an directory name (without an /) if an entire directory and its contents shall disapper). An directory name ending with / is not processed, to prevent incomplete edits (filename replaced by \-, but not added to directory) from killing entire directories (such as say all of /etc/ :\-)) .TP .B command\-to\-trigger Full command (directory+filename, with parameters) of an command to be run, after this config file has been newly installed or changed/updated, or before this config file is removed. This can also be multiple commands separated by ; separators. Useful for doing chown/chmod to files that need it. If the marker \fI{}\fP appears in the command, this will be substituted by the filename the config file is going to be installed as. This is analog to \fBfind \-exec\fP filename substitution .RE .PP Lines which begin with an \fB#\fP are regarded as comments, and don't have any effect anything (Lines extended with one are chopped off at that point). The same applies for empty lines. .SH PREPROCESSOR If the first line of the config file list, or any config file fetched on its behalf, has the special format \fB#@dphys\-config\-preprocess\fP [\fBaction...\fP] then this line will be stripped, and the rest of the file will be preprocessed. Depending on the list of \fBaction\fPs present and their order (repeats are allowed) the file will be procesed. Valid \fBaction\fPs are: .RS .TP .B backtick Anything inside backticks (\fB``\fP) will be executed as a command, and its stdout will then be substituted for the `` expression. This is analog to \fIsh\fP backtick substitution .TP .B if For any line beginning with \fB#@if\fP the stuff between the #@if and the first \fB;\fP character will be executed as command, and if it returns true, everything after the ; will be left, else the entire line will be removed. This is analog to \fIshell if ... ;\fP conditional execution .TP .B include For any line beginning with \fB#@include\fP the rest of the line is regarded as an subsection name, which will be added to the base filename, and then the resulting subsection file fetched (also by wget or cp) and substituted for the line. This is analog to an \fIC preprocessor #include\fP oder an \fIshell . include\fP .RE .SH EXAMPLES The following allows you to fetch all your config file lists from an HTTP VirtualHost called www.admin.example.net under its subdirectory dphys\-config. .PP In file \fI/etc/dphys\-config\fP, on every host, so it can find the config file server: .PP .nf # system will use ${CONF_BASEURL}/`hostname`/* CONF_BASEURL=http://www.admin.example.net/dphys\-config .fi .PP We advise using an subdirectory here, because other \fI/http://www.admin.example.net/*\fP directories may already contain other admin stuff you put on the same VirtualHost. Such as software packages, site news, etc. .PP For dphys\-config to be useful you then need to make config file lists for it. And provide the actual config files that can be installed, driven by the lists. This is the largest job, as it basically amounts to extracting all your relevant config work from your site. Also known as reengineering your site. .PP Assuming your VirtualHost on \fIwww.admin.example.net\fP has as its DocumentRoot \fI/vhost/www.admin\fP, you would then begin with an pseudo\-host Directory for site\-global common stuff: \fI/vhost/www.admin/dphys\-config/SITE/\fP. .PP If your hosts are organised in groups with group\-global common configs (such as professors, students, staff), make an pseudo\-host for each group, such as: \fI/vhost/www.admin/dphys\-config/PROFS/\fP and \fI*/STUDENTS/\fP and \fI*/STAFF/\fP. .PP Then for host specific stuff, assuming systems called prof1.example.com to prof3.example.com, stud1 to stud20, staff1 to staff5, server1 and server2, make for each its own directory: \fI/vhost/www.admin/dphys\-config/prof1/\fP (and so on). .PP Note that we suggest using CAPITALS for pseudo\-hosts and lowercase for actual hosts. This avoids name space collisions. You can also use loops like \fIfor host in [a\-z]* ; do ... ; done\fP to work (say generating symlinks to an new config file in all hosts). Well at least you can do this so long no one goes and sets LANGUAGE= or similar junk, then bash (or libc?) will hapily screw up case sensitivity and produce random lossage (yes, it was painfull). .PP After this add to \fI/vhost/www.admin/dphys\-config/SITE/\fP, the actual config files as far as they are not host specific, or at least have an common section to all hosts. Example this would be \fB/etc/hosts\fP for all, an common section for \fB/etc/motd\fP, common or all for \fBsendmail.cf\fP, common for \fBinetd.conf\fP, nothing for the ssh hostkeys. .PP Then add, to an group, say \fI/vhost/www.admin/dphys\-config/STUDENTS/\fP, whatever is specific to that group. Example this may be an entire special \fBmotd\fP for the many changing users, or just an \fBmotd.group\fP to #@include into the common one. .PP Then for each host in its \fI/vhost/www.admin/dphys\-config/prof1/\fP (or so) add all that is specific to it. Such as its ssh key files. And its own \fBmotd.host\fP, it it needs one. Same its \fBinetd.conf.host\fP if it is going to offer special stuff. An configs for services only this host has such as \fBhttpd.conf\fP. .PP Then for each host add symlinks to the SITE or group versions that it is to use for common stuff, like on \fI/vhost/www.admin/dphys\-config/stud1/\fP: .PP .nf .../dphys\-config/stud1/dphys\-config.list \-> ../SITE/dphys\-config.list .../dphys\-config/stud1/hosts \-> ../SITE/hosts .../dphys\-config/stud1/inetd.conf \-> ../SITE/inetd.conf .../dphys\-config/stud1/motd \-> ../SITE/motd .../dphys\-config/stud1/motd.group \-> GROUP/motd .../dphys\-config/stud1/GROUP \-> ../STUDENTS .../dphys\-config/stud1/sendmail.cf \-> ../SITE/sendmail.cf .fi .PP In the \fI/vhost/www.admin/dphys\-config/SITE/\fP directory place the site\-global common \fBdphys\-config.list\fP for all your hosts, containing stuff like this: .PP .nf # SITE dphys\-config.list \- just example stuff, for our exemplaric site # basics hosts:/etc/ # simply works, no command motd:/etc/ # this will be assembled group specific inetd.conf:/etc/:/etc/init.d/inetd restart # needs an command to reload sendmail.cf:/etc/mail/:/etc/init.d/sendmail restart # not in /etc # ssh restart only after last file, and ensure file modes for each file ssh_host_key:/etc/ssh/:chown root:root {}; chmod 600 {} ssh_host_rsa_key:/etc/ssh/:chown root:root {}; chmod 600 {} ssh_host_dsa_key:/etc/ssh/:chown root:root {}; chmod 600 {}; /etc/init.d/sshd restart # load stuff into an existing database file seed.debconf:/etc/:debconf\-set\-selections {} # other stuff daemon1\-conf:/etc/daemon1/conf # rename so names can differ on server daemon2\-conf:/etc/daemon2/conf daemon1/conf:/etc/ # same as above, but with directories on server daemon2/conf:/etc/ testing:/etc/ # put something in there for an test # delete some stuff \-:/etc/testing # change to above test to get rid of it again \-:/etc/ # you will get a warning if you leave this #\-:/etc # you would reinstall your system after the resulting rm \-rf /etc :\-) # and some errors #only\-an\-name # you would get an error: no place on target #only\-an\-name: # you would get an error: no place on target #:only\-an\-place # you would get an error: no file to install .fi .PP For special services add an \fBdphys\-config.list.host\fP on each host that has special config files not present on others, such as on \fI/vhost/www.admin/dphys\-config/server2/\fP: .PP .nf # server2 dphys\-config.list.host \- only used on our web server httpd.conf:/etc/apache/httpd.conf:/etc/init.d/apache restart .fi .PP You can also use dphys\-config to run arbitrary commands, whenever config files are installed/updated or removed, to modify existing config files, or more likely modify complex config databases which can not be provided as files, but where one can provide edit info as files. .PP dphys\-config can even install scripts to use as above commands (or even just to run scripts while installing), such as into \fI/usr/local/sbin/\fP. .PP For this make an \fI../SITE/local/sbin/\fP directory, place the scripts in there (such as \fI../SITE/local/sbin/dphys\-config\-\fP), and symlink \fIlocal\fP to \fI../SITE/local\fP on each host, and then add config lines for the scripts, with the command to trigger them, giving something like this: .PP .nf local/sbin/dphys\-config\-:/usr/:chmod 755 {}; {} # chmod and run .fi .PP It this script processes an config file your will want it to be run if either the script or the config file is updated, so add the script to the laters line as well: .PP .nf dphys\-config\-:/etc/:if [ \-x /usr/local/sbin/dphys\-config\- ] ; then /usr/local/sbin/dphys\-config\- ; fi # run also here .fi .PP Finally, new hosts can then later simply be added, by making the new hosts directory and copying all files and symlinks from an existing host of the same group. Such as by doing: .PP .nf mkdir student21 tar \-cf \- \-C student1 . | tar xpf \- \-C student21 .fi .PP To then run dphys\-config by hand (say for tests), type on the host: .PP \fBdphys\-config\fP .PP But usually you will want to run dphys\-config automatically, every night (or if a machine was/is switched off, at every boot), to keep your configs up to date. .PP For nightly updates the best thing is to use an cron job on every host. 03:00 to 03:59 is most likely idle time. Use an line like this one, with the \fIcron\fP option to avoid an load peak on the config file server, by random delaying the run by 0..3599 seconds, and with stdout and strerr thrown away to avoid getting an mail from every host, as error messages are also allways sent to syslog: .PP 0 3 * * * root dphys\-config cron > /dev/null 2>&1 .PP To catch machines switched off over night, with no cron run on them, also run an init.d script. Use an script like this one, also with stdout and stderr thrown away to avoid cluttering your boot console output: .PP .nf #!/bin/sh # /etc/init.d/dphys\-config \- boot time automatic config updates, if no cron case "$1" in start) dphys\-config init > /dev/null 2>&1 ;; esac exit 0 .fi .SH SECURITY If dphys\-config is to be used to distribute \fIall\fP config files, this will also include files which are security relevant, such as ssh private keys (host key or (root) user authentification), SSL certificates, passwd and shadow, lilo.conf, software license keys, etc. .PP As all files are most likely fetched from an http: URL, measures must be taken to secure the config website from other people downloading them. We here use an restriction to only IP addresses registered as hosts in our NIS server, and additionally run identd on all allowed hosts, and require the wget process opening the HTTP connection to be running by user root, and so also require dphys\-config to run as root. .PP To avoid sniffing it is recommended to give wget an https: URL. .SH GOTCHAS Config files are read by wget from an webserver, so they lose their owners and modes. So the commands triggered on their lines must be used to chown/chmod them to proper values. .PP When used together with \fIdphys\-admin\fP, dphys\-config should run as first (earlier cron and init.d entries). This is needed to provide configs before new packages are installed, so dphys\-admin can pretend that the packages were already once installed (and then non\-purge removed), and so prevent questions on install, which is required for unattended installs. [Note that this pretending does not go as far as setting debconf up. Broken packages that ignore config files and only look at debconf will still ask questions.] .PP As result of this, when installing for the first time on an new system (such as installing Debian by the \fIdphys3\fP end2stage feature, which installs first dphys\-config and then dphys\-admin), any scripts installed by packages by dphys\-admin, to be called on config file install/update will still be missing, and so not runnable. Either ignore the warnings, or better call the scripts by something like this: .PP file:place:if [ \-x script ]; then script; fi .PP Note that in this case, trying to run dphys\-config for a second time after dphys\-admin has installed packages and scripts, will \fBnot\fP automatically mend this, as the config files have not changed, and so dphys\-config will not (re\-)run their scripts. Therefore packages containing such scripts must also, as part of their postinst (or init.d which is called by postinst), check for existing config files and then run their scripts. This is the normal behaviour of quite a few packages anyway. Of course this requires the scripts to be idempotent, which is official Debian policy anyway. .SH AUTHOR neil@franklin.ch, http://neil.franklin.ch/ dphys-config/dphys-config.example0000644000175500017550000000172711221421553016074 0ustar neilneil# /etc/dphys-config - user settings for dphys-config auto configurator # author Neil Franklin, last modification 2009.06.27 # copyright ETH Zuerich Physics Departement # use under either modified/non-advertising BSD or GPL license # this file is sourced with . so full normal sh syntax applies # the default settings are added as commented out CONF_*=* lines # base directory for temporary files # some prefer /var/tmp for size and safety, works everywhere # some prefer /tmp for speed or boot-time auto-delete #CONF_TMP_DIR=/var/tmp # base directory for config files on server # set to something that will produce an error message without site config #CONF_BASEURL=http://not-configured-server.example.net/not/configured/directory # configuration name to use, usually host name, unless chroot or vhost or test #CONF_CONFNAME=`hostname` # only process lines matching this grep regexp, default do all #CONF_LINEFILTER=".*" # log what we have done #CONF_LOG_DONE=yes dphys-config/index.html.de0000777000175500017550000000000010542075510017100 2index.html.enustar neilneildphys-config/index.html.en0000644000175500017550000003710111336576604014535 0ustar neilneil dphys-config Configuration Manager Home | Projects | dphys-config

dphys-config Configuration Manager

Project Basics
Project Status
Code Download
External Stuff (Links)

Project Basics

This project is aimed at installing (and keeping update) the site specific config files we want, after preprocessing them (conditional content and include files and include sections). It also triggers an postinstall script whenever its associated config file has been changed. It can also remove config files, including running an preremove script before doing so. All this is driven by an simple config file list.

This project has produced an dphys-config script for doing the work. And an cron job and an init.d script that run this script nightly and at boot time.

This project was spawned from the dphys-admin project, aimed at automatically installing Debian packages onto our systems, but is itsself independant of dphys-admin or any other Debian stuff. It should work on any Unix system, but has only been tested on our Debian Linux 3.1 (sarge) and later systems and on FreeBSD 6.1.

Project Status

For the full details of done/doing/todo of the project best read the Logfile. A short excerpt from it is here:

Done are:

Milestone/Release 1 (2006.09.15):
  • Fetch config file list, host dependant
  • Fetch config files driven by above, host dependant
  • Merge in host or group dependant "include" files or "if" lines to files
  • Install/update config file where it belongs, if it is new or has changed
  • Run an postinstall script if config file was installed/updated
  • Run an preremove script if a config file shall disappear
  • Remove unwanted config files
  • Allow non-root to use dphys-config to distribute dot files
Milestone/Release 2 (2006.10.20):
  • Bugfix non-root mode to actually work, no writing into /etc/
  • Changed to also work with newer sed comming with in Debian sid
  • Linked to official Debian package in sid (will become etch)
  • Code and documentation tidy ups, some from early feedback
  • Extensive quoting improvements against possible escaping bugs
  • Path handling and other changes to work also on FreeBSD 6.1
Milestone/Release 3 (2009.09.26):
  • Added file: URL support, as wget does not implement that
  • Bugfixes for HTTP status codes, preprocessing handle spaces
  • Facultatively user set hostname for install in xen guests/vhosts
  • Remove various bashisms, so it will work with Debians dash
  • Use mktemp if the users system has it
Milestone/Release 4 (2010.02.16):
  • fixed wget LANG= dependancy which broke file downloads
  • added new -D DEBUG_* option for keeping last wget output file
  • changed 2 unusual spelling variants which Lintian dislikes
Current (= development, = may be fantastic, may be broken):
  • Nothing yet

Todo are:

  • Nothing planned

Code Download

Current (= development, = may be fantastic, may be broken): Milestone/Release 4 (2010.02.16): Milestone/Release 3 (2009.09.26): Milestone/Release 2 (2006.10.20): Milestone/Release 1 (2006.09.15):

External Stuff (Links)

Various links that may be useful:
Home | Projects | dphys-config

This page is by Neil Franklin, last modification 2010.02.16 dphys-config/init.d.example0000644000175500017550000000271411221425644014671 0ustar neilneil#!/bin/sh # /etc/init.d/dphys-config - boot time trigger automatic config updates # authors dsbg and franklin, last modification 2009.06.27 # copyright ETH Zuerich Physics Departement # use under either modified/non-advertising BSD or GPL license # this init.d script is intended to be run from rc2.d # on our site it needs to run after rc2.d/S20inetd (and so identd) # else our config file server will disallow requests for config files # on our site it needs to run before rc2.d/S24dphys-admin # else that will not find its /etc/dphys-admin.list config file # so we run it as rc2.d/S22dphys-config # /usr/local added for FreeBSD, because their ports end up in there PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin export PATH # what we are NAME=dphys-config case "$1" in start) echo -n "Starting ${NAME} automatic config file updates ..." # in case system was switched off for a while, no cron, run an upgrade # no direct output, so no on-screen error message if not configured # this is also consistant with cron.d handling # errors will still be recorded to syslog, enough, as not boot-critical dphys-config init > /dev/null 2>&1 echo ", done." ;; stop) echo "'Stopping' ${NAME} automatic config updates (does nothing)." ;; restart|reload|force-reload) echo "No daemon to (force-)re[start|load] in ${NAME}" ;; *) echo "Usage: $0 {start}" exit 1 ;; esac exit 0 dphys-config/site.example/0000755000175500017550000000000010542757740014533 5ustar neilneildphys-config/site.example/dphys-config-x0000664000175500017550000000574210502274206017312 0ustar neilneil# /etc/dphys-config-x - configure XFree server # author Neil Franklin (auto generate script), last modification 2006.09.14 # whether to generate XF86Config-4 (auto) or leave it alone (manual) # defaults to manual, as user needs to make config file if something wanted #CONF_SETUP=manual # what keyboard layout we have (us, en_US, de_CH, ...) # defaults to international compatible standard here #CONF_KEYB_LAYOUT=us # whether we have the extra 3 keys, and so need an keymap including them # but enabling this screwd up xterm ALT key on Debian 3.0 (potato) XFree4.1 # and without they worked anyway, still does on Debian 3.1 (sarge) XFree4.3 # defaults to using the more universal setting #CONF_KEYB_EXTRA3="" # where the PS/2 mouse is connected # /dev/psaux (standard) # /dev/misc/psaux (devfs) # none (only USB mouse, disable PS/2 mouse, else keyboard dead) # defaults to what we and most people use these days, now devfs is deprecated #CONF_PS2_MOUSE_DEV=/dev/psaux # what PS/2 mouse type we have # imps2 (Logitech Wheel Mouse) # ps2 (2 or 3-button mouse) # ps2scroll (Wheel Mouse with scrolling on button2 push) # none (only USB mouse, disable PS/2 mouse, else keyboard dead) # defaults to the most common PS/2 mouse type around here #CONF_PS2_MOUSE_PROTO=imps2 # what USB mouse type we have # imps2 (Logitech Wheel Mouse) # ps2 (2 or 3-button mouse) # ps2scroll (Wheel Mouse with scrolling on button2 push) # none (only PS/2 mouse, disable USB mouse, don't load USB drivers) # defaults to the most common USB mouse type around here #CONF_USB_MOUSE_PROTO=imps2 # what our monitor is capable of # defaults to standard averge LCD abilities, as most are today LCDs # old "CRT" and "LCD" settings were 121, "CRT-slow" and "EIZO-T68" had 96 #CONF_HOR_MAX=121 # old "LCD" setting was 60, "CRT" and "CRT-slow" and "EIZO-T68" had 160 #CONF_VER_MAX=60 # what physical size the monitor has, if not queryable, or overriding wanted # format ist "xxx yyy" with xxx and yyy being size in mm # defaults to nothing, as most systems here do not have it set #CONF_DISPSIZE="" # force configuration for this device type # defaults to using what lspci detects, change for special cases #CONF_DEVICE_TYPE="" # PCI bus ID of what card we will be using, in cases it needs forcing # defaults to nothing, as only needed on dual displays, and host specific #CONF_BUS_ID="" # what amount of pixels we want # such as 800x600, 1024x768, 1152x864, 1280x1024, 1400x1050, 1600x1200 # defaults to what most monitors are capable of displaying #CONF_RESOLUTION="1024x768" # what amount of bits/pixel we want # such as 1, 2, 4, 8, 15, 16, 24, 32 # defaults to what most cards can do and need #CONF_DEPTH=24 # whether we have an dual headed system or even Xinerama # none (single screen) # dual (2 screens separate, 2nd right of 1st) # xine (2 screens merged, 2nd right of 1st) #CONF_DUAL=none # log what we have done #CONF_LOG_DONE=yes dphys-config/site.example/dphys-config-filesys.list0000664000175500017550000000235110455706571021500 0ustar neilneil# /etc/dphys-config-filesys.list - add stuff to filesystem and to /etc/fstab # allow direct reading of mails nfsmount:/var/mail:mail.phys:/var/mail:rw,soft,noac,rsize=8192,wsize=8192,retry=1 # allow users to use rest of disk space directory:/scratch:root:root:1777 # allow remote access to /export/data, uses autofs automounter # only used by some groups, with /data/ to access /export/data # with /export/data defined for these in their .hostpost list files: # astro (for only astro, with SGID, and sticky): # partition:/export/data1:/dev/hdb1:ext3 # directory:/export/data2:root:astro:3770 # lpp (for only lpp, without SGID, but with sticky): # partition:/export/data1:/dev/hdb1:ext3 # directory:/export/data2:root:lpp:1770 # few isg and theor (for anyone, without SGID, but with sticky): # partition:/export/data1:/dev/hdb1:ext3 # directory:/export/data2:root:root:1777 directory:/data:root:root:0755 # for restoring stuff, uses autofs automounter directory:/backup:root:root:0755 # quick access to package servers, uses /net automounter # /mirror for debian, /pub for debian-local symlink:/mirror:/net/debian/export/mirror symlink:/pub:/net/debian/export/pub dphys-config/site.example/dphys-config.list0000644000175500017550000000272410513467715020025 0ustar neilneil# SITE/dphys-config.list - tell dphys-config what files to process # authors multiple, last modification 2006.10.05 # extra filesystem and fstab line configuration # after updating this also autogenerate exports and user quota dphys-config-filesys.list:/etc/:if [ -x /usr/local/sbin/dphys-config-filesys ] ; then /usr/local/sbin/dphys-config-filesys; fi; if [ -x /usr/local/sbin/dphys-config-exports ] ; then /usr/local/sbin/dphys-config-exports; fi; if [ -x /usr/local/sbin/dphys-config-quota ] ; then /usr/local/sbin/dphys-config-quota; fi # extra filesystem and fstab line script local/sbin/dphys-config-filesys:/usr/:chmod 755 {}; {} # NFS exports for shares script local/sbin/dphys-config-exports:/usr/:chmod 755 {}; {} # quota configuration script local/sbin/dphys-config-quota:/usr/:chmod 755 {}; {} # usb storage (sticks/disks) modules load configuration local/sbin/dphys-config-usb-storage:/usr/:chmod 755 {}; {} # X configuration # X server setup, hardware description dphys-config-x:/etc/:if [ -x /usr/local/sbin/dphys-config-x ] ; then /usr/local/sbin/dphys-config-x ; fi # and XFree.conf generator script local/sbin/dphys-config-x:/usr/:chmod 755 {}; {} # select various X settings local/sbin/dphys-config-altern-xcursor:/usr/:chmod 755 {}; {} local/sbin/dphys-config-altern-xsession:/usr/:chmod 755 {}; {} # select various applications local/sbin/dphys-config-altern-xterminal:/usr/:chmod 755 {}; {} local/sbin/dphys-config-altern-wwwbrowser:/usr/:chmod 755 {}; {} dphys-config/site.example/local/0000755000175500017550000000000010467125216015616 5ustar neilneildphys-config/site.example/local/sbin/0000755000175500017550000000000011223147411016541 5ustar neilneildphys-config/site.example/local/sbin/dphys-config-exports0000664000175500017550000000231111223145553022564 0ustar neilneil#!/bin/bash # /usr/local/sbin/dphys-config-exports - generate /etc/exports # author Neil Franklin, last modification 2006.10.12 # 2009.07.02 because of echo -e changed to #!/bin/bash, not tested after!!! # copyright ETH Zuerich Physics Departement, # use under either modified/non-advertising BSD or GPL license # this script is called by dphys-config, once on each install/update # no parameters or environment variables are evaluated # it requires in /etc/dphys-config.list 1 line: # local/sbin/dphys-config-exports:/usr/:chmod 755 {}; {} set -e # get ready to work # /usr/local added for FreeBSD, because their ports end up in there PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin export PATH ACCESS="@many(rw,async)" EXPORTS=/etc/exports if [ -f ${EXPORTS} ] ; then rm ${EXPORTS} fi # here no "" around `ls`, else intervening and trailing spaces end up in DIR for DIR in /scratch /export/data* ; do # prevent space split data from making multiple bogus entries if [ -d "${DIR}" ] ; then echo -e "${DIR}\t${ACCESS}" >> ${EXPORTS} fi done if [ -f ${EXPORTS} ] ; then if [ -x /etc/init.d/nfs-kernel-server ] ; then /etc/init.d/nfs-kernel-server restart fi fi exit 0 dphys-config/site.example/local/sbin/dphys-config-filesys0000664000175500017550000002376711223145706022560 0ustar neilneil#!/bin/sh # /usr/local/sbin/dphys-config-filesys - add filesystem stuff # author Neil Franklin, last modification 2006.10.12 # derived from dphys-setup-extra-fs 1.0, Elmar S. Heeb # 2009.07.02 because of [ -o ] changed to ( [] || [] ), not tested after!!! # copyright ETH Zuerich Physics Departement, # use under either modified/non-advertising BSD or GPL license # this script is called by dphys-config # once on each config list file or script install/update # no parameters or environment variables are evaluated # reads all input from dirnames list file /etc/dphys-config-filesys.list # it requires in /etc/dphys-config.list 2 lines, for config file and script: # dphys-config-filesys.list:/etc/:if [ -f /usr/local/sbin/dphys-config-filesys ] ; then /usr/local/sbin/dphys-config-filesys ; fi # local/sbin/dphys-config-filesys:/usr/:chmod 755 {}; {} ### ------ configuration for this site # --- CONF_* various site or subnet dependant user config variables # log what we have done CONF_LOG_DONE=yes # --- DEBUG_*, various debugging settings # force lots of debugging output # this can also be enabled by touch /dphys-config-filesys.debug #DEBUG_LOG_STEP=yes # --- SYS_*, various system internal values # name of directory names list file on server SYS_CONFLIST=/etc/dphys-config-filesys.list ### ------ actual implementation from here on # no user settings any more below this point set -e # --- get ready to work # sanitise this place, else some commands may fail # must be before any commands are executed, incl config/input processing # /usr/local added for FreeBSD, because their ports end up in there PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin export PATH # --- tidy up some commands, make systematic # stuff that goes wrong, not expected by user, not in data output, use >&2 # so also with $0 in case this script was called by an other script # something within the system that user does not expect, give up CMD_FATAL="echo $0: FATAL:" # something from users input, user will correct this and continue CMD_ERROR="echo $0: ERROR:" # something we can continue with, but may be wrong, and user may not suspect it CMD_WARNING="echo $0: WARNING:" # something most likely not wrong, but tell user for the odd case it is wrong CMD_NOTE="echo $0: NOTE:" # normal stuff users expect, so to stdout as normal output, no $0, no marking CMD_INFO="echo" # stuff users asked for, so add to stdout as normal output, no $0, but mark it CMD_DEBUG="echo DEBUG:" # and also put out some permanent messages, in case running as cron/init.d job BASENAME="`basename $0`" # something within the system that user does not expect, give up CMD_LOG_FATAL="logger -t ${BASENAME} -p user.error FATAL:" # something from users input, user can possibly correct this and continue CMD_LOG_ERROR="logger -t ${BASENAME} -p user.error ERROR:" # something we can continue with, but may be wrong, and user may not suspect it CMD_LOG_WARNING="logger -t ${BASENAME} -p user.warning WARNING:" # something most likely not wrong, but tell user for the odd case it is wrong CMD_LOG_NOTE="logger -t ${BASENAME} -p user.notice NOTE:" # normal stuff users expect, so no marking CMD_LOG_INFO="logger -t ${BASENAME} -p user.info" # stuff users asked for, but mark it as special CMD_LOG_DEBUG="logger -t ${BASENAME} -p user.debug DEBUG:" # other stuff we may want to use CMD_SLEEP="sleep 2" CMD_WAIT="read -p ---DEBUG-wait-after-step--- dummy" # --- config file stuff # what we are NAME=dphys-config-filesys PNAME=dphys-config-filesys # check user config file(s), let user override settings if [ -e /etc/${PNAME} ] ; then . /etc/${PNAME} fi # allow us to set logging despite no command line options and parser if [ -f /${NAME}.debug ] ; then DEBUG_LOG_STEP=yes fi # --- control variable output # set config option controllable stuff if [ x${CONF_LOG_DONE} = xyes ] ; then CMD_LOG_IF_DONE="${CMD_LOG_INFO}" else CMD_LOG_IF_DONE=true fi # set debug option controllable stuff if [ x${DEBUG_LOG_STEP} = xyes ] ; then CMD_LOG_IF_DEBUG="${CMD_LOG_DEBUG}" else CMD_LOG_IF_DEBUG=true fi # show what config settings this debug run is using ${CMD_LOG_IF_DEBUG} "CONF_LOG_DONE=${CONF_LOG_DONE}" # --- install each directory name if ( [ ! -f "${SYS_CONFLIST}" ] || [ ! -s "${SYS_CONFLIST}" ] ) ; then # directory name list not found, so we can not work ${CMD_FATAL} "no or empty directory name list ${SYS_CONFLIST}" >&2 ${CMD_LOG_FATAL} "no or empty directory name list ${SYS_CONFLIST}" exit 1 fi # get rid of comments and empty lines (may be emptied comment lines) cut -f 1 -d '#' "${SYS_CONFLIST}" | grep -v '^ *$' | while read LINE ; do ${CMD_LOG_IF_DEBUG} "LINE=\"${LINE}\"" # extract from LINE format: type:parameter[:parameter...] if ! echo "${LINE}" | grep -q ':' ; then ${CMD_ERROR} "config line \"${LINE}\" has no \":\" to split on" >&2 ${CMD_LOG_ERROR} "config line \"${LINE}\" has no \":\" to split on" exit 1 fi TYPE="`echo "${LINE}" | cut -f 1 -d ":"`" ${CMD_LOG_IF_DEBUG} "TYPE=${TYPE}" case "${TYPE}" in directory) # line format: directory:

::: # example: directory:/scratch:root:root:1777 DIR="`echo "${LINE}" | cut -f 2 -d ':'`" OWNER="`echo "${LINE}" | cut -f 3 -d ':'`" GROUP="`echo "${LINE}" | cut -f 4 -d ':'`" MODE="`echo "${LINE}" | cut -f 5 -d ':'`" if [ ! -e "${DIR}" ] ; then mkdir -p "${DIR}" ${CMD_LOG_IF_DEBUG} "made DIR=${DIR}" else if [ ! -d "${DIR}" ] ; then ${CMD_ERROR} "File ${DIR} already exists and is not a directory" >&2 ${CMD_LOG_ERROR} "File ${DIR} already exists and is not a directory" exit 1 fi fi chown "${OWNER}:${GROUP}" "${DIR}" chmod "${MODE}" "${DIR}" ${CMD_LOG_IF_DEBUG} "DIR=${DIR}" \ "OWNER=${OWNER} GROUP=${GROUP} MODE=${MODE}" ;; symlink) # line format: symlink:: # example: symlink:/pub:/net/debian/export/pub LINK="`echo "${LINE}" | cut -f 2 -d ':'`" TARGET="`echo "${LINE}" | cut -f 3 -d ':'`" if [ "${LINK}" = "" ]; then LINK="`basename "${TARGET}"`" fi if [ ! -e "${LINK}" ] ; then ln -sf "${TARGET}" "${LINK}" ${CMD_LOG_IF_DEBUG} "made LINK=${LINK}" else if [ ! -L "${LINK}" ] ; then ${CMD_ERROR} "File ${LINK} already exists and is not a symlink" >&2 ${CMD_LOG_ERROR} "File ${LINK} already exists and is not a symlink" exit 1 fi fi ${CMD_LOG_IF_DEBUG} "LINK=${LINK} TARGET=${TARGET}" ;; partition) # line format: partition::: # example: partition:/export/data1:/dev/sdb1:ext3 MPOINT="`echo "${LINE}" | cut -f 2 -d ':'`" DEV="`echo "${LINE}" | cut -f 3 -d ':'`" FS="`echo "${LINE}" | cut -f 4 -d ':'`" if [ ! -e "${DEV}" ]; then ${CMD_ERROR} "line for ${MPOINT} has non-existant" \ "device ${DEV}" >&2 ${CMD_LOG_ERROR} "line for ${MPOINT} has non-existant" \ "device ${DEV}" exit 1 fi if [ ! -e "${MPOINT}" ] ; then mkdir -p "${MPOINT}" ${CMD_LOG_IF_DEBUG} "made MPOINT=${MPOINT}" else if [ ! -d "${MPOINT}" ] ; then ${CMD_ERROR} "File ${MPOINT} already exists and is not directory" >&2 ${CMD_LOG_ERROR} "File ${MPOINT} already exists and is not directory" exit 1 fi fi # possible existing line (or empty) awk '$2=="'"${MPOINT}"'"{print}' /etc/fstab > /etc/fstab.old.$$ # potentially new line we want printf "%s\t%s\t%s\t%s\t%s\t%s\n" "${DEV}" "${MPOINT}" "${FS}" \ "defaults" "0" "2" > /etc/fstab.new.$$ if ! cmp -s /etc/fstab.new.$$ /etc/fstab.old.$$ ; then # differs, remove old entry (if present) ... awk '$2!="'"${MPOINT}"'"{print}' /etc/fstab > /etc/fstab.tmp.$$ # ... and add new entry cat /etc/fstab.tmp.$$ /etc/fstab.new.$$ > /etc/fstab rm /etc/fstab.tmp.$$ fi rm /etc/fstab.new.$$ /etc/fstab.old.$$ mount "${MPOINT}" 2> /dev/null || true ${CMD_LOG_IF_DEBUG} "MPOINT=${MPOINT} DEV=${DEV} FS=${fFS}" ;; nfsmount) # line format: nfsmount:::: # example: nfsmount:/var/mail:mail.phys:/var/mail:rw,soft,noac,rsize=8192,wsize=8192,retry=1 MPOINT="`echo "${LINE}" | cut -f 2 -d ':'`" SERVER="`echo "${LINE}" | cut -f 3 -d ':'`" EXPORT="`echo "${LINE}" | cut -f 4 -d ':'`" NFSOPT="`echo "${LINE}" | cut -f 5 -d ':'`" if [ "${NFSOPT}" = "" ]; then NFSOPT=defaults fi if [ ! -e "${MPOINT}" ] ; then mkdir -p "${MPOINT}" ${CMD_LOG_IF_DEBUG} "made MPOINT=${MPOINT}" else if [ ! -d "${MPOINT}" ] ; then ${CMD_ERROR} "File ${MPOINT} already exists and is not directory" >&2 ${CMD_LOG_ERROR} "File ${MPOINT} already exists and is not directory" exit 1 fi fi # possible existing line (or empty) awk '$2=="'"${MPOINT}"'"{print}' /etc/fstab > /etc/fstab.old.$$ # potentially new line we want printf "%s\t%s\t%s\t%s\t%s\t%s\n" "${SERVER}:${EXPORT}" "${MPOINT}" \ "nfs" "${NFSOPT}" "0" "0" > /etc/fstab.new.$$ if ! cmp -s /etc/fstab.new.$$ /etc/fstab.old.$$ ; then # differs, remove old entry (if present) ... awk '$2!="'"${MPOINT}"'"{print}' /etc/fstab > /etc/fstab.tmp.$$ # ... and add new entry cat /etc/fstab.tmp.$$ /etc/fstab.new.$$ > /etc/fstab rm /etc/fstab.tmp.$$ fi rm /etc/fstab.new.$$ /etc/fstab.old.$$ mount "${MPOINT}" 2> /dev/null || true ${CMD_LOG_IF_DEBUG} "MPOINT=${MPOINT}" \ "SERVER=${SERVER} EXPORT=${EXPORT} NFSOPT=${NFSOPT}" ;; *) ${CMD_ERROR} "unknown line type: ${TYPE}" >&2 ${CMD_LOG_ERROR} "unknown line type: ${TYPE}" exit 1 esac done # --- finish off ${CMD_LOG_IF_DONE} "has updated filesystem and /etc/fstab" exit 0 dphys-config/site.example/local/sbin/dphys-config-quota0000664000175500017550000000600410513673076022223 0ustar neilneil#!/bin/sh # /usr/local/sbin/dphys-config-quota - automatically set up user quotas # author franklin, last modification 2006.10.13 # This script is copyright ETH Zuerich Physics Departement, # use under either modified/non-advertising BSD or GPL license # this script is called by dphys-config, once on each install/update # no parameters or env vars for this script # it requires in /etc/dphys-config.list 1 line: # local/sbin/dphys-config-quota:/usr/:chmod 755 {}; {} set -e # get ready to work # /usr/local added for FreeBSD, because their ports end up in there PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin export PATH # eliminate accidental duplicated usrquota options on some of our hosts # were result of older scripts that wre not idempotent while grep -q ',usrquota,usrquota' /etc/fstab ; do sed -e '/,usrquota,usrquota/s//,usrquota/' /etc/fstab > /etc/fstab.tmp mv /etc/fstab.tmp /etc/fstab done # we want quota on / and any filesystems mounted as /export/data* (if any) # hope there are no other relevant filesystems # here no "" around `ls`, else intervening and trailing spaces end up in MPOINT for MPOINT in / /export/data* ; do # is this actually a valid mount point? # one of the /export/data* will be subdir of /, not separate mount # so we must drop that one, so no simple test for directory if [ "`awk '$2=="'"${MPOINT}"'" { print $2 }' /etc/fstab`" != "" ] ; then # only if quota has not been added yet if [ "`awk '$2=="'"${MPOINT}"'" && $4 !~ /usrquota/ { print $2 }' \ /etc/fstab`" != "" ] ; then awk 'BEGIN { OFS="\t" } $2=="'"${MPOINT}"'" && NF==6 { $4 = $4",usrquota" } { print }' \ /etc/fstab > /etc/.fstab mv /etc/.fstab /etc/fstab fi # only if not already mounted with quota if [ "`awk '$2=="'"${MPOINT}"'" && $4 !~ /usrquota/ { print $2 }' \ /etc/mtab`" != "" ] ; then # ensure that kernel knows about this mount point using quota mount -o remount "${MPOINT}" # just in case this interferes with rebuilding # may return non-zero if no quota is running, so catch that quotaoff "${MPOINT}" 2> /dev/null || true # man page claims following autogenerate, Beat regards these as needed rm -f "${MPOINT}/quota.user" touch "${MPOINT}/quota.user" chmod 600 "${MPOINT}/quota.user" # we use -m (no remount as -ro), so risks losing count # but this quota is only for recording, not for enforcement # we only want to see users disk usage without waiting for du -sk # same also -f (force) so that mount is ignored # the -c avoids validity check warning message on empty quota.user file # quotacheck can take a very long time, like find quotacheck -cmf "${MPOINT}" quotaon "${MPOINT}" fi else echo "$0: NOTE: no mount point ${MPOINT} in /etc/fstab," \ "may be a subdir of /, ignoring quota request for it ..." >&2 fi done exit 0 dphys-config/site.example/local/sbin/dphys-config-usb-storage0000664000175500017550000000271310513673173023326 0ustar neilneil#!/bin/sh # /usr/local/sbin/dphys-config-usb-storage - load modules for USB storage # author Neil Franklin, last modification 2006.10.13 # copyright ETH Zuerich Physics Departement, # use under either modified/non-advertising BSD or GPL license # this script is called by dphys-config, once on each script install/update # no parameters or environment variables are evaluated # it requires in /etc/dphys-config.list 1 line: # local/sbin/dphys-config-usb-storage:/usr/:chmod 755 {}; {} set -e # get ready to work # /usr/local added for FreeBSD, because their ports end up in there PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin export PATH # install and load kernel modules needed for USB storage # usbcore is needed for all USB stuff, should be already in, but go safe # sd_mod is SCSI disk, for logging scsi numbers to /dev/sd names map # this is missing in Debian Linux 3.1 (sarge) standard kernels # usb-storage is generic USB storage device protocol for MODULE in usbcore sd_mod usb-storage ; do # insert them into /etc/modules for after future boots grep ${MODULE} /etc/modules > /dev/null || echo ${MODULE} >> /etc/modules # insert them into the running kernel for this session # use || true so we can try nonexisting other kernel version modules # else set -e will nuke this script when we try this grep "^${MODULE}" /proc/modules > /dev/null || \ modprobe ${MODULE} 2> /dev/null || true done exit 0 dphys-config/site.example/local/sbin/dphys-config-x0000664000175500017550000006646311223147411021344 0ustar neilneil#!/bin/sh # /usr/local/sbin/dphys-config-x - generate XFree server configuration # author Neil Franklin, last modification 2006.10.13 # 2009.07.02 because of [ -a ] changed to ( [] && [] ), not tested after!!! # copyright ETH Zuerich Physics Departement, # use under either modified/non-advertising BSD or GPL license # this script is called by dphys-config # once on each config file or script install/update # no parameters or environment variables are evaluated # reads all input from config file /etc/dphys-config-x # it requires in /etc/dphys-config.list 2 lines, for config file and script: # dphys-config-x:/etc/:if [ -f /usr/local/sbin/dphys-config-x ] ; then /usr/local/sbin/dphys-config-x ; fi # local/sbin/dphys-config-x:/usr/:chmod 755 {}; {} ### ------ configuration for this site # first CONF_* various site or user dependant user config variables # then DEBUG_* various debugging settings # last SYS_* various system internal values # --- CONF_* various site or subnet dependant user config variables # whether to generate XF86Config-4 (auto) or leave it alone (manual) # defaults to manual, as user needs to make config file if something wanted CONF_SETUP=manual # what keyboard layout we have (us, en_US, de_CH, ...) # defaults to international compatible standard here CONF_KEYB_LAYOUT=us # whether we have the extra 3 keys, and so need an keymap including them # but enabling this screwd up xterm ALT key on Debian 3.0 (potato) XFree4.1 # and without they worked anyway, still does on Debian 3.1 (sarge) XFree4.3 # defaults to using the more universal setting CONF_KEYB_EXTRA3="" # where the PS/2 mouse is connected # /dev/psaux (standard) # /dev/misc/psaux (devfs) # /dev/gmpdata (used for gpm) # none (only USB mouse, disable PS/2 mouse, else keyboard dead) # defaults to what we and most people use these days, now devfs is deprecated CONF_PS2_MOUSE_DEV=/dev/psaux # what PS/2 mouse type we have # imps2 (Logitech Wheel Mouse) # ps2 (2 or 3-button mouse) # ps2scroll (Wheel Mouse with scrolling on button2 push) # intelli (used for gpmdata) # none (only USB mouse, disable PS/2 mouse, else keyboard dead) # defaults to the most common mouse type around here # fix it for old ps2, alternative ps2scroll or none CONF_PS2_MOUSE_PROTO=imps2 # what USB mouse type we have # imps2 (Logitech Wheel Mouse) # ps2 (2 or 3-button mouse) # ps2scroll (Wheel Mouse with scrolling on button2 push) # intelli (used for gpmdata) # none (only PS/2 mouse, disable USB mouse, don't load USB drivers) # defaults to allow user to plug in anything, but this fails scroll wheels #CONF_USB_MOUSE_PROTO=auto # defaults to the most common mouse type around here CONF_USB_MOUSE_PROTO=imps2 # what our monitor is capable of # defaults to standard averge LCD abilities, as most are today LCDs # old "CRT" and "LCD" settings were 121, "CRT-slow" and "EIZO-T68" had 96 CONF_HOR_MAX=121 # old "LCD" setting was 60, "CRT" and "CRT-slow" and "EIZO-T68" had 160 CONF_VER_MAX=60 # what physical size the monitor has, if not queryable, or overriding wanted # format ist "xxx yyy" with xxx and yyy being size in mm # defaults to nothing, as most systems here do not have it set CONF_DISPSIZE="" # force configuration for this device type # defaults to using what lspci detects, change for special cases CONF_DEVICE_TYPE="" # PCI bus ID of what card we will be using, in cases it needs forcing # defaults to nothing, as only needed on dual displays, and host specific CONF_BUS_ID="" # what amount of pixels we want # such as 800x600, 1024x768, 1152x864, 1280x1024, 1400x1050, 1600x1200 # defaults to what most monitors are capable of displaying CONF_RESOLUTION="1024x768" # what amount of bits/pixel we want # such as 1, 2, 4, 8, 15, 16, 24, 32 # defaults to what most cards can do and need CONF_DEPTH=24 # whether we have an dual headed system or even Xinerama # none (single screen) # dual (2 screens separate, 2nd right of 1st) # xine (2 screens merged, 2nd right of 1st) CONF_DUAL=none # log what we have done CONF_LOG_DONE=yes # --- DEBUG_*, various debugging settings # force lots of debugging output # this can also be enabled by touch /dphys-config-x.debug #DEBUG_LOG_STEP=yes # --- SYS_*, various system internal values # what we are going to generate SYS_X_CONFFILE=/etc/X11/XF86Config-4 # where we hope to find our X installation SYS_X_PREFIX_PATH1=/usr/X11R64 SYS_X_PREFIX_PATH2=/usr/X11R6 # where we need to link the X server from and to SYS_X_SERVER=bin/XFree86 SYS_X_LINK=/etc/X11/X # settings for monitor resolutions, normal CRT monitor # try stay inside ranges, so min slightly higher than normal standard VGA SYS_HOR_MIN="32" # old was 30, may fail some monitors SYS_VER_MIN="50" # old was 48, definitively failled some monitors ### ------ actual implementation from here on # no user settings any more below this point set -e # --- get ready to work # sanitise this place, else some commands may fail # must be before any commands are executed, incl config/input processing # /usr/local added for FreeBSD, because their ports end up in there PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin export PATH # --- tidy up some commands, make systematic # stuff that goes wrong, not expected by user, not in data output, use >&2 # so also with $0 in case this script was called by an other script # something within the system that user does not expect, give up CMD_FATAL="echo $0: FATAL:" # something from users input, user will correct this and continue CMD_ERROR="echo $0: ERROR:" # something we can continue with, but may be wrong, and user may not suspect it CMD_WARNING="echo $0: WARNING:" # something most likely not wrong, but tell user for the odd case it is wrong CMD_NOTE="echo $0: NOTE:" # normal stuff users expect, so to stdout as normal output, no $0, no marking CMD_INFO="echo" # stuff users asked for, so add to stdout as normal output, no $0, but mark it CMD_DEBUG="echo DEBUG:" # and also put out some permanent messages, in case running as cron/init.d job BASENAME="`basename $0`" # stuff that goes wrong, not expected by user # something within the system that user does not expect, give up CMD_LOG_FATAL="logger -t ${BASENAME} -p user.error FATAL:" # something from users input, user can possibly correct this and continue CMD_LOG_ERROR="logger -t ${BASENAME} -p user.error ERROR:" # something we can continue with, but may be wrong, and user may not suspect it CMD_LOG_WARNING="logger -t ${BASENAME} -p user.warning WARNING:" # something most likely not wrong, but tell user for the odd case it is wrong CMD_LOG_NOTE="logger -t ${BASENAME} -p user.notice NOTE:" # normal stuff users expect, so no marking CMD_LOG_INFO="logger -t ${BASENAME} -p user.info" # stuff users asked for, but mark it as special CMD_LOG_DEBUG="logger -t ${BASENAME} -p user.debug DEBUG:" # other stuff we may want to use CMD_SLEEP="sleep 2" CMD_WAIT="read -p ---DEBUG-wait-after-step--- dummy" # --- config file stuff # what we are NAME=dphys-config-x PNAME=dphys-config-x # check user config file(s), let user override settings if [ -e /etc/${PNAME} ] ; then . /etc/${PNAME} fi # allow us to set logging despite no command line options and parser if [ -f /${NAME}.debug ] ; then DEBUG_LOG_STEP=yes fi # --- control variable output # set config option controllable stuff if [ x${CONF_LOG_DONE} = xyes ] ; then CMD_LOG_IF_DONE="${CMD_LOG_INFO}" else CMD_LOG_IF_DONE=true fi # set debug option controllable stuff if [ x${DEBUG_LOG_STEP} = xyes ] ; then CMD_LOG_IF_DEBUG="${CMD_LOG_DEBUG}" else CMD_LOG_IF_DEBUG=true fi # show what config settings this debug run is using ${CMD_LOG_IF_DEBUG} "CONF_SETUP=${CONF_SETUP}" \ "CONF_KEYB_LAYOUT=${CONF_KEYB_LAYOUT}" \ "CONF_KEYB_EXTRA3=${CONF_KEYB_EXTRA3}" \ "CONF_PS2_MOUSE_DEV=${CONF_PS2_MOUSE_DEV}" \ "CONF_PS2_MOUSE_PROTO=${CONF_PS2_MOUSE_PROTO}" \ "CONF_USB_MOUSE_PROTO=${CONF_USB_MOUSE_PROTO}" \ "CONF_HOR_MAX=${CONF_HOR_MAX}" \ "CONF_VER_MAX=${CONF_VER_MAX} CONF_DISPSIZE=${CONF_DISPSIZE}" \ "CONF_DEVICE_TYPE=${CONF_DEVICE_TYPE} CONF_BUS_ID=${CONF_BUS_ID}" \ "CONF_RESOLUTION=${CONF_RESOLUTION} CONF_DEPTH=${ONF_DEPTH}" \ "CONF_DUAL=${CONF_DUAL} CONF_LOG_DONE=${CONF_LOG_DONE}" # --- test if we need to generate if [ "${CONF_SETUP}" = manual ] ; then ${CMD_NOTE} "no automatic X configuration selected for this host," \ "falling back to manual configuration file" if [ -f "${SYS_X_CONFFILE}" ] ; then exit 0 else ${CMD_WARNING} "no configuration file at all," \ "continuing with making an automatic one, better than none" >&2 ${CMD_LOG_WARNING} "no configuration file at all," \ "continuing with making an automatic one, better than none" CONF_SETUP=auto fi fi # +++ temp stuff for while we are testing/migrating, delete it after +++ # eliminate old test file if [ -f /etc/X11/XF86Config-4.test-dphys-config-x ] ; then rm /etc/X11/XF86Config-4.test-dphys-config-x fi # backup old style working file in case new file fails to work if [ ! -f /etc/X11/XF86Config-4.before-dphys-config-x ] ; then if [ -f /etc/X11/XF86Config-4 ] ; then mv /etc/X11/XF86Config-4 /etc/X11/XF86Config-4.before-dphys-config-x fi fi # prevent the old system from breaking the new file if [ -x /etc/init.d/dphys-local-x ] ; then chmod a-x /etc/init.d/dphys-local-x fi if [ -x /etc/init.d/dphys-setup-x ] ; then chmod a-x /etc/init.d/dphys-setup-x fi if [ -x /etc/cron.daily/dphys-local-x ] ; then chmod a-x /etc/cron.daily/dphys-local-x fi if [ -x /etc/cron.daily/dphys-setup-x ] ; then chmod a-x /etc/cron.daily/dphys-setup-x fi # --- look for our X installation X_PREFIX_PATH="${SYS_X_PREFIX_PATH1}" if [ ! -d "${X_PREFIX_PATH}" ] ; then X_PREFIX_PATH="${SYS_X_PREFIX_PATH2}" fi if [ ! -d "${X_PREFIX_PATH}" ] ; then ${CMD_FATAL} "X installation can not be found, abborting ..." >&2 ${CMD_LOG_FATAL} "X installation can not be found, abborting ..." exit 1 fi ${CMD_LOG_IF_DEBUG} "X_PREFIX_PATH=${X_PREFIX_PATH}" # and while here, fix up link to X server if [ ! -L "${SYS_X_LINK}" ] ; then if [ -e "${SYS_X_LINK}" ] ; then ${CMD_FATAL} "${SYS_X_LINK} already being used for something else," \ "can not link to X server, abborting ..." >&2 ${CMD_LOG_FATAL} "${SYS_X_LINK} already being used for something else", \ "can not link to X server, abborting ..." exit 1 fi ln -s "${SYS_X_PREFIX_PATH2}/${SYS_X_SERVER}" "${SYS_X_LINK}" fi # --- make generic beginning section cat > "${SYS_X_CONFFILE}" << END-CONFIG-FILE # ${SYS_X_CONFFILE} - configure XFree X server for our hardware # generator /usr/local/sbin/dphys-config-x, generated `date +%Y.%m.%d` ### this file is automatically generated by dphys-config-x script # change /etc/${PNAME} config file to define the parameters for this script # parameters used for last run on this host were: # # CONF_SETUP=${CONF_SETUP} # CONF_KEYB_LAYOUT=${CONF_KEYB_LAYOUT} # CONF_KEYB_EXTRA3=${CONF_KEYB_EXTRA3} # CONF_PS2_MOUSE_PROTO=${CONF_PS2_MOUSE_PROTO} # CONF_PS2_MOUSE_DEV=${CONF_PS2_MOUSE_DEV} # CONF_USB_MOUSE_DEV=${CONF_USB_MOUSE_DEV} # CONF_HOR_MAX=${CONF_HOR_MAX} # CONF_VER_MAX=${CONF_VER_MAX} # CONF_DISPSIZE=${CONF_DISPSIZE} # CONF_DEVICE_TYPE=${CONF_DEVICE_TYPE} # CONF_BUS_ID=${CONF_BUS_ID} # CONF_RESOLUTION=${CONF_RESOLUTION} # CONF_DEPTH=${CONF_DEPTH} # CONF_DUAL=${CONF_DUAL} Section "Module" END-CONFIG-FILE if [ "${CONF_DEVICE_TYPE}" != nvidia ] ; then # binary nvidia driver can not stand having GLcore loaded, has own GL cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Load "GLcore" END-CONFIG-FILE fi cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Load "bitmap" Load "dbe" Load "ddc" Load "dri" Load "extmod" Load "freetype" Load "glx" Load "int10" # Load "pex5" # deprecated Load "record" Load "speedo" Load "type1" Load "vbe" # Load "xie" # deprecated EndSection Section "DRI" Group "video" Mode 0660 EndSection Section "Files" # these 2 variable because of self compiled X servers under woody RgbPath "${X_PREFIX_PATH}/lib/X11/rgb" ModulePath "${X_PREFIX_PATH}/lib/modules" # FontPath "unix/:7100" # local font server FontPath "/usr/X11R6/lib/X11/fonts/misc:unscaled" FontPath "/usr/X11R6/lib/X11/fonts/cyrillic:unscaled" FontPath "/usr/X11R6/lib/X11/fonts/100dpi:unscaled" FontPath "/usr/X11R6/lib/X11/fonts/75dpi:unscaled" FontPath "/usr/X11R6/lib/X11/fonts/Speedo" FontPath "/usr/X11R6/lib/X11/fonts/TrueType" FontPath "/usr/X11R6/lib/X11/fonts/misc" FontPath "/usr/X11R6/lib/X11/fonts/cyrillic" FontPath "/usr/X11R6/lib/X11/fonts/100dpi" FontPath "/usr/X11R6/lib/X11/fonts/75dpi" FontPath "/usr/X11R6/lib/X11/fonts/Type1" EndSection Section "ServerFlags" Option "DontZoom" "true" Option "AllowMouseOpenFail" "true" EndSection END-CONFIG-FILE # --- make keyboard input section if [ "${CONF_KEYB_EXTRA3}" = "" ] ; then if [ "${CONF_KEYB_LAYOUT}" = us ] ; then KEYB_KEYS=pc101 else KEYB_KEYS=pc102 fi else if [ "${CONF_KEYB_LAYOUT}" = us ] ; then KEYB_KEYS=pc104 else KEYB_KEYS=pc105 fi fi ${CMD_LOG_IF_DEBUG} "KEYB_KEYS=${KEYB_KEYS}" echo >> "${SYS_X_CONFFILE}" cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Section "InputDevice" Identifier "Keyboard0" Driver "keyboard" Option "XkbRules" "xfree86" Option "XkbModel" "${KEYB_KEYS}" Option "XkbLayout" "${CONF_KEYB_LAYOUT}" EndSection END-CONFIG-FILE # --- make mouse input section # - PS/2 mouse, if we have one if ( [ "${CONF_PS2_MOUSE_DEV}" != none ] && \ [ "${CONF_PS2_MOUSE_PROTO}" != none ] ) ; then if [ ! -e "${CONF_PS2_MOUSE_DEV}" ] ; then ${CMD_ERROR} "non existant PS/2 mouse device" \ "\"${CONF_PS2_MOUSE_DEV}\", abborting ..." >&2 ${CMD_LOG_ERROR} "non existant PS/2 mouse device" \ "\"${CONF_PS2_MOUSE_DEV}\", abborting ..." exit 1 fi echo >> "${SYS_X_CONFFILE}" cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Section "InputDevice" Identifier "MousePS20" Driver "mouse" Option "Device" "${CONF_PS2_MOUSE_DEV}" END-CONFIG-FILE if [ "${CONF_PS2_MOUSE_PROTO}" = imps2 ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Option "Protocol" "ImPS/2" Option "ZAxisMapping" "4 5" END-CONFIG-FILE elif [ "${CONF_PS2_MOUSE_PROTO}" = ps2 ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Option "Protocol" "PS/2" END-CONFIG-FILE elif [ "${CONF_PS2_MOUSE_PROTO}" = ps2scroll ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Option "Protocol" "PS/2" Option "Emulate3Buttons" "on" Option "Emulate3Timeout" "50" Option "EmulateWheel" "on" Option "EmulateWheelButton" "2" END-CONFIG-FILE elif [ "${CONF_PS2_MOUSE_PROTO}" = intelli ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Option "Protocol" "IntelliMouse" Option "ZAxisMapping" "4 5" END-CONFIG-FILE else ${CMD_ERROR} "unknown PS/2 mouse protocol" \ "\"${CONF_PS2_MOUSE_PROTO}\", abborting ..." >&2 ${CMD_LOG_ERROR} "unknown PS/2 mouse protocol" \ "\"${CONF_PS2_MOUSE_PROTO}\", abborting ..." exit 1 fi echo EndSection >> "${SYS_X_CONFFILE}" fi # - USB mouse, if we want to allow one if [ "${CONF_USB_MOUSE_PROTO}" != none ] ; then # while here, install and load kernel modules needed for USB mouse # usbcore is needed for all USB stuff, should be already in, but go safe # input is general infrastructure, basic key/mouse/etc stuff # hid and usbhid are generic 2.4 and 2.6 USB HID key/mouse/etc protocol # mousedev basic input->mouse device for MODULE in usbcore input hid usbhid mousedev ; do # insert them into /etc/modules for after future boots grep ${MODULE} /etc/modules > /dev/null || echo ${MODULE} >> /etc/modules # insert them into the running kernel for this session # use || true so we can try nonexist other kernel version modules # else set -e will nuke this script when we try this grep "^${MODULE}" /proc/modules > /dev/null || \ modprobe ${MODULE} 2> /dev/null || true done # and while here, fix up device node for USB mouse if [ ! -c /dev/input/mice ]; then if [ -e /dev/input/mice ]; then ${CMD_FATAL} "/dev/input/mice is already being used for something" \ "else, can not make node for USB mouse, abborting ..." >&2 ${CMD_LOG_FATAL} "/dev/input/mice is already being used for something" \ "else, can not make node for USB mouse, abborting ..." exit 1 fi mkdir -p /dev/input mknod /dev/input/mice c 13 63 fi echo >> "${SYS_X_CONFFILE}" cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Section "InputDevice" Identifier "MouseUSB0" Driver "mouse" Option "Device" "/dev/input/mice" END-CONFIG-FILE if [ "${CONF_USB_MOUSE_PROTO}" = imps2 ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Option "Protocol" "ImPS/2" Option "ZAxisMapping" "4 5" END-CONFIG-FILE elif [ "${CONF_USB_MOUSE_PROTO}" = ps2 ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Option "Protocol" "PS/2" END-CONFIG-FILE elif [ "${CONF_USB_MOUSE_PROTO}" = ps2scroll ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Option "Protocol" "PS/2" Option "Emulate3Buttons" "on" Option "Emulate3Timeout" "50" Option "EmulateWheel" "on" Option "EmulateWheelButton" "2" END-CONFIG-FILE else ${CMD_ERROR} "unknown USB mouse protocol" \ "\"${CONF_USB_MOUSE_PROTO}\", abborting ..." >&2 ${CMD_LOG_ERROR} "unknown USB mouse protocol" \ "\"${CONF_USB_MOUSE_PROTO}\", abborting ..." exit 1 fi echo EndSection >> "${SYS_X_CONFFILE}" fi # --- make monitor info section ${CMD_LOG_IF_DEBUG} "SYS_HOR_MIN=${SYS_HOR_MIN} CONF_HOR_MAX=${CONF_HOR_MAX}" \ "SYS_VER_MIN=${SYS_VER_MIN} CONF_VER_MAX=${CONF_VER_MAX}" echo >> "${SYS_X_CONFFILE}" cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Section "Monitor" Identifier "Monitor0" HorizSync ${SYS_HOR_MIN} - ${CONF_HOR_MAX} VertRefresh ${SYS_VER_MIN} - ${CONF_VER_MAX} Option "DPMS" END-CONFIG-FILE if [ "`echo "${CONF_DISPSIZE}" | tr -d ' '`" != "" ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE DisplaySize ${CONF_DISPSIZE} END-CONFIG-FILE fi echo EndSection >> "${SYS_X_CONFFILE}" if [ "${CONF_DUAL}" != none ] ; then # duplicate the monitor section, with 0 -> 1 echo >> "${SYS_X_CONFFILE}" sed -ne '/Section "Monitor"/,/EndSection/p' "${SYS_X_CONFFILE}" | \ sed -e 's/Monitor0/Monitor1/' > "${SYS_X_CONFFILE}.mon1" cat "${SYS_X_CONFFILE}.mon1" >> "${SYS_X_CONFFILE}" rm "${SYS_X_CONFFILE}.mon1" fi # --- make device settings section # auto-identify what card we have, from PCI ID PCI_ID="`lspci -n | sed 's/Class //' | \ awk '$2=="0300:"||$2=="0380:" { print $3 }' | head -1`" # translate to our internal device/card/parameter-set name # get rid of comments and empty lines (may be emptied comment lines) DEVICE_TYPE="`cut -f 1 -d '#' << END-PCI_ID-LIST | \ grep -v '^ *$' | grep "^${PCI_ID}" | awk '{ print $2 }' 1002:4750 ati # ATI 3D Rage Pro 215GP 1002:4752 ati # ATI Rage XL 1002:4756 ati # ATI 3D Rage IIC 215IIC [Mach64 GT IIC] 1002:4c57 radeon # ATI Radeon Mobility M7 LW [Radeon Mobility 7500] 1002:4c66 radeon # ATI Radeon R250 Lf [Radeon Mobility 9000 M9] 1002:5046 ati # ATI Rage 128 PF/PRO AGP 4x TMDS 1002:5159 radeon # ATI Radeon RV100 QY [Radeon 7000/VE] 1002:5246 ati # ATI Rage 128 RF/SG AGP 1002:5940 fglrx # ATI RV280 [Radeon 9200 PRO] (Secondary) 1002:5960 fglrx # ATI RV280 [Radeon 9200 PRO] 1014:0170 vesa # IBM GXT6000P Graphics Adapter 102b:0519 mga # Matrox MGA 2064W [Millennium] 102b:051b mga # Matrox MGA 2164W [Millennium II] 102b:0520 mga # Matrox MGA G200 102b:0521 mga # Matrox MGA G200 AGP 102b:0525 mga # Matrox MGA G400 AGP 102b:2527 mga # Matrox MGA G550 AGP 104c:3d07 ti # TI TVP4020 [Permedia 2] 10de:0110 nv # nVidia NV11 [GeForce2 MX/MX 400] 10de:0161 nvidia # nVidia NV44 [GeForce 6200 TurboCache(TM)] 10de:0175 nv # nVidia NV17 [GeForce4 420 Go] (Toshiba) 10de:01f0 nv # nVidia NV18 [GeForce4 MX - nForce GPU] (Shuttle on-board) 10de:0322 nvidia # nVidia NV34 [GeForce FX 5200] 10de:0393 nvidia # nVidia G70 [GeForce 7300 GT] 15ad:0405 vmware # VMware [VMWare SVGA II] PCI Display Adapter 5333:8811 s3 # S3 86c764/765 [Trio32/64/64V+] 8086:1132 i810 # Intel 82815 CGC [Chipset Graphics Controller] (i810) 8086:2562 i810 # Intel 82845G/GL[Brookdale-G]/GE Chipset I G D (i810) #8086:2582 i810 # Intel 82915G Graphics Controller (rev 04) 8086:2582 vesa # Intel 82915G Graphics Controller (rev 04) END-PCI_ID-LIST`" if [ "${CONF_DEVICE_TYPE}" != "" ] ; then # allow config to force an device type, for unknown or exeptional cases # used to manually force usage of binary drivers, never automatic DEVICE_TYPE="${CONF_DEVICE_TYPE}" fi if [ "${DEVICE_TYPE}" = "" ] ; then ${CMD_WARNING} "unknown video card PCI ID ${PCI_ID}," \ "falling back to vesa mode ..." >&2 ${CMD_LOG_WARNING} "unknown video card PCI ID ${PCI_ID}," \ "falling back to vesa mode ..." DEVICE_TYPE=vesa fi ${CMD_LOG_IF_DEBUG} "DEVICE_TYPE=${DEVICE_TYPE}" echo >> "${SYS_X_CONFFILE}" cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Section "Device" Identifier "Device0" END-CONFIG-FILE if [ "${DEVICE_TYPE}" = ati ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Driver "ati" VendorName "ATI" BoardName "ATI Rage" END-CONFIG-FILE elif [ "${DEVICE_TYPE}" = fglrx ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Driver "fglrx" VendorName "ATI" BoardName "ATI Radeon Closed Binary" END-CONFIG-FILE elif [ "${DEVICE_TYPE}" = i810 ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Driver "i810" VendorName "Intel" BoardName "OnBoard i810" VideoRam 16384 Option "XvMCSurfaces" "6" Option "AGPMode" "1" END-CONFIG-FILE elif [ "${DEVICE_TYPE}" = mga ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Driver "mga" VendorName "Matrox" BoardName "MGA" Option "OverclockMem" "true" Option "Overlay" "true" END-CONFIG-FILE elif [ "${DEVICE_TYPE}" = nv ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Driver "nv" VendorName "nVidia" BoardName "nVidia Free" END-CONFIG-FILE elif [ "${DEVICE_TYPE}" = nvidia ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Driver "nvidia" VendorName "nVidia" BoardName "nVidia Closed Binary" END-CONFIG-FILE elif [ "${DEVICE_TYPE}" = radeon ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Driver "radeon" VendorName "ATI" BoardName "ATI Radeon Free" END-CONFIG-FILE elif [ "${DEVICE_TYPE}" = s3 ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Driver "s3" VendorName "S3" BoardName "Trio32/64" END-CONFIG-FILE elif [ "${DEVICE_TYPE}" = ti ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Driver "glint" VendorName "Texas Instruments" BoardName "Permedia 2" END-CONFIG-FILE elif [ "${DEVICE_TYPE}" = vesa ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Driver "vesa" VendorName "Unknown" BoardName "Unknown using VESA" END-CONFIG-FILE elif [ "${DEVICE_TYPE}" = vmware ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Driver "vmware" VendorName "VMware" BoardName "VMware" # see vmware(4) #Option "HWcursor" "false" #Option "NoAccel" "false" END-CONFIG-FILE else ${CMD_FATAL} "unknown device type \"${DEVICE_TYPE}\", abborting ..." >&2 ${CMD_LOG_FATAL} "unknown device type \"${DEVICE_TYPE}\", abborting ..." exit 1 fi for TEST_DEVICE in ati fglrx i810 mga nv nvidia nvidia-free radeon s3 ti ; do if [ "${DEVICE_TYPE}" = ${TEST_DEVICE} ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Option "SWcursor" "true" Option "HWcursor" "false" Option "DPMS" "true" END-CONFIG-FILE fi done if [ "${CONF_BUS_ID}" != "" ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE BusID "${CONF_BUS_ID}" END-CONFIG-FILE fi if [ "${CONF_DUAL}" != none ] ; then if [ "${CONF_BUS_ID}" = "" ] ; then ${CMD_ERROR} "dualhead display selected but no CONF_BusID given," \ "abborting ..." >&2 ${CMD_LOG_ERROR} "dualhead display selected but no CONF_BusID given," \ "abborting ..." exit 1 fi cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Screen 0 END-CONFIG-FILE fi echo EndSection >> "${SYS_X_CONFFILE}" if [ "${CONF_DUAL}" != none ] ; then # duplicate the device section, with 0 -> 1 echo >> "${SYS_X_CONFFILE}" sed -ne '/Section "Device"/,/EndSection/p' "${SYS_X_CONFFILE}" | \ sed -e 's/Device0/Device1/' | \ sed -e '/Screen/s/0/1/' > "${SYS_X_CONFFILE}.dev1" cat "${SYS_X_CONFFILE}.dev1" >> "${SYS_X_CONFFILE}" rm "${SYS_X_CONFFILE}.dev1" fi # --- make screen settings section if [ "${CONF_RESOLUTION}" = "" ] ; then CONF_RESOLUTION=1024x768 fi if [ "${CONF_DEPTH}" = "" ] ; then CONF_DEPTH=24 fi for TEST_DEVICE in fglrx mga nv nvidia radeon s3 ti ; do if [ "${DEVICE_TYPE}" = ${TEST_DEVICE} ] ; then NEED_FB32=true fi done ${CMD_LOG_IF_DEBUG} "CONF_RESOLUTION=${CONF_RESOLUTION}" \ "CONF_DEPTH=${CONF_DEPTH} NEED_FB32=${NEED_FB32}" echo >> "${SYS_X_CONFFILE}" cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Section "Screen" Identifier "Screen0" Device "Device0" Monitor "Monitor0" DefaultDepth ${CONF_DEPTH} END-CONFIG-FILE if [ "${NEED_FB32}" != "" ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE DefaultFbBpp 32 END-CONFIG-FILE fi cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE SubSection "Display" Depth ${CONF_DEPTH} Modes "${CONF_RESOLUTION}" EndSubSection EndSection END-CONFIG-FILE if [ "${CONF_DUAL}" != none ] ; then # duplicate the screen section, with 0 -> 1 echo >> "${SYS_X_CONFFILE}" sed -ne '/Section "Screen"/,/EndSection/p' "${SYS_X_CONFFILE}" | \ sed -e 's/Screen0/Screen1/' | \ sed -e 's/Device0/Device1/' | \ sed -e 's/Monitor0/Monitor1/' > "${SYS_X_CONFFILE}.dev1" cat "${SYS_X_CONFFILE}.dev1" >> "${SYS_X_CONFFILE}" rm "${SYS_X_CONFFILE}.dev1" fi # --- make ending section echo >> "${SYS_X_CONFFILE}" cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Section "ServerLayout" Identifier "XFree86 by dphys-config-x" Screen 0 "Screen0" 0 0 END-CONFIG-FILE if [ "${CONF_DUAL}" != none ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Screen 1 "Screen1" RightOf "Screen0" END-CONFIG-FILE fi cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE InputDevice "Keyboard0" "CoreKeyboard" END-CONFIG-FILE # on some systems enabling PS/2 mouse with only an USB mouse connected # crashes the PS/2 controller, so losing PS/2 keyboard access if ( [ "${CONF_PS2_MOUSE_DEV}" != none ] && \ [ "${CONF_PS2_MOUSE_PROTO}" != none ] ) ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE InputDevice "MousePS20" "CorePointer" END-CONFIG-FILE # max be no USB mouse, that is allowed if PS/2 if [ "${CONF_USB_MOUSE_PROTO}" != none ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE InputDevice "MouseUSB0" "SendCoreEvents" END-CONFIG-FILE fi else # if no PS/2 then no USB is most likely wrong, complain but continue if [ "${CONF_USB_MOUSE_PROTO}" != none ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE InputDevice "MouseUSB0" "CorePointer" END-CONFIG-FILE else ${CMD_WARNING} "no mouse chosen at all, both PS/2 and USB set to none" >&2 ${CMD_LOG_WARNING} "no mouse chosen at all, both PS/2 and USB set to none" fi fi if [ "${CONF_DUAL}" = xine ] ; then cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE Option "Xinerama" "on" END-CONFIG-FILE fi echo EndSection >> "${SYS_X_CONFFILE}" # --- finish off ${CMD_LOG_IF_DONE} "has generated/replaced ${SYS_X_CONFFILE}" exit 0 dphys-config/site.example/local/sbin/dphys-config-altern-wwwbrowser0000664000175500017550000000265510513463505024607 0ustar neilneil#!/bin/sh # /usr/local/sbin/dphys-config-altern-wwwbrowser - set /etc/alternatives/* # author Neil Franklin, last modification 2006.10.12 # copyright ETH Zuerich Physics Departement, # use under either modified/non-advertising BSD or GPL license # this script is called by dphys-config, once on each install/update # no parameters or env vars for this script # it requires in /etc/dphys-config.list 1 line: # local/sbin/dphys-config-altern-wwwbrowser:/usr/:chmod 755 {}; {} # this will only work on Debian, as /etc/alternatives/* is Debian specific set -e # get ready to work # /usr/local added for FreeBSD, because their ports end up in there PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin export PATH # --- main stuff if [ -x /usr/bin/mozilla-firefox ] ; then update-alternatives --set x-www-browser /usr/bin/mozilla-firefox #update-alternatives --list x-www-browser | nl | \ # grep /firefox | awk '{print $1}' | \ # update-alternatives --config x-www-browser > /dev/null else MISSING_PACKAGE=yes fi # --- avoid problem with not running on install, because packages not yet here if [ "${MISSING_PACKAGE}" = yes ] ; then # remove this script to force rerun and reinstall on next dphys-config run # should happen after the reboot directly after installing all packages rm $0 # this will actually produce warning from dphys-config, but exit 0 is wrong exit 1 fi # --- finish off exit 0 dphys-config/site.example/local/sbin/dphys-config-altern-xcursor0000664000175500017550000000241710513463512024056 0ustar neilneil#!/bin/sh # /usr/local/sbin/dphys-config-altern-xcursor - set /etc/alternatives/* # author Neil Franklin, last modification 2006.10.12 # copyright ETH Zuerich Physics Departement, # use under either modified/non-advertising BSD or GPL license # this script is called by dphys-config, once on each install/update # no parameters or env vars for this script # it requires in /etc/dphys-config.list 1 line: # local/sbin/dphys-config-altern-xcursor:/usr/:chmod 755 {}; {} # this will only work on Debian, as /etc/alternatives/* is Debian specific set -e # get ready to work # /usr/local added for FreeBSD, because their ports end up in there PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin export PATH # --- main stuff if [ -f /etc/X11/cursors/core.theme ] ; then update-alternatives --set x-cursor-theme /etc/X11/cursors/core.theme else MISSING_PACKAGE=yes fi # --- avoid problem with not running on install, because packages not yet here if [ "${MISSING_PACKAGE}" = yes ] ; then # remove this script to force rerun and reinstall on next dphys-config run # should happen after the reboot directly after installing all packages rm $0 # this will actually produce warning from dphys-config, but exit 0 is wrong exit 1 fi # --- finish off exit 0 dphys-config/site.example/local/sbin/dphys-config-altern-xsession0000664000175500017550000000356710513463517024240 0ustar neilneil#!/bin/sh # /usr/local/sbin/dphys-config-altern-xsession - set /etc/alternatives/* # author Neil Franklin, last modification 2006.10.12 # copyright ETH Zuerich Physics Departement, # use under either modified/non-advertising BSD or GPL license # this script is called by dphys-config, once on each install/update # no parameters or env vars for this script # it requires in /etc/dphys-config.list 1 line: # local/sbin/dphys-config-altern-xsession:/usr/:chmod 755 {}; {} # this will only work on Debian, as /etc/alternatives/* is Debian specific set -e # get ready to work # /usr/local added for FreeBSD, because their ports end up in there PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin export PATH # --- main stuff if [ -x /usr/bin/fvwm2 ] ; then # this block taken from old /usr/sbin/dphys-local-x package # possibly /usr/bin/fvwm forgets (or once forgot?) to install itsself here if ! update-alternatives --display x-session-manager | \ grep -q /usr/bin//fvwm > /dev/null ; then update-alternatives --install /usr/bin/x-session-manager \ x-session-manager /usr/bin/fvwm2 99 --slave \ /usr/share/man/man1/x-session-manager.1.gz \ x-session-manager.1.gz /usr/share/man/man1/fvwm2.1.gz fi update-alternatives --set x-session-manager /usr/bin/fvwm2 else # we are doing new installation, dphys-config run before dphys-admin # config files + scripts are being installed, but packaged software missing MISSING_PACKAGE=yes fi # --- avoid problem with not running on install, because packages not yet here if [ "${MISSING_PACKAGE}" = yes ] ; then # remove this script to force rerun and reinstall on next dphys-config run # should happen after the reboot directly after installing all packages rm $0 # this will actually produce warning from dphys-config, but exit 0 is wrong exit 1 fi # --- finish off exit 0 dphys-config/site.example/local/sbin/dphys-config-altern-xterminal0000664000175500017550000000266510513463523024363 0ustar neilneil#!/bin/sh # /usr/local/sbin/dphys-config-altern-xterminal - set /etc/alternatives/* # author Neil Franklin, last modification 2006.10.12 # copyright ETH Zuerich Physics Departement, # use under either modified/non-advertising BSD or GPL license # this script is called by dphys-config, once on each install/update # no parameters or env vars for this script # it requires in /etc/dphys-config.list 1 line: # local/sbin/dphys-config-altern-xterminal:/usr/:chmod 755 {}; {} # this will only work on Debian, as /etc/alternatives/* is Debian specific set -e # get ready to work # /usr/local added for FreeBSD, because their ports end up in there PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin export PATH # --- main stuff if [ -x /usr/X11R6/bin/uxterm ] ; then update-alternatives --set x-terminal-emulator /usr/X11R6/bin/uxterm #update-alternatives --list x-terminal-emulator | nl | \ # grep /uxterm | awk '{print $1}' | \ # update-alternatives --config x-terminal-emulator > /dev/null else MISSING_PACKAGE=yes fi # --- avoid problem with not running on install, because packages not yet here if [ "${MISSING_PACKAGE}" = yes ] ; then # remove this script to force rerun and reinstall on next dphys-config run # should happen after the reboot directly after installing all packages rm $0 # this will actually produce warning from dphys-config, but exit 0 is wrong exit 1 fi # --- finish off exit 0