A small bash script to create maintenance links

From semantic-mediawiki.org
Jump to: navigation, search
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


# Usage: maintenance_links.bash SOURCE_DIR TARGET_DIR
# This script will make links for maintenance scripts from
# the source directory to the target directory.
# Use the full path to each directory.


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

# check for the right number of arguments and that they are both directories
if [[ "$#" -eq "0" || ! -d $1 || ! -d $2 ]]

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

# find every PHP file in the source directory and symlink to it from the target directory
for FILE in `find $SOURCE_DIR -name "*.php"`; 
	echo $FILE;