Commit 00620c69cdedc5f04e95cc16e8ba43f4d0da050a

Authored by Rodrigo Souto
1 parent de5477c7

Adding triggers to plugin enable/disable script

After/Before enable/disable

Also: alerting user to run reindex after enabling solr.
plugins/solr/after_enable.rb 0 → 100644
... ... @@ -0,0 +1 @@
  1 +puts "\nI: \e[33mAfter enabling solr you might want to run: $rake solr:reindex\e[0m\n\n"
... ...
script/noosfero-plugins
... ... @@ -67,10 +67,18 @@ _say(){
67 67 fi
68 68 }
69 69  
  70 +run(){
  71 + if [ -e "$1" ]; then
  72 + ruby -I$load_paths -e "require '$1'"
  73 + return $?
  74 + fi
  75 +}
  76 +
70 77 _enable(){
71 78 plugin="$1"
72 79 source="$available_plugins_dir/$plugin"
73 80 target="$enabled_plugins_dir/$plugin"
  81 + run "$source/before_enable.rb"
74 82 if [ -h "$target" ]; then
75 83 _say "$plugin already enabled"
76 84 else
... ... @@ -80,16 +88,15 @@ _enable(){
80 88 fi
81 89 dependencies_ok=true
82 90 dependencies_file="$source/dependencies.rb"
83   - if [ -e "$dependencies_file" ]; then
84   - if ! ruby -I$load_paths -e "require '$dependencies_file'"; then
85   - dependencies_ok=false
86   - fi
  91 + if ! run $dependencies_file; then
  92 + dependencies_ok=false
87 93 fi
88 94 if [ "$dependencies_ok" = true ]; then
89 95 ln -s "$source" "$target"
90 96 plugins_public_dir="$NOOSFERO_DIR/public/plugins"
91 97 test -d "$target/public/" && ln -s "$target/public" "$plugins_public_dir/$plugin"
92 98 _say "$plugin enabled"
  99 + run "$source/after_enable.rb"
93 100 needs_migrate=true
94 101 else
95 102 echo "W: failed to load dependencies for $plugin; not enabling"
... ... @@ -99,12 +106,15 @@ _enable(){
99 106  
100 107 _disable(){
101 108 plugin="$1"
  109 + source="$available_plugins_dir/$plugin"
102 110 target="$enabled_plugins_dir/$plugin"
103 111 plugins_public_dir="$NOOSFERO_DIR/public/plugins"
  112 + run "$source/before_disable.rb"
104 113 if [ -h "$target" ]; then
105 114 rm "$target"
106 115 test -h "$plugins_public_dir/$plugin" && rm "$plugins_public_dir/$plugin"
107 116 _say "$plugin disabled"
  117 + run "$source/after_disable.rb"
108 118 else
109 119 _say "$plugin already disabled"
110 120 fi
... ...