Skip to content

Commit

Permalink
Merge pull request #19 from ww24/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ww24 authored Dec 28, 2016
2 parents c6e6263 + 47cd816 commit 9eafc5f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
41 changes: 37 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,44 @@ case $ARCH in
i386) ARCH="386";;
esac
OS=$(uname | tr '[:upper:]' '[:lower:]')
if [ $OS = "windows" ]; then
if [ "$OS" = "windows" ]; then
EXT=".exe"
fi

VERSION=$(curl -sL https://raw.githubusercontent.com/ww24/lirc-web-api/master/wercker.yml | grep 'API_VERSION="v' | awk -F\" '{print $2}')
curl -sLo api "https://github.com/ww24/lirc-web-api/releases/download/${VERSION}/api_${OS}_${ARCH}${EXT}"
chmod +x api

echo "installed at $(pwd)/api $(./api -v)"
DOWNLOAD_URL="https://github.com/ww24/lirc-web-api/releases/download/${VERSION}/api_${OS}_${ARCH}${EXT}"
echo "Downloading $DOWNLOAD_URL"
curl -Lo /tmp/lirc-web-api "$DOWNLOAD_URL"
chmod +x /tmp/lirc-web-api

if [ "$OS" = "linux" ] && hash systemctl; then
INSTALL_DIR=/usr/local/bin
mkdir -p $INSTALL_DIR
INSTALL_PATH="$INSTALL_DIR/lirc-web-api"
sudo mv /tmp/lirc-web-api $INSTALL_PATH

cat <<EOF | sudo tee /lib/systemd/system/lirc-web-api.service
[Unit]
Description=lirc-web-api
After=network.target network-online.target
[Service]
Type=simple
ExecStart=$INSTALL_PATH
ExecReload=/bin/kill -HUP \$MAINPID
KillMode=control-group
Restart=on-failure
[Install]
WantedBy=multi-user.target
Alias=mackerel-agent.service
EOF

sudo systemctl enable lirc-web-api
sudo systemctl start lirc-web-api
sudo systemctl status lirc-web-api
else
mv /tmp/lirc-web-api .
echo "installed at $(pwd)/lirc-web-api $(./lirc-web-api -v)"
fi
5 changes: 4 additions & 1 deletion wercker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build:
steps:
- script:
name: set API_VERSION
code: export API_VERSION="v0.2.5"
code: export API_VERSION="v0.2.6"

- script:
name: install lirc
Expand Down Expand Up @@ -76,6 +76,9 @@ build:
code: |
cp "$WERCKER_SOURCE_DIR/README.md" "$WERCKER_OUTPUT_DIR"
- shellcheck:
files: install.sh

deploy:
steps:
- install-packages:
Expand Down

0 comments on commit 9eafc5f

Please sign in to comment.