Skip to content

Commit

Permalink
conditional on leader
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Mar 20, 2023
1 parent ebd29f4 commit 09ff029
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions workspace/scripts/files/bash/uninstall_pioreactor_plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@ export LC_ALL=C
plugin_name=$1


# the below can fail, and will fail on a worker

# delete yamls from pioreactorui
install_folder=$(python3 -c "import site; print(site.getsitepackages()[0])")/${plugin_name//-/_}
(cd "$install_folder"/ui/contrib/ && find ./ -type f) | awk '{print "/var/www/pioreactorui/contrib/"$1}' | xargs rm

# TODO: remove sections from config.ini
# this is complicated because sometimes we edit sections, instead of adding full sections. Ex: we edit [PWM] in relay plugin.


sudo pip3 uninstall -y "$plugin_name"

# broadcast to cluster
pios sync-configs
leader_hostname=$(crudini --get /home/pioreactor/.pioreactor/config.ini cluster.topology leader_hostname)

if [ "$leader_hostname" == "$(hostname)" ]; then
# delete yamls from pioreactorui
install_folder=$(python3 -c "import site; print(site.getsitepackages()[0])")/${plugin_name//-/_}
(cd "$install_folder"/ui/contrib/ && find ./ -type f) | awk '{print "/var/www/pioreactorui/contrib/"$1}' | xargs rm

# TODO: remove sections from config.ini
# this is complicated because sometimes we edit sections, instead of adding full sections. Ex: we edit [PWM] in relay plugin.

sudo pip3 uninstall -y "$plugin_name"
# broadcast to cluster
pios sync-configs
else
sudo pip3 uninstall -y "$plugin_name"
fi

exit 0

0 comments on commit 09ff029

Please sign in to comment.