Archive:A small bash script to create maintenance links


 * WARNING: This is an old recommendation, all the scripts in current versions of Semantic MediaWiki work fine right from the extensions directory and also pickup on the MW_INSTALL_PATH environment variable. It's recommended not to use this script anymore.

Why use this script
Semantic MediaWiki and the Halo Extension both have maintenance scripts that should be run from the maintenance directory of the MediaWiki installation. The README in the maintenance directory recommends symlinking them. This script will automatically do that for each file with a PHP extension in a given directory.

Using the script
You will need shell access on a Linux server. Save the script code to a file named "maintenance_links.bash" on the server, and make sure it has permission to execute:

chmod 755 maintenance_links.bash

Example execution commands:

./maintenance_links.bash ~/http/wiki_test/extensions/SemanticMediaintenance/ ~/http/wiki_test/maintenance/ ./maintenance_links.bash ~/http/wiki_test/extensions/SMWHalo/maintenance/ ~/http/wiki_test/maintenance/

The script

 * 1) !/bin/bash


 * 1) Usage: maintenance_links.bash SOURCE_DIR TARGET_DIR
 * 2) This script will make links for maintenance scripts from
 * 3) the source directory to the target directory.
 * 4) Use the full path to each directory.
 * 1) Use the full path to each directory.

SOURCE_DIR=$1 TARGET_DIR=$2

usage {	echo "Usage: $0 SOURCE_DIR TARGET_DIR"; echo; echo "PHP files from the source directory will be linked to in the target directory."; echo "Use the full path to each directory."; }

if | ! -d $1 || ! -d $2 then usage; exit; fi
 * 1) check for the right number of arguments and that they are both directories

echo "Linking .php files from $SOURCE_DIR to $TARGET_DIR"

for FILE in `find $SOURCE_DIR -name "*.php"`; do echo $FILE; ln -sf $FILE $TARGET_DIR done
 * 1) find every PHP file in the source directory and symlink to it from the target directory