File: list-enabled-plugins.sh

package info (click to toggle)
fusionforge 5.3.2%2B20141104-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 60,472 kB
  • sloc: php: 271,846; sql: 36,817; python: 14,575; perl: 6,406; sh: 5,980; xml: 4,294; pascal: 1,411; makefile: 911; cpp: 52; awk: 27
file content (57 lines) | stat: -rwxr-xr-x 1,410 bytes parent folder | download | duplicates (3)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#! /bin/sh

# Lists which plugins are enabled or disabled.

# Takes into account the 'plugin_status = valid' values if the plugin's etc/pluginname.ini file exists
if ! type confget >/dev/null 2>&1 && ! type python >/dev/null 2>&1 ; then
	echo >&2 Aborting, neither confget nor python are available
	exit 255
fi

if [ -e plugins ] ; then
    cd .
elif [ -e ../src/plugins ] ; then
    cd ../src
else
    echo "Couldn't find source directory..."
    exit 1
fi

enabled=""
disabled=""

for name in plugins/*/NAME ; do 
    dir=${name%%/NAME}
    plugin=${dir##plugins/}
    if [ -e $dir/packaging/control/[1-9][0-9][0-9]plugin-$plugin ] ; then
	if [ ! -e $dir/etc/$plugin.ini ] ; then
	    enabled="$enabled $plugin"
	else
	    if [ -x /usr/bin/confget ] ; then
		status=$(confget -f $dir/etc/$plugin.ini plugin_status | sed -r 's/[ \t]*;.*//g')
	    else
		status=$(python 2>/dev/null <<EOF
import ConfigParser
config = ConfigParser.ConfigParser()
config.read("plugins/$plugin/etc/$plugin.ini")
print config.get("$plugin","plugin_status").strip()
EOF
) || status=error		
	    fi
	    # confget returns litteral semi-colons after values, so get rid of comments
	    if [ "$status" = "valid" ] ; then
		enabled="$enabled $plugin"
	    else
		disabled="$disabled $plugin"
	    fi
	fi
    else
	disabled="$disabled $plugin"
    fi
done

if [ "$1" = "--disabled" ] ; then
    echo $disabled
else
    echo $enabled
fi