Merge pull request #6 from jespino/adding-curl-to-makefile
Adding curl as option to 'make deploy' for better linux support
This commit is contained in:
commit
25beae65fa
1 changed files with 10 additions and 1 deletions
11
Makefile
11
Makefile
|
@ -1,6 +1,8 @@
|
|||
GO ?= $(shell command -v go 2> /dev/null)
|
||||
DEP ?= $(shell command -v dep 2> /dev/null)
|
||||
NPM ?= $(shell command -v npm 2> /dev/null)
|
||||
HTTP ?= $(shell command -v http 2> /dev/null)
|
||||
CURL ?= $(shell command -v curl 2> /dev/null)
|
||||
MANIFEST_FILE ?= plugin.json
|
||||
|
||||
# Verify environment, and define PLUGIN_ID, HAS_SERVER and HAS_WEBAPP as needed.
|
||||
|
@ -74,7 +76,7 @@ dist: apply \
|
|||
# variables are defined, or copying the files directly to a sibling mattermost-server directory
|
||||
.PHONY: deploy
|
||||
deploy: dist
|
||||
ifneq ($(and $(MM_SERVICESETTINGS_SITEURL),$(MM_ADMIN_USERNAME),$(MM_ADMIN_PASSWORD)),)
|
||||
ifneq ($(and $(MM_SERVICESETTINGS_SITEURL),$(MM_ADMIN_USERNAME),$(MM_ADMIN_PASSWORD),$(HTTP)),)
|
||||
@echo "Installing plugin via API"
|
||||
(TOKEN=`http --print h POST $(MM_SERVICESETTINGS_SITEURL)/api/v4/users/login login_id=$(MM_ADMIN_USERNAME) password=$(MM_ADMIN_PASSWORD) | grep Token | cut -f2 -d' '` && \
|
||||
http --print b GET $(MM_SERVICESETTINGS_SITEURL)/api/v4/users/me Authorization:"Bearer $$TOKEN" && \
|
||||
|
@ -83,6 +85,13 @@ ifneq ($(and $(MM_SERVICESETTINGS_SITEURL),$(MM_ADMIN_USERNAME),$(MM_ADMIN_PASSW
|
|||
http --print b POST $(MM_SERVICESETTINGS_SITEURL)/api/v4/plugins/$(PLUGIN_ID)/enable Authorization:"Bearer $$TOKEN" && \
|
||||
http --print b POST $(MM_SERVICESETTINGS_SITEURL)/api/v4/users/logout Authorization:"Bearer $$TOKEN" \
|
||||
)
|
||||
else ifneq ($(and $(MM_SERVICESETTINGS_SITEURL),$(MM_ADMIN_USERNAME),$(MM_ADMIN_PASSWORD),$(CURL)),)
|
||||
@echo "Installing plugin via API"
|
||||
$(eval TOKEN := $(shell curl -i -X POST $(MM_SERVICESETTINGS_SITEURL)/api/v4/users/login -d '{"login_id": "$(MM_ADMIN_USERNAME)", "password": "$(MM_ADMIN_PASSWORD)"}' | grep Token | cut -f2 -d' ' 2> /dev/null))
|
||||
@curl -s -H "Authorization: Bearer $(TOKEN)" -X DELETE $(MM_SERVICESETTINGS_SITEURL)/api/v4/plugins/$(PLUGIN_ID) > /dev/null
|
||||
@curl -s -H "Authorization: Bearer $(TOKEN)" -X POST $(MM_SERVICESETTINGS_SITEURL)/api/v4/plugins -F "plugin=@dist/$(PLUGIN_ID).tar.gz" > /dev/null && \
|
||||
curl -s -H "Authorization: Bearer $(TOKEN)" -X POST $(MM_SERVICESETTINGS_SITEURL)/api/v4/plugins/$(PLUGIN_ID)/enable > /dev/null && \
|
||||
echo "OK." || echo "Sorry, something went wrong."
|
||||
else ifneq ($(wildcard ../mattermost-server/.*),)
|
||||
@echo "Installing plugin via filesystem. Server restart and manual plugin enabling required"
|
||||
mkdir -p ../mattermost-server/plugins
|
||||
|
|
Reference in a new issue