Skip to content

Commit

Permalink
🤖 Sync Script for Server and Lang Update
Browse files Browse the repository at this point in the history
  • Loading branch information
ConradSollitt committed Dec 9, 2019
1 parent e619dd0 commit 7332b87
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 15 deletions.
23 changes: 8 additions & 15 deletions app/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,15 @@
// Site Functions
// --------------------------------------------------------------------------------------

// More lanuages can be added here as templates are created.
// Available languages must be white-listed for security.
function getLangauage($lang) {
switch ($lang) {
case 'en':
case 'es':
break;
default:
$lang = 'en';
}
return $lang;
}

// Get the template site for the user's selected language.
// The language must exist as a directory otherwise 'en'
// is used as the fallback language.
function getTemplateRoot($lang) {
$lang = getLangauage($lang);
return __DIR__ . '/../app_data/template/' . $lang . '/';
$dir = __DIR__ . '/../app_data/template';
if ($lang !== 'en' && !Security::dirContainsDir($dir, $lang)) {
$lang = 'en';
}
return $dir . '/' . $lang . '/';
}

function getSitePath($site) {
Expand Down
33 changes: 33 additions & 0 deletions scripts/sync-server-from-github.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

# -----------------------------------------------------------------------------
#
# This is a Bash Script that runs on the production server [dataformsjs.com]
# and is used to sync the latest changes from GitHub. It runs manually from
# the author once published changes are confirmed.
#
# Only site templates and Framework are synced, any other code changes
# require manual updates. This is due to the fact that the playground server
# uses a hard-coded security key for authentication which only exists on the
# server. A hard-coded key is used over a [.env] file for performance
# (to avoid loading extra classes and files).
#
# To run:
# bash /var/www/scripts/sync-server-from-github.sh
#
# For testing with [rsync] use [-n = --dry-run]
# Example:
# rsync -nrcv --delete ~/playground-master/app_data/template/ /var/www/app_data/template
#
# -----------------------------------------------------------------------------

wget https://github.com/fastsitephp/playground/archive/master.zip -O /home/ubuntu/master.zip
unzip -q master.zip
rm master.zip
wget https://github.com/fastsitephp/fastsitephp/archive/1.0.0.zip -O /home/ubuntu/1.0.0.zip
unzip -q 1.0.0.zip
rm 1.0.0.zip
rsync -rcv --delete ~/playground-master/app_data/template/ /var/www/app_data/template
rsync -rcv --delete ~/fastsitephp-1.0.0/src/ /var/www/vendor/fastsitephp/src
rm -r playground-master
rm -r fastsitephp-1.0.0

0 comments on commit 7332b87

Please sign in to comment.