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 @@ @@ -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,10 +67,18 @@ _say(){
67 fi 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 _enable(){ 77 _enable(){
71 plugin="$1" 78 plugin="$1"
72 source="$available_plugins_dir/$plugin" 79 source="$available_plugins_dir/$plugin"
73 target="$enabled_plugins_dir/$plugin" 80 target="$enabled_plugins_dir/$plugin"
  81 + run "$source/before_enable.rb"
74 if [ -h "$target" ]; then 82 if [ -h "$target" ]; then
75 _say "$plugin already enabled" 83 _say "$plugin already enabled"
76 else 84 else
@@ -80,16 +88,15 @@ _enable(){ @@ -80,16 +88,15 @@ _enable(){
80 fi 88 fi
81 dependencies_ok=true 89 dependencies_ok=true
82 dependencies_file="$source/dependencies.rb" 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 fi 93 fi
88 if [ "$dependencies_ok" = true ]; then 94 if [ "$dependencies_ok" = true ]; then
89 ln -s "$source" "$target" 95 ln -s "$source" "$target"
90 plugins_public_dir="$NOOSFERO_DIR/public/plugins" 96 plugins_public_dir="$NOOSFERO_DIR/public/plugins"
91 test -d "$target/public/" && ln -s "$target/public" "$plugins_public_dir/$plugin" 97 test -d "$target/public/" && ln -s "$target/public" "$plugins_public_dir/$plugin"
92 _say "$plugin enabled" 98 _say "$plugin enabled"
  99 + run "$source/after_enable.rb"
93 needs_migrate=true 100 needs_migrate=true
94 else 101 else
95 echo "W: failed to load dependencies for $plugin; not enabling" 102 echo "W: failed to load dependencies for $plugin; not enabling"
@@ -99,12 +106,15 @@ _enable(){ @@ -99,12 +106,15 @@ _enable(){
99 106
100 _disable(){ 107 _disable(){
101 plugin="$1" 108 plugin="$1"
  109 + source="$available_plugins_dir/$plugin"
102 target="$enabled_plugins_dir/$plugin" 110 target="$enabled_plugins_dir/$plugin"
103 plugins_public_dir="$NOOSFERO_DIR/public/plugins" 111 plugins_public_dir="$NOOSFERO_DIR/public/plugins"
  112 + run "$source/before_disable.rb"
104 if [ -h "$target" ]; then 113 if [ -h "$target" ]; then
105 rm "$target" 114 rm "$target"
106 test -h "$plugins_public_dir/$plugin" && rm "$plugins_public_dir/$plugin" 115 test -h "$plugins_public_dir/$plugin" && rm "$plugins_public_dir/$plugin"
107 _say "$plugin disabled" 116 _say "$plugin disabled"
  117 + run "$source/after_disable.rb"
108 else 118 else
109 _say "$plugin already disabled" 119 _say "$plugin already disabled"
110 fi 120 fi