File: cron.sh

package info (click to toggle)
drupal7 7.32-1%2Bdeb8u12
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 23,496 kB
  • sloc: php: 43,501; pascal: 41,001; sh: 1,635; xml: 466; makefile: 21; sql: 1
file content (41 lines) | stat: -rwxr-xr-x 1,032 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh

for site in /etc/drupal/7/sites/* ; do
	BASE_URL=""
	CRON_KEY=""
	FULL_URL=""

	if [ ! "`basename $site`" = "all" ]; then
		for file in $site/baseurl.php $site/settings.php; do
			[ -f "$file" ] && BASE_URL=`grep '^$base_url' $file | cut -d"'" -f2`
			[ "X$BASE_URL" != "X" ] && break
		done

		for file in $site/cronkey.php $site/settings.php; do
			[ -f "$file" ] && CRON_KEY=`grep '^$cron_key' $file | cut -d"'" -f2`
			[ "X$CRON_KEY" != "X" ] && break
		done

		if [ "X$BASE_URL" = "X" ] ; then
		        if [ -f "$site/settings.php" ]; then
			        BASE_URL='http://localhost/drupal7'
			else
			        break
			fi
		fi

		if [ "X$CRON_KEY" = "X" ] ; then
			FULL_URL="$BASE_URL/cron.php"
		else
			FULL_URL="$BASE_URL/cron.php?cron_key=$CRON_KEY"
		fi

		if curl -S --fail --silent --compressed --insecure --location $FULL_URL ; then
		        # Success!
		        true
		else
		        echo "Error running the periodic maintenance for $site: CURL exit code $?"
			echo "Requested URL: $FULL_URL"
		fi
	fi
done