mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
Merge remote-tracking branch 'upstream/master' into dev
This commit is contained in:
commit
f2d8267ef1
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
# Usage:
|
# Usage:
|
||||||
# module-manager list-available
|
# module-manager list-available
|
||||||
@ -6,54 +6,64 @@
|
|||||||
# module-manager enable <python_root> <module_name>
|
# module-manager enable <python_root> <module_name>
|
||||||
# module-manager disable <python_root> <module_name>
|
# module-manager disable <python_root> <module_name>
|
||||||
|
|
||||||
# associate array with mapping between module names and install paths
|
# list of modules that may be enabled/disabled
|
||||||
# (relative to <python_root>/modules/)
|
modules="owncloud"
|
||||||
declare -A modules=( ["owncloud"]="installed/apps/owncloud.py" )
|
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"list-available")
|
"list-available")
|
||||||
# TODO: Replace this with something like "aptitude search -F %p plinth-"
|
# TODO: Replace this with something like "aptitude search -F %p plinth-"
|
||||||
echo "${!modules[@]}"
|
echo "$modules"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"list-enabled")
|
"list-enabled")
|
||||||
# TODO: Replace this with something like 'aptitude search -F %p | grep "plinth-"'
|
# TODO: Replace this with something like 'aptitude search -F %p | grep "plinth-"'
|
||||||
for module in "${!modules[@]}"
|
for module in "$modules"
|
||||||
do
|
do
|
||||||
if [ -e "$2"/modules/"$module".py ] ; then
|
if [ -e "$2"/modules/enabled/"$module" ] ; then
|
||||||
echo "$module"
|
echo "$module"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"enable")
|
"enable")
|
||||||
# TODO: Replace this with "aptitude install plinth-<module>"
|
# TODO: Replace this with "aptitude install plinth-<module>"
|
||||||
for module in "${!modules[@]}"
|
for module in "$modules"
|
||||||
do
|
do
|
||||||
if [ "$3" == "$module" ] ; then
|
if [ "$3" = "$module" ] ; then
|
||||||
if [ ! -e "$2"/modules/"$3".py ] ; then
|
if [ ! -e "$2"/modules/enabled/"$3" ] ; then
|
||||||
ln -s "$2"/modules/"${modules["$3"]}" "$2"/modules/"$3".py
|
touch "$2"/modules/enabled/"$3"
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
[ $RETVAL -eq 0 ] && echo "enabled" "$3"
|
if [ $RETVAL -eq 0 ] ; then
|
||||||
[ $RETVAL -ne 0 ] && echo "failed to enable" "$3"
|
echo "enabled" "$3"
|
||||||
fi
|
else
|
||||||
|
echo "failed to enable" "$3"
|
||||||
|
fi
|
||||||
|
exit $RETVAL
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
echo "failed to enable invalid module" "$3"
|
||||||
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"disable")
|
"disable")
|
||||||
# TODO: Replace this with "aptitude purge plinth-<module>"
|
# TODO: Replace this with "aptitude purge plinth-<module>"
|
||||||
for module in "${!modules[@]}"
|
for module in "$modules"
|
||||||
do
|
do
|
||||||
if [ "$3" == "$module" ] ; then
|
if [ "$3" = "$module" ] ; then
|
||||||
if [ -e "$2"/modules/"$3".py ] ; then
|
if [ -e "$2"/modules/enabled/"$3" ] ; then
|
||||||
rm -f "$2"/modules/"$3".py
|
rm -f "$2"/modules/enabled/"$3"
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
[ $RETVAL -eq 0 ] && echo "disabled" "$3"
|
if [ $RETVAL -eq 0 ] ; then
|
||||||
[ $RETVAL -ne 0 ] && echo "failed to disable" "$3"
|
echo "disabled" "$3"
|
||||||
fi
|
else
|
||||||
|
echo "failed to disable" "$3"
|
||||||
|
fi
|
||||||
|
exit $RETVAL
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
echo "failed to disable invalid module" "$3"
|
||||||
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@ from django.contrib import messages
|
|||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
import os
|
||||||
|
|
||||||
from plinth import actions
|
from plinth import actions
|
||||||
from plinth import cfg
|
from plinth import cfg
|
||||||
@ -16,7 +17,9 @@ def get_modules_available():
|
|||||||
|
|
||||||
def get_modules_enabled():
|
def get_modules_enabled():
|
||||||
"""Return list of all modules"""
|
"""Return list of all modules"""
|
||||||
output = actions.run('module-manager', ['list-enabled'])
|
root = os.path.join(os.path.dirname(__file__), '..', '..')
|
||||||
|
output = actions.run('module-manager',
|
||||||
|
['list-enabled', root])
|
||||||
return output.split()
|
return output.split()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user