Shell Scripts for ePages on Linux | → 6.17.48 | Created: 6.13.0; Updated: 6.17.37 |
This document is intended as a reference for system administrators who manage the ePages installation on the UNIX level. The inaccurate usage of the functions and scripts as described below may damage the ePages system seriously. For any questions, first ask the ePages support department.
Table of Contents |
ePages services are started/stopped by the run script /etc/init.d/epages6.
Each ePages Java service has its own run script:
/etc/init.d/epagesj restart /etc/init.d/epagesj status
status has following return codes:
At boot time, /etc/init.d/epages6 starts all ePages services. If you don't want ePages to start at boot time, run following command:
chkconfig --del epages6
After running this command, if you want ePages to start at boot time again, run following command:
chkconfig --add epages6
The same holds for the epages Java services mentioned above.
/etc/init.d/epages6 starts/stops all ePages services existing on the machine where it is executed. If ePages services are distributed over various servers, each server only handles it's own part of the services. Hence, if you want to start/stop all ePages services manually, run /etc/init.d/epages6 on all involved servers.
Running /etc/init.d/epages6 without parameters shows you the usage:
# /etc/init.d/epages6 Usage: EPAGES_IGNORE='[services]' /etc/init.d/epages6 ARGUMENT Arguments (use one of them): start : start database, web server and epages services stop : stop database, web server and epages services show : show all running epages processes start_httpd [arg] : start web server (httpd-epages) (with arg, one of:) close : close all outside connections open : open all outside connections reload : reload configuration graceful: graceful restart stop_httpd : stop web server (httpd-epages) start_db : start database server stop_db : stop database server start_service : start epages application server (epagesService) stop_service : stop epages application server (epagesService) restart_perl : restart epages application server (perl) start_rr : start epages request router (RequestRouter) stop_rr : stop epages request router (RequestRouter) start_cron : start epages cron jobs stop_cron : stop epages cron jobs show_cron : show all epages cron jobs perm {where} : sets UNIX user/group/mode {where} : admin stores webroot static apache perl cartridges mysql all EPAGES_IGNORE='[services]' : space separated list of services not to start/stop [services] : cron appsrv reqsrv dbsrv websrv
If you want to (re)start all ePages services, run:
/etc/init.d/epages6 start
If you want to (re)start all (but some) ePages services, run:
EPAGES_IGNORE='[services]' /etc/init.d/epages6 start
where [services] is a space-separated list of the services to ignore (use one or more of: cron appsrv reqsrv dbsrv websrv).
You may use as well EPAGES_IGNORE= for stopping all (but some) ePages services:
EPAGES_IGNORE='[services]' /etc/init.d/epages6 stop
Show all running ePages services:
/etc/init.d/epages6 show
(Re)start the ePages cronjobs (ignoring other ePages services) by:
/etc/init.d/epages6 start_cron
Stop the ePages cronjobs (ignoring other ePages services) by:
/etc/init.d/epages6 stop_cron
Show all installed ePages cronjobs by (see an example output with explanation in section wrapScheduler.sh):
/etc/init.d/epages6 show_cron
(Re)start just the ePages database server (MySQL) (ignoring other ePages services) by:
/etc/init.d/epages6 start_db
Stop just the ePages database server (MySQL) (ignoring other ePages services) by:
/etc/init.d/epages6 stop_db
(Re)start just the ePages request router (ignoring other ePages services) by:
/etc/init.d/epages6 start_rr
Stop just the ePages request router (ignoring other ePages services) by:
/etc/init.d/epages6 stop_rr
(Re)start just the ePages application server (Perl) (ignoring other ePages services) by:
/etc/init.d/epages6 start_service
Stop just the ePages application server (Perl) (ignoring other ePages services) by:
/etc/init.d/epages6 stop_service
The following command restarts the ePages application server gracefully. This differs from a normal restart in that the Perl processes are not aborted, but finished and restarted.
/etc/init.d/epages6 restart_perl
(Re)start just the ePages web server (httpd) (ignoring other ePages services) by:
/etc/init.d/epages6 start_httpd
Stop just the ePages web server (httpd) (ignoring other ePages services) by:
/etc/init.d/epages6 stop_httpd
/etc/init.d/epages6 start_httpd may have an additional parameter:
Following command closes outside connections and (re)starts the web server:
/etc/init.d/epages6 start_httpd close
After running this command, connections from outside result in 503 (Service Temporary Unavailable).
Environment variable APACHE_CLOSED_EXCEPT in file /etc/apache2-epages/envvars defines from what hosts internal connections are allowed after closing outside connections.
Re-open your website for outside connections by:
/etc/init.d/epages6 start_httpd open
/etc/init.d/epages6 also can be used to correct UNIX permissions of ePages files (chown/chmod) :
/etc/init.d/epages6 perm all -f -d /my/epages
/etc/init.d/epages6 as well as other shell scripts use variables and functions as defined in:
If you want to use the ePages environment variables and functions in a shell, source the file /etc/default/epages6:
. /etc/default/epages6
Environment variables in the variable lists below are marked as follows:
/etc/default/epages6 includes additionally /etc/default/epages6.local (if file exists). This can be used in a distributed environment where there is a common /etc/default/epages6 but some variable values differ from host to host. You may redefine all variables mentioned in /etc/default/epages6 in /etc/default/epages6.local that do not describe file paths as well as EPAGES (the only path variable). The enviroment variable list below marks all variables that may redefined in /etc/default/epages6.local as 'local'.
/etc/sysconfig/epages6 contains variables that are used while installing ePages. Such installation variable names always start with EPAGES_INSTALL_. Replacing EPAGES_INSTALL_ by EPAGES_, for some of these variables you'll find the corresponding variable in /etc/default/epages6. See documentation in /etc/sysconfig/epages6 itself.
The only variable that is used from /etc/sysconfig/epages6 by the running ePages is EPAGES_INSTALL_RUN_SCRIPT. The variable is used in function etc_default (see below) as a fallback to guess the name of the epages project (default: epages6).
The project name is used for naming the source script /etc/default/EPAGES_PROJECT and the run script /etc/init.d/EPAGES_PROJECT. Default values are /etc/default/epages6 and /etc/init.d/epages6.
The name of /etc/sysconfig/epages6 is fix.
EPAGES_KERNEL Linux Distribution 2.6.32r Red Hat Enterprise Linux 6 / CentOS 6 3.10.0r Red Hat Enterprise Linux 7 / CentOS 7 3.2.0d Debian 7 3.16.7d Debian 8 2.6.32s SuSE Enterprise 11.1 (or higher)
All ePages shell functions are stored in /var/epages/functions.sh. Provide this functions to your shell by sourcing /etc/default/epages6:
. /etc/default/epages6
If you execute all functions described below with option '-?' you get a short usage message, e.g.:
# . /etc/default/epages6 # show_pids -? [PS_FORMAT=...] show_pids PID_LIST PID_LIST: show processes of space separated list in PS_FORMAT
All functions are used in various ePages shell scripts.
checkpid PID checks /proc/ if PID is running.
Example:
checkpid 1 || echo something is wrong.
get_pidof COMMAND shows all PIDs associated with COMMAND.
Example:
# get_pidof httpd 1738 1736 1735 1733 1732 1731 1730 1729 1723
get_pidfile [-p pidfile] [/path/to/program] checks if PID in pidfile (default: /var/run/program.pid) is running.
# get_pidfile httpd && echo is running 1723 1729 1730 1731 1732 1733 1735 1736 1738 is running
# get_pidfile -p /var/run/httpd.pid && echo is running 1723 1729 1730 1731 1732 1733 1735 1736 1738 is running
get_pidfile returns:
get_pids returns a space separated PID list either for the specified command (using pgrep -f) or for the specified process ID (using ps -p).
# get_pids -? get_pids {-c COMMAND | -p PID} [-u USER] [-C] [-P] -c COMMAND: returns space separated PID list for command -p PID: returns space separated PID list for PID -u USER: returns only processes of USER -C: add child processes to PID list -P: add parent process to PID list
Examples:
# get_pids -c mysqld_safe 6939 # get_pids -c mysqld_safe -C 6939 6989 # PS_FORMAT=user,pid,ppid,args show_pids $(get_pids -c mysqld_safe -C) USER PID PPID COMMAND root 6939 1 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --user=mysql mysql 6989 6939 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --socket=/var/lib/mysql/mysql.sock # get_pids -p 6670 6670 # get_pids -p 6670 -C 6670 6673 6674 6675 6676 6677 6678 6679 6680 # PS_FORMAT=user,pid,ppid,args show_pids $(get_pids -p 6670 -C) USER PID PPID COMMAND root 6670 1 /usr/sbin/httpd -DSSL apache 6673 6670 /usr/sbin/httpd -DSSL apache 6674 6670 /usr/sbin/httpd -DSSL apache 6675 6670 /usr/sbin/httpd -DSSL apache 6676 6670 /usr/sbin/httpd -DSSL
show_pids PID_LIST shows processes of the space separated list PID_LIST in a specific format defined by PS_FORMAT. PS_FORMAT defaults to user,pid,ppid,nice,pri,pcpu,time,pmem,vsz,etime,args, user-defined formats are described in 'man ps'.
Example:
show_pids $(get_pids -p 6670 -C) USER PID PPID NI PRI %CPU TIME %MEM VSZ ELAPSED COMMAND root 6670 1 0 21 0.0 00:00:09 0.4 11968 23:11:46 /usr/sbin/httpd -DSSL apache 6673 6670 0 15 0.0 00:00:00 0.2 12100 23:11:46 /usr/sbin/httpd -DSSL apache 6674 6670 0 14 0.0 00:00:00 0.2 12100 23:11:46 /usr/sbin/httpd -DSSL apache 6675 6670 0 14 0.0 00:00:00 0.2 12100 23:11:46 /usr/sbin/httpd -DSSL apache 6676 6670 0 14 0.0 00:00:00 0.2 12100 23:11:46 /usr/sbin/httpd -DSSL
softkill PID_LIST stops all processes defined by the separated process list PID_LIST. It first tries to terminate the processes by sending a TERM signal. Then, all processes that can't be stopped by TERM are killed by sending a KILL signal.
# softkill -? softkill PID_LIST PID_LIST: space separated list of processes to kill; first try TERM, then KILL
show_daemon DAEMON shows the daemon process of DAEMON (as defined with /etc/init.d/DAEMON) in a specific format defined by PS_FORMAT, see show_pids. show_daemon has no arguments, it returns always only 1 line. show_daemon DAEMON runs /etc/init.d/DAEMON status, so it takes a little longer than get_pids.
Examples:
# show_daemon httpd USER PID PPID NI PRI %CPU TIME %MEM VSZ ELAPSED COMMAND root 6670 1 0 21 0.0 00:00:09 0.4 11968 23:15:44 /usr/sbin/httpd -DSSL # PS_FORMAT=pid= show_daemon httpd 6670
run_cron {start|stop|show} [USER] starts/stops/shows epages cron processes (all or just for USER).
Example:
# run_cron stop ep_appl Stopping ep_appl cron jobs... 10 5 * * * ep_appl /srv/epages/eproot/bin/wrapScheduler.sh MySQLFullBackup epages6 10 6 * * 6 ep_appl /srv/epages/eproot/bin/wrapScheduler.sh MySQLUpdateStatistics epages6 32 * * * * ep_appl /srv/epages/eproot/bin/wrapScheduler.sh appserver-RotateLogs epages6 crond (pid 6918) is running... # run_cron stop ep_appl Stopping ep_appl cron jobs... crond (pid 6918) is running...
run_cron is used by /etc/init.d/epages6.
rs_show [return code] prints '[OK]' or '[FAILED]' on screen and returns return code (default: $?). This functions is useful only in run scripts.
rs_status [-p pidfile] [-l lockfile] [program] shows the status of the program (or PID in pidfile).
Example:
# rs_status httpd httpd (pid 1723 1729 1730 1731 1732 1733 1735 1736 1738) is running...
rs_status returns:
rs_start [-bg] [-q|-Q] [-l logfile] [-u user] [-p pidfile] {program} starts program in run script.
Options:
rs_stop [-p pidfile] [-d delay] [program [-signal]] stops program in run script.
Options:
pathmunge shortens directory paths (semicolon-separated strings as PATH or LD_LIBRARY_PATH) so that in the resulting path each directory occurs only once (in the first occurrence, latter occurrences are deleted) and only if it exists.
With one argument, it just trims the path. With two arguments, all directories in the first argument are prepended to the second argument only if they not already exist in the second argument:
# pathmunge -? pathmunge [SOURCE_PATH] TARGET_PATH TARGET_PATH: semicolon-separated path to change SOURCE_PATH: semicolon-separated path to prepend $(pathmunge /usr/bin:/bin:/usr/bin) == /usr/bin:/bin $(pathmunge /usr/bin /bin:/usr/bin) == /bin:/usr/bin $(pathmunge /usr/bin /bin) == /usr/bin:/bin
jre_home returns the best guess for the path to JRE directory, depending on the operating system/version and typical places where the JRE directory is expected to be. Typically, the value of jre_home is used to set the ePages environment variable EPAGES_JAVA.
Example:
# jre_home /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre
Used in /etc/default/epages6:
EPAGES_JAVA="$(jre_home)"
java_executable returns the best guess for the path to the java executable file. Typically, the value of java_executable is used to set the ePages environment variable JAVACMD.
Example:
# java_executable /usr/java/latest/jre/bin/java
Used in /etc/default/epages6:
JAVACMD="$(java_executable)"
etc_default PREFIX returns the best guess for the ePages environment variables file (default: /etc/default/epages6), depending on:
# etc_default FOOBAR /etc/default/epages6
mysqld_name returns the name of the MySQL server (mysql or mysqld) if the RPM package epages-mysqld is installed. Otherwise it returns nothing.
Example:
# mysqld_name mysqld
mysqld_name is used by /etc/init.d/epages6 in order to decide if the MySQL server is a ePages MySQL server. If so, /etc/init.d/epages6 start_db (resp. stop_db) starts/stops the installed MySQL server. Otherwise, /etc/init.d/epages6 start_db does nothing.
httpd_name returns the name of the Apache httpd server provided by the operating system (httpd or apache2) if installed. Otherwise returns nothing.
Example:
# httpd_name httpd
httpd_name is used by httpd_confd.
httpd_confd returns the Apache httpd server configuration directory (depending on the server provided by the operating system) where ePages configuration files should be stored. If the directory exists, the directory is returned, otherwise nothing.
httpd_confd epages returns the Apache httpd server configuration directory only if the ePages configuration file zzz-epages-httpd.conf exists inside.
Example:
# httpd_confd /etc/httpd/conf.d
Result: directory (where to put ePages configuration files) /etc/httpd/conf.d exists.
Example:
# httpd_confd epages /etc/httpd/conf.d
Result: ePages configuration file /etc/httpd/conf.d/zzz-epages-httpd.conf exists.
httpd_confd epages is used by /etc/init.d/epages6 in order to decide if the httpd server is a ePages httpd server. If so, /etc/init.d/epages6 start_httpd (resp. stop_httpd) starts/stops the installed httpd server. Otherwise, /etc/init.d/epages6 start_httpd does nothing.
. /etc/default/epages6 adds ePages directories to the end of PATH:
# grep PATH= /var/epages/functions.sh PATH=$(pathmunge "$PATH:$EPAGES_PERL/bin:$HTTPD_ROOT/bin")
ePages directories cannot be put in the beginning of PATH because then the operating system would use ePages perl ($PERL), not its own perl. The operating system has a lot of perl scripts that rely on the operating system perl; those scripts would not work anymore.
The same holds for LD_LIBRARY_PATH. ePages libraries and operating system libraries may differ slightly (e.g. in the version). We cannot add libraries that are provided by ePages to this path, this would lead to conflicts in binary files.
On the other hand, ePages scripts need ePages perl. Thatswhy there are the two functions epages_path resp. epages_libs that return PATH resp. LD_LIBRARY_PATH for the ePages environment:
# epages_libs -? epages_libs prepends LD_LIBRARY_PATH with epages libdirs # epages_libs /srv/epages/eproot/Perl/lib32/2.6.18r:/srv/epages/eproot/Perl/lib32/ssl:/srv/epages/eproot/Perl/bin:/lib:/lib:/usr/lib # epages_path -? epages_path prepends PATH with EPAGES_PERL/bin # epages_path /srv/epages/eproot/Perl/bin:/sbin:/bin:/usr/sbin:/usr/bin
epages_libs and epages_path are used in $PERL, $EPAGES_APACHE/bin/httpd.sh and /etc/init.d/epages6:
# cd /srv/epages/eproot # grep epages_libs */bin/* /etc/init.d/epages6 Perl/bin/perl:LD_LIBRARY_PATH=$(epages_libs) Apache/bin/httpd.sh:LD_LIBRARY_PATH=$(epages_libs) /etc/init.d/epages6:PATH="$(epages_path)" LD_LIBRARY_PATH="$(epages_libs)" "$EP_HTTPD" -f "$HTTPD_ROOT"/conf/httpd.conf ...
column COL sets start column COL for echo.
Example:
# echo "123$(column 2)x" 1x3 # echo "123$(column 3)x" 12x
em OPTIONS STRING (em for emphasize) echoes a colored STRING (depending on the OPTIONS) on the terminal, if the environment variable TERM is set and not set to raw or dumb. Otherwise only the STRING is echoed.
# em -? em [OPTIONS] [COLOR] [BGCOLOR] "STRING" OPTIONS: -s(trong) -d(im) -u(nderline) -i(nverse) -h(idden) -x(out) COLOR: -L(black) -R(ed) -G(reen) -B(lue) -Y(ellow) -P(ink) -C(yan) -W(hite) BGCOLOR: -l(black) -r(ed) -g(reen) -b(lue) -y(ellow) -p(ink) -c(yan) -w(hite)
Example (first string is blue, bold, with background color cyan; second string is red, crossed out, and inverse):
echo "$(em -B -c -s first) $(em -R -x -i second)"
Following shorthand functions exist:
echo "$(G this is green text)"
timeout_test does a file test as /usr/bin/test would do. The differnce is that the test stops after EPAGES_TIMEOUT seconds. This is useful for example if the file to test is stored on an NFS server mount which is not reachable anymore. /usr/bin/test would never return.
timeout_test uses exec.sh, see below. If EPAGES_TEST=timeout_test is set in /etc/default/epages6 then test is aliased to timeout_test in /var/epages/functions.sh:
[[ $EPAGES_TEST = timeout_test ]] && alias test=timeout_test
Use timeout_test as you would use /usr/bin/test for testing files:
# timeout_test -? timeout_test FILE_TEST_OPERATOR TEST_OBJECT FILE_TEST_OPERATOR: see 'man test', e.g. one of: -f -d -e -x TEST_OBJECT: file/directory to test
Example:
timeout_test -x /nfs/bin/some/executable && echo "file is executable"
ipcrm_user USER runs ipcrm -m and ipcrm -s for all processes owned by a specific USER (see 'man ipcrm').
Examples (from /etc/init.d/epages6):
ipcrm_user $EPAGES_WEBUSER ipcrm_user $EPAGES_APPUSER
started_by_rpm PID returns 0 (success) if one of ancestors of process ID PID is rpm/yum/zypper, otherwise 1 (failure).
Sometimes a shell script must know, if it executed by rpm or on the command line. For example, if the script is executed by rpm, it cannot update RPM packages by itself (this would lead to a conflict).
Example (from patch Makefile.PL):
started_by_rpm $$ || yum -y install graphviz
check_nfs returns 0 (success) if the NFS client process rpc.statd is running, else 1 (failure). The running NFS client process rpc.statd is necessary for mounting ePages ahres in a distributed installation.
If the environment variable CHECK_NFS=1 is set (in /etc/default/epages6), /etc/init.d/epages6 always executes check_nfs when starting (any) services. If check_nfs fails, services are not started:
# grep check_nfs /etc/init.d/epages6 start*) [ -n "$CHECK_NFS" ] && { check_nfs || exit $?; } ;;
set_selinux4epages sets SELinux file context for ePages files if:
$EPAGES/bin/se-file-context.sh --set $PERL_CGI
where $PERL_CGI is set to --perl-cgi if EPAGES_ENABLE_PERL_CGI is set (see Operating System Variables).
set_selinux4epages is executed when starting ePages by /etc/init.d/epages6.
See document SELinux Context for ePages Applications.
check_epages_webgroup checks the environment variable EPAGES_WEBGROUP=GROUP_NAME:GROUP_ID as defined in /etc/default/epages6 and returns the GID of the web group:
# check_epages_webgroup -? check_epages_web {*start*/*stop*} EP_DEFAULT EP_DEFAULT: checks (e.g. /etc/default/epages6) for EPAGES_WEBGROUP= setting *start*: add missing UNIX user as defined in EPAGES_WEBGROUP= returns: GID of epages web group
It is only used by /etc/init.d/epages6 and should not be used elsewhere (including the command line):
# grep check_epages_webgroup /etc/init.d/epages6 EPWEBID=$(check_epages_webgroup $1 "$EP_DEFAULT" )
# check_epages_webgroup start /etc/default/epages6 48
my_host {IP/hostname} checks if IP/hostname belongs to host that executes my_host depending on ifconfig, DNS and /etc/hosts.
Examples:
# my_host localhost && echo yow yow # my_host ::1 && echo has IPv6 has IPv6 # echo '172.20.20.20 my_name' >> /etc/hosts # my_host my_name || echo nope nope # ip addr show | awk '/^[[:space:]]*inet/{sub(/\/.*/,"",$2); print $2}' 127.0.0.1 ::1 172.20.50.54 2001:4bd8:2:2:250:56ff:fe00:1199 fe80::250:56ff:fe00:1199 # sed -i 's,172.20.20.20,172.20.50.54,' /etc/hosts # my_host my_name && echo yow yow # host $(hostname) vm.example.com has address 172.20.50.54 # my_host vm.example.com && echo yow yow # my_host 2001:4bd8:2:2:250:56ff:fe00:1199 && echo yow yow
ePages shell scripts are traditionally stored in $EPAGES/bin. This has the drawback that if $EPAGES/bin is NFS mounted and if the NFS server is down, the scripts can't be executed. For this reason, some (newer) shell scripts are stored in /var/epages.
/var/epages/exec.sh runs COMMAND and terminates it by SIGNAL after TIMEOUT (default: ${EPAGES_TIMEOUT:-5}) seconds if it hasn't finished yet:
Usage: /var/epages/exec.sh -c 'COMMAND' [-t TIMEOUT] [-s SIGNAL] Options: -c: command to execute -t: terminate command after TIMEOUT seconds (default: 5) -s: terminate command with SIGNAL (not TRAP,ALRM; default: TERM) Example: time /var/epages/exec.sh -c 'sleep 10' -t 1 -s KILL
The return value of /var/epages/exec.sh is either the return value of the command (if in time), else 127.
The function timeout_test defined in /var/epages/functions.sh uses /var/epages/exec.sh:
/var/epages/exec.sh -c "/usr/bin/test $HOW '$@'"
/var/epages/ini-config.sh processes configuration files in INI format similiar to our perl module DE_EPAGES::Core::API::IniConfig but it is written in awk, not in perl:
# /var/epages/ini-config.sh Usage: ini-config.sh -f file { [-s section] [-k key] } [-v value [-r subst] | -g] [-i] [-p {k|s|ks}] Options: -f: INI file name -s: section (REGEX) as in [section] -k: key (REGEX) as in key= -v: set key to value -r: replace subst (REGEX) with value in key -g: get key value (first occurrence) -i: edit file in place -p: plain key and/or section (do not quote)
Contrary to DE_EPAGES::Core::API::IniConfig, some additional features are added:
# /var/epages/ini-config.sh -f /etc/default/epages6 -k EP_RR -g "$EPAGES/RequestRouter/RequestRouter"
# cat patch/zzz-epages-httpd.conf-patch.ini [RequestHeader unset Range] subst=$ by=<<HERE <IfModule mod_headers.c> RequestHeader unset Range RequestHeader unset Request-Range </IfModule> HERE # /var/epages/ini-config.sh -f patch/zzz-epages-httpd.conf-patch.ini -s 'RequestHeader unset Range' -k by -g <IfModule mod_headers.c> RequestHeader unset Range RequestHeader unset Request-Range </IfModule>
# /var/epages/ini-config.sh -f patch/zzz-epages-httpd.conf-patch.ini -g
# /var/epages/ini-config.sh -f patch/zzz-epages-httpd.conf-patch.ini -s 'RequestHeader unset Range' -g
movelink.sh FILE has as argument a symbolic link. If the file isn't a symbolic link or does not exist at all, movelink.sh does nothing.
If FILE does not end in '.lnk', movelink.sh FILE moves the symlink to FILE.lnk and writes the dereferenced version to FILE:
In distributed installations, after installing the first part of ePages on the first server, you should share installed ePages directories. Then, all other servers of the epages installation may mount those NFS shares before starting the ePages installation to get a common file system base.
This is done by /var/epages/fs-epages.sh. On the first server named FILESERVER share the ePages directories:
# /var/epages/epages-fs.sh -share
On all other servers mount the shares provided by FILESERVER:
# /var/epages/epages-fs.sh -mount FILESERVER
Usage:
# /var/epages/epages-fs.sh Usage: epages-fs.sh { -share | -mount FILESERVER | -unmount | -unshare } Options: -share: share /srv/epages with other hosts -mount: mount /srv/epages from FILESERVER -unmount: unmount /srv/epages -unshare: unshare /srv/epages
For more information on distributed ePages installation see ePages Installation Guide for Linux.
If you installed epages by yum, you may deinstall epages by executing yum groupremove epages.
But this command does not remove files that have changed (or that are not part of a ePages RPM). To remove ePages completely from your server, run /var/epages/delete-epages.sh. The command deletes all ePages RPM packages, files and databases:
# /var/epages/delete-epages.sh Installed ePages RPMs: epages-mysqld-6.12.0-0 epages-appsrv-6.12.0-0 epages-mysql-6.12.2-0 epages-perl-6.12.2-0 epages-patch-6.12.3-0 epages-common-6.12.2-0 epages-requires-2.6.18r-0 epages-release-6.12-0 Do you really want to delete those ePages RPMs? (y/n): n Installed ePages databases: sitedb storedb Do you really want to delete those ePages databases? (y/n): n Installed ePages files: /srv/epages Do you really want to delete all ePages files? (y/n): n
Files outside $EPAGES (default: /srv/epages/eproot) are patched by /var/epages/patch-sh.sh. The script is executed in target update_os both in the patch Makefile.PL:
update_os: patch-sh.sh -d sh
and in DE_EPAGES/Makefile.PL:
update_os: patch-sh.sh -d "$(PATCH_DIR)"/sh
/var/epages/patch-sh.sh should be executed only by those two targets, there is no use to run the command on the command line, ignore it simply.
# /var/epages/patch-sh.sh Usage: EPAGES_PROJECT=epages6 patch-sh.sh -d PATCH_DIR [-R] Options: EPAGES_PROJECT: envvar of the epages project (default: epages6) -d: directory with patch.conf -R: restore
/var/epages/patch-sh.sh reads file PATCH_DIR/patch.conf that contains all information on how to patch files outside $EPAGES.
In the patch, PATCH_DIR is sh/, you'll find this PATCH_DIR in $EPAGES_SHARED/Patches/patch_x_y_z/sh/ (default).
File patch.conf consists of various sections:
# ini-config.sh -f patch.conf -g EPAGES/Apache EPAGES/bin EPAGES/Setup EPAGES/WebAdapter EPAGES_PERL EPAGES_ETC EPAGES_RELEASE ETC_HTTPD_CONFD EPAGES_MYSQLD
Each section shows the path for the new files. For the target patch, the first part (until /) is expanded as environment variable (or to / if not exist); exceptions:
[EPAGES/Apache] BASE=Apache bin/httpd.sh=patch conf/extra/httpd-default.conf.initial=add conf/extra/httpd-default.conf.ini=del conf/extra/httpd-default.conf=patch/httpd-default.conf-patch.ini
Means:
# /var/epages/patch-default.sh Usage: patch-default.sh -s epages6 -t epages6.ept [-i] Options: -s: file to change (e.g.: /etc/default/epages6) -t: new template file (e.g.: /srv/epages/etc/default/epages6.ept) -i: edit file to change in place
/var/epages/patch-file.sh -f FILE -p CONF patches FILE by the rules given in CONF:
# /var/epages/patch-file.sh Usage: patch-file.sh -f file -p patch.ini [-i] Options: -f: file to patch -p: ini file with patch instructions -i: edit file in place
/var/epages/patch-file.sh uses ini-config.sh and is used by patch-sh.sh, e.g. (see example patch.conf in patch-sh.sh / patch-default.sh above):
/var/epages/patch-file.sh -f $EPAGES/Apache/conf/extra/httpd-default.conf -p PATCH_DIR/patch/httpd-default.conf-patch.ini
Each [section] in CONF has two keys: subst and by. Then the rule is that if section does not exist in FILE, substitute subst by by, e.g.:
[ServerTokens Prod] subst=ServerTokens Full by=ServerTokens Prod
means: if ServerTokens Prod does not exist in FILE, substitute ServerTokens Full by ServerTokens Prod.
If you want to delete/shorten a string in the FILE, use a section name that never exist:
[pngwavxml] subst=<FilesMatch .+?\(.+?png\|wav\|xml.*?\).*?> by=<FilesMatch \.>
means: if pngwavxml does not exist in FILE (it won't), substitute regexp
All scheduler scripts (scripts for cron jobs) are stored in $EPAGES/bin.
$EPAGES/bin/DelObsoleteFiles.sh -f 'FILES' -m TIME[dm] DIR deletes files older than TIME matching FILE in DIR:
# $EPAGES/bin/DelObsoleteFiles.sh Usage: DelObsoleteFiles.sh [-t] -f 'FILES' -m TIME[dm] DIR1 DIR2 DIR3... Options: -f FILES : remove files with specific file name (req.) -m TIME[dm] : remove files older than TIME (d - days, m - minutes, req.) -t : do not remove, just test
$EPAGES/bin/DelObsoleteFiles.sh is used in $EPAGES_CONFIG/Scheduler.d/runserver-DelObsoleteMonitor.env:
COMMAND="$EPAGES/bin/DelObsoleteFiles.sh" # search directory/ies for monitor files (separated by ' ') SEARCHDIRS="$EPAGES_STORES/_MONITOR_ $EPAGES_WEBROOT/_MONITOR_" # -f FILES: remove files with specific file name (must be set) FILES="-f '*.html *.response'" # -m TIME: remove files older than TIME[dm] (d:days, m:minutes, must be set) TIME="-m 1d" # what command options? OPTIONS="$FILES $TIME $SEARCHDIRS"
$EPAGES/bin/logfilemgmt.sh rotates log files:
# $EPAGES/bin/logfilemgmt.sh Usage: logfilemgmt.sh [-t] { -c CONF | [OPTIONS] DIR1 DIR2 DIR3... } OPTIONS: -t : do not compress, just test -c CONF : use options as defined in file CONF -s SIZE[ckm] : required size (in bytes, KB, MB) to compress -d DAYS : remove compressed files older than DAYS (w/o: don't remove) -a DIR : move compressed files into archive DIR -e SUFFIX_LIST : compress only files ending in suffix (default: [._]log) -z ZIPPER : use compression instead of 'gz' (allowed: gz,bz2,lzo,zip,Z) -v : verbose output
$EPAGES/bin/logfilemgmt.sh is used in $EPAGES_CONFIG/Scheduler.d/appserver-RotateLogs.env:
COMMAND="$EPAGES/bin/logfilemgmt.sh" # search directory/ies for log files (separated by ' ') SEARCHDIRS="$EPAGES_LOG" # -s SIZE[ckm]: required size (in bytes, KB, MB) to compress SIZE="-s 30m" # -d DAYS: remove compressed files older than DAYS (unset -> don't remove) DAYS= # -a DIR: move compressed files into ARCHIVE directory ARCHIVE="-a $EPAGES_LOG/Archive" # -z ZIPPER: use compression instead of 'gz' (allowed: gz,bz2,lzo,zip,Z) ZIPPER= # what command options? OPTIONS="$SIZE $DAYS $ARCHIVE $ZIPPER $SEARCHDIRS"
Example:
$EPAGES/bin/logfilemgmt.sh -c /export/raid5/share/conf/logfilemgmt.conf
with /export/raid5/share/conf/logfilemgmt.conf (logfilemgmt.sh is executed repeatedly with the arguments of each line):
-s 40m $REPOSITORY_DIR/CVSROOT -s 40m -d 30 -z bz2 /var/log -s 40m -d 30 -z bz2 $BACKUP_LOG_DIR
$EPAGES/bin/SendProgramOutput.sh -a TO [-s SUBJECT] -f FILE is a really simple mail-sender. It sends the contents of FILE to TO (with SUBJECT):
usage: $EPAGES/bin/SendProgramOutput.sh -a ep_appl@localhost [ -s 'Output from Backup.sh' ] -f Backup.log OPTIONS: -a: addressee (e-mail address) (mandatory) -s: e-mail subject (optional) -f: name of file to sent (mandatory)
$EPAGES/bin/SendProgramOutput.sh uses mail resp. mailx to send the mail, sending authorized mails is not possible.
cat $FILE | mail -s $SUBJECT $RECIPIENT
$EPAGES/bin/SendProgramOutput.sh is used by wrapScheduler.sh if no other (more fancy perl) mail script is found. Literally, it is not used anymore.
$EPAGES/bin/epagesScheduler.sh starts/stops/shows ePages schedulers. It is used by the shell function run_cron which itself is used by /etc/init.d/epages6, see Starting/Stopping ePages.
ePages cron jobs may be debugged by adding Debug=1 to the section of the scheduler you want to debug in $EPAGES_CONFIG/Scheduler.conf. Debug shell schedulers defined in $EPAGES_CONFIG/Scheduler.d/*.env by adding DEBUG=1 to the .env file.
ePages schedulers may be debugged while running or while starting/stopping:
wrapScheduler.sh is a wrapper script around the scheduler script itself. wrapScheduler.sh run each ePages scheduler:
# /etc/init.d/epages6 show_cron Showing epages cron jobs... 5,10,15,20,25,30,35,40,45,50,55 * * * * eprunapp /srv/epages/eproot/bin/wrapScheduler.sh ClearTrash epages6 0 4 * * * eprunapp /srv/epages/eproot/bin/wrapScheduler.sh PurgeSessions epages6 10,40 * * * * eprunapp /srv/epages/eproot/bin/wrapScheduler.sh SendScheduledNewsletters epages6 35 2 * * * eprunapp /srv/epages/eproot/bin/wrapScheduler.sh SendShopCountMail epages6 ...
The first five fields (space separated) of each cron job line designate the date when the job will be executed: minute, hour, day of month, month, and day of week (see man 5 crontab). The sixth field contains the user who runs the command. The rest of the line is the command to be executed.
For example, eprunapp runs each day at 4:00 a.m. the command /srv/epages/eproot/bin/wrapScheduler.sh PurgeSessions epages6. wrapScheduler.sh uses following arguments:
# $EPAGES/bin/wrapScheduler.sh Usage: wrapScheduler.sh [OPTIONS] SCRIPT_NAME [PROJECT] Arguments: -d <DURATION>: max duration the cronjob may take without a next instance reports an error DURATION is one of: <MINUTES> (e.g. -d 56) <HOURS>:<MINUTES> (e.g. -d 7:30) <DAYS>-<HOURS>:<MINUTES> (e.g. -d 3-00:00) -w WRAP_SCRIPT path to perl script (default: $EPAGES/bin/wrapScheduler.PL) -i INI_FILE path to ini file (default: $EPAGES_CONFIG/Scheduler.conf) -g GROUP name of the group the script belongs to SCRIPT_NAME: either file SCRIPT_NAME.env in $EPAGES_CONFIG/Scheduler.d/ OR section SCRIPT_NAME in $EPAGES_CONFIG/Scheduler.conf PROJECT: NAME as defined by /etc/default/NAME (default: epages6) OR own:NAME (use own, not ePages scheduler; set environment) OR own: (use own, not ePages scheduler; don't set environment)
SELinux scripts are stored in /var/epages.
See SELinux Context for ePages Applications.
See SELinux Context for ePages Applications.
Following Apache scripts are stored in /usr/sbin.
dummycert.sh creates a self-signed SSL certificate that may be used by a ePages test webserver for SSL support.
# $EPAGES/bin/dummycert.sh -? Usage: dummycert.sh [-h HOST] [-b BITS] [-d DAYS] [-c CONF_DIR] Options: -h host: certificate host name (default: HOSTNAME) -d days: certificate validation period in days (default: 1) -b bits: key size in bits (default: 2048) -c dir: store certificates in apache conf directory (default: /tmp/cert.4728) Example: dummycert.sh -d 365 -b 4092 -c /etc/httpd
dummycert.sh is used by use-local-httpd.sh to create a SSL certificate to test https requests to the ePages web server.