Shell Script To Generate Mediawiki Wiki Software Google Sitemap

in Categories Web Server last updated July 18, 2017
#!/bin/bash
# A Sample Shell Script To Generate Mediawiki Wiki Software Google Sitemap Using PHP
# on server itself via cron.
# Warning: You need to customize this script before using it!
# -------------------------------------------------------------------------
# Copyright (c) 2008 nixCraft project <https://www.cyberciti.biz/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
 
# Path to wiki dir
BASE="/home/httpd/example.com/wiki"
 
# Wiki domain name
SERVER="http://www.example.com/"
 
# Path to actual sitemap file - change this 
OUT="${BASE}/sitemap-index-cbzwikibashportal.xml"
cd $BASE/wiki/maintenance
php generateSitemap.php --fspath="$BASE" --server="${SERVER}"
 
# patch it up replace example.com with actual domain name 
sed -i -e 's/sitemap-cbzwikibashportal-NS_[0-9]*-[0-9]*\.xml\.gz/http:\/\/www\.example\.com\/&/g' $OUT

Here is an updated version without need of using sed command:

#!/bin/bash
# Purpose: Shell Script To Generate Mediawiki Wiki Software Google Sitemap Using PHP
# -------------------------------------------------------------------------
# Copyright (c) 2017 nixCraft project <https://www.cyberciti.biz/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit https://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
 
## ATTENTION: Set me ##
# PHP cli path
_php=/usr/bin/php
# Path to script
_s=/var/www/html/wiki/maintenance/generateSitemap.php
# Memory limit 
_mem=50M
# Output folder
_fs=/var/www/html
# Given ID
_id=cbzwikibashportal
# Folder in which mediawiki installed
_url=https://bash.cyberciti.biz/wiki
# Wiki https url
_server=https://bash.cyberciti.biz
# Run it 
${_php} ${_s} --memory-limit=${_mem} --fspath=${_fs} --identifier=${_id} --urlpath=${_url} --server=${_server} --compress=yes

Share this on: