diff --git a/.github/workflows/generate-release.yml b/.github/workflows/generate-release.yml new file mode 100644 index 0000000..f2c493a --- /dev/null +++ b/.github/workflows/generate-release.yml @@ -0,0 +1,32 @@ +name: Generate Release +on: + push: + tags: + - "*.*.*" + +jobs: + generate_release: + name: Generate release + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v2 + + - name: Archive release + uses: thedoctor0/zip-release@master + with: + type: tar + directory: ./server + filename: ../craftcms-server-check.tar.gz + exclusions: '*.git*' + + - name: Generate SHA256 + run: sha256sum -b craftcms-server-check.tar.gz > sha256sum.txt + + - name: Release + uses: softprops/action-gh-release@v1 + with: + files: | + sha256sum.txt + craftcms-server-check.tar.gz diff --git a/README.md b/README.md index 7af67b4..b38a877 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,15 @@ This script checks if a web server meets the minimum requirements to run a Craft 3 installation. -You can upload the `server` folder to your web server's public html folder and load `checkit.php` from your browser +## Usage + +Run the following in a terminal of any [\*nix](https://en.wikipedia.org/wiki/Unix-like) environment (e.g. Linux, MacOS, WSL). + +```bash +curl -Lsf https://raw.githubusercontent.com/craftcms/server-check/HEAD/check.sh | bash +``` + +Alternatively, you can upload the `server` folder to your web server's public html folder and load `checkit.php` from your browser or upload `server` anywhere on your server and execute `php checkit.php` from the console to see the results. ## Shell exit codes diff --git a/check.sh b/check.sh new file mode 100755 index 0000000..b51a034 --- /dev/null +++ b/check.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +# Craft CMS Server Check (one-liner) +# +# From the environment you want to check, run: +# `curl -Lsf https://raw.githubusercontent.com/craftcms/server-check/HEAD/check.sh | bash` + +[[ $- = *i* ]] && echo "Don't source this script!" && return 10 + +checkTools() { + Tools=("curl" "php" "rm" "tar" "grep" "cut") + + for tool in ${Tools[*]}; do + if ! checkCmd $tool; then + echo "Aborted, missing $tool." + exit 6 + fi + done +} + +checkCmd() { + command -v "$1" > /dev/null 2>&1 +} + +function serverCheck() { + checkTools + + latestTag=$(curl -s https://api.github.com/repos/craftcms/server-check/releases | grep 'tag_name' | cut -d\" -f4) + tmpDir="/tmp/craftcms-server-check-${latestTag}" + assetUrl="https://github.com/craftcms/server-check/releases/download/${latestTag}/craftcms-server-check.tar.gz" + downloadToFile="${tmpDir}/craftcms-server-check.tar.gz" + phpScript="${tmpDir}/checkit.php" + + echo "Downloading file…" + mkdir "$tmpDir" + curl -fsSL "$assetUrl" --output "$downloadToFile" + + echo "Extracting…" + tar -xzf "$downloadToFile" -C "$tmpDir" + + echo "Running Craft Server Check…" + php $phpScript + returnCode=$? + + rm -rf "$tmpDir" + + return $returnCode +} + +serverCheck +exit $? diff --git a/server/checkit.php b/server/checkit.php old mode 100755 new mode 100644 index 711928d..218f836 --- a/server/checkit.php +++ b/server/checkit.php @@ -1,4 +1,3 @@ -#!/usr/bin/env php