Commit b8cc4fc1e94710f383afba46a84cb4032f7100b9
1 parent
c0e71352
Exists in
master
and in
22 other branches
Avoid enabling plugins with missing dependencies
Showing
1 changed file
with
20 additions
and
5 deletions
Show diff stats
script/noosfero-plugins
| @@ -72,11 +72,26 @@ _enable(){ | @@ -72,11 +72,26 @@ _enable(){ | ||
| 72 | if [ -h "$target" ]; then | 72 | if [ -h "$target" ]; then |
| 73 | _say "$plugin already enabled" | 73 | _say "$plugin already enabled" |
| 74 | else | 74 | else |
| 75 | - ln -s "$source" "$target" | ||
| 76 | - plugins_public_dir="$NOOSFERO_DIR/public/plugins" | ||
| 77 | - test -d "$target/public/" && ln -s "$target/public" "$plugins_public_dir/$plugin" | ||
| 78 | - _say "$plugin enabled" | ||
| 79 | - needs_migrate=true | 75 | + if [ ! -d "$source" ]; then |
| 76 | + echo "E: $plugin plugin does not exist!" | ||
| 77 | + return | ||
| 78 | + fi | ||
| 79 | + dependencies_ok=true | ||
| 80 | + dependencies_file="$source/dependencies.rb" | ||
| 81 | + if [ -e "$dependencies_file" ]; then | ||
| 82 | + if ! "$NOOSFERO_DIR"/script/runner "require '$dependencies_file'"; then | ||
| 83 | + dependencies_ok=false | ||
| 84 | + fi | ||
| 85 | + fi | ||
| 86 | + if [ "$dependencies_ok" = true ]; then | ||
| 87 | + ln -s "$source" "$target" | ||
| 88 | + plugins_public_dir="$NOOSFERO_DIR/public/plugins" | ||
| 89 | + test -d "$target/public/" && ln -s "$target/public" "$plugins_public_dir/$plugin" | ||
| 90 | + _say "$plugin enabled" | ||
| 91 | + needs_migrate=true | ||
| 92 | + else | ||
| 93 | + echo "W: failed to load dependencies for $plugin; not enabling" | ||
| 94 | + fi | ||
| 80 | fi | 95 | fi |
| 81 | } | 96 | } |
| 82 | 97 |