configure 974 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/bash
  2. # read wekan config
  3. . $SNAP/bin/config
  4. # create run dir, we're going to use it for unix socket
  5. mkdir -p $SNAP_DATA/share
  6. mkdir -p $SNAP_DATA/shared
  7. # settings were altered by user, safest way to get them applied is to restart service
  8. # TODO: remove this workaround once it's not needed
  9. # for the moment we can't read settings outside of the hook,
  10. # so store all settings in helpper script which is then picked by main wrapper
  11. echo -e "#!/bin/sh\n" > $SETTINGS_FILE
  12. for key in ${keys[@]}
  13. do
  14. # snappy is picky about key syntax, using mapping
  15. MAP_KEY="KEY_$key"
  16. if value=$(snapctl get ${!MAP_KEY}); then
  17. echo "export $key='$value'" >> $SETTINGS_FILE
  18. elif [ -d "${!key}" ]; then
  19. # store back value from SETTINGS_FILE
  20. echo "export $key='${!key}'" >> $SETTINGS_FILE
  21. fi
  22. done
  23. # set file executable
  24. chmod 755 $SETTINGS_FILE
  25. # we can't use snapctl to restart service, may be one day ....
  26. echo "Setting has been updated, restart service."