Skip to content

Commit

Permalink
Merge pull request #17 from craftcms/feature/dev-83-provide-shell-one…
Browse files Browse the repository at this point in the history
…-liner-for

Shell one-liner
  • Loading branch information
timkelty authored Aug 18, 2021
2 parents 3ee75e8 + dc868f1 commit aec52e2
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 2 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/generate-release.yml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 51 additions & 0 deletions check.sh
Original file line number Diff line number Diff line change
@@ -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 $?
1 change: 0 additions & 1 deletion server/checkit.php
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env php
<?php

// Turn it all on.
Expand Down

0 comments on commit aec52e2

Please sign in to comment.