From 65deaf3a853d52f0603ae20e7ee6c7cfb1765ba4 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 25 May 2017 17:43:51 +0000 Subject: [PATCH 1/5] reset permissions --- install.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 41a9af3..0647bc4 100755 --- a/install.sh +++ b/install.sh @@ -141,7 +141,8 @@ install_etc_config() $sudo_cmd mv "$my_app_dir/$my_app_etc_config" "$MY_ROOT/$my_app_etc_config" fi - $sudo_cmd chown -R www-data:www-data $(dirname "$MY_ROOT/$my_app_etc_config") + $sudo_cmd chown -R www-data:www-data $(dirname "$MY_ROOT/$my_app_etc_config") || true + $sudo_cmd chown -R _www:_www $(dirname "$MY_ROOT/$my_app_etc_config") || true $sudo_cmd chmod 775 $(dirname "$MY_ROOT/$my_app_etc_config") $sudo_cmd chmod 664 "$MY_ROOT/$my_app_etc_config" } @@ -220,11 +221,16 @@ install_my_app() sudo mkdir -p /srv/walnut/etc/org.oauth3.provider sudo mkdir -p /srv/walnut/packages/{client-api-grants,rest,api,pages,services,sites} #sudo chown -R $(whoami):$(whoami) /srv/walnut - sudo chown -R www-data:www-data /srv/walnut + sudo chown -R www-data:www-data /srv/walnut || true + sudo chown -R _www:_www /srv/walnut || true sudo chmod -R ug+Xrw /srv/walnut pushd /srv/walnut/core + sudo chown -R $(whoami) /srv/walnut + #sudo --user www-data --group www-data npm install npm install + sudo chown -R www-data /srv/walnut || true + sudo chown -R _www /srv/walnut || true popd } From 4e0b996acde474c070dbdbba6142a17fa0e098a9 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 25 May 2017 18:26:14 +0000 Subject: [PATCH 2/5] reset permissions --- install.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/install.sh b/install.sh index 0647bc4..db56956 100755 --- a/install.sh +++ b/install.sh @@ -72,8 +72,8 @@ dap_dl_bash() { dap_url=$1 #dap_args=$2 - rm -rf dap-tmp-runner.sh - $http_bin $http_opts $http_out dap-tmp-runner.sh "$dap_url"; bash dap-tmp-runner.sh; rm dap-tmp-runner.sh + rm -rf /tmp/dap-tmp-runner.sh + $http_bin $http_opts $http_out /tmp/dap-tmp-runner.sh "$dap_url"; bash /tmp/dap-tmp-runner.sh; rm /tmp/dap-tmp-runner.sh } detect_http_bin @@ -149,6 +149,7 @@ install_etc_config() install_service() { + echo "install etc config" install_etc_config installable="" @@ -185,6 +186,7 @@ create_skeleton() # Unistall install_uninstaller() { + echo "install uninstaller" dap_dl "https://git.daplie.com/Daplie/walnut.js/raw/master/uninstall.sh" "./walnut-uninstall" $sudo_cmd chmod 755 "./walnut-uninstall" $sudo_cmd chown root:root "./walnut-uninstall" @@ -220,21 +222,20 @@ install_my_app() sudo mkdir -p /srv/walnut/etc/org.oauth3.consumer sudo mkdir -p /srv/walnut/etc/org.oauth3.provider sudo mkdir -p /srv/walnut/packages/{client-api-grants,rest,api,pages,services,sites} - #sudo chown -R $(whoami):$(whoami) /srv/walnut - sudo chown -R www-data:www-data /srv/walnut || true - sudo chown -R _www:_www /srv/walnut || true - sudo chmod -R ug+Xrw /srv/walnut pushd /srv/walnut/core - sudo chown -R $(whoami) /srv/walnut - #sudo --user www-data --group www-data npm install npm install - sudo chown -R www-data /srv/walnut || true - sudo chown -R _www /srv/walnut || true popd } +sudo mkdir -p /srv/walnut +sudo chown -R $(whoami) /srv/walnut + install_my_app create_skeleton install_uninstaller install_service + +sudo chown -R www-data:www-data /srv/walnut || true +sudo chown -R _www:_www /srv/walnut || true +sudo chmod -R ug+Xrw /srv/walnut From 66589782fed507e2a060aaaf1ac182fd68a591e2 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 25 May 2017 18:57:24 +0000 Subject: [PATCH 3/5] set installer base correctly --- install.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index db56956..a0a9f01 100755 --- a/install.sh +++ b/install.sh @@ -134,6 +134,7 @@ install_for_launchd() install_etc_config() { + #echo "install etc config $MY_ROOT / $my_app_etc_config" if [ ! -e "$MY_ROOT/$my_app_etc_config" ]; then $sudo_cmd mkdir -p $(dirname "$MY_ROOT/$my_app_etc_config") mkdir -p $(dirname "$my_app_dir/$my_app_etc_config") @@ -149,8 +150,8 @@ install_etc_config() install_service() { - echo "install etc config" install_etc_config + #echo "install service" installable="" if [ -d "$MY_ROOT/etc/systemd/system" ]; then @@ -186,7 +187,7 @@ create_skeleton() # Unistall install_uninstaller() { - echo "install uninstaller" + #echo "install uninstaller" dap_dl "https://git.daplie.com/Daplie/walnut.js/raw/master/uninstall.sh" "./walnut-uninstall" $sudo_cmd chmod 755 "./walnut-uninstall" $sudo_cmd chown root:root "./walnut-uninstall" @@ -204,7 +205,8 @@ my_app_name=walnut my_app_pkg_name=com.daplie.walnut.web my_app_dir=$(mktemp -d) #installer_base="https://git.daplie.com/Daplie/walnut.js/raw/master/dist" -installer_base="./dist" +#installer_base="$( dirname "${BASH_SOURCE[0]}" )/dist" +installer_base="/srv/walnut/core/dist" my_app_etc_config="etc/${my_app_name}/${my_app_name}.yml" my_app_systemd_service="etc/systemd/system/${my_app_name}.service" From 172f7f3bc494f442456bdf92c99bf41adcb9ef7b Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 25 May 2017 15:43:50 -0600 Subject: [PATCH 4/5] load correct path and document package loading --- lib/com.daplie.walnut/index.html | 17 +++++++++++++++++ lib/main.js | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/com.daplie.walnut/index.html b/lib/com.daplie.walnut/index.html index 40a1121..a139eb0 100644 --- a/lib/com.daplie.walnut/index.html +++ b/lib/com.daplie.walnut/index.html @@ -36,6 +36,23 @@ + + + +
HTML packages go in /srv/walnut/packages/pages
+REST packages go in /srv/walnut/packages/rest
+API packages go in /srv/walnut/packages/api
+
+There are two ways to set up a site.
+
+The first is to create a site package yourself by adding files.
+/srv/walnut/packages/sites/example.com/index.html
+
+The other is by providing a single text file of the name of the site with the name of the package to load
+/srv/walnut/packages/sites/example.com => com.example
+ + + diff --git a/lib/main.js b/lib/main.js index da83127..de18e68 100644 --- a/lib/main.js +++ b/lib/main.js @@ -59,7 +59,7 @@ module.exports.create = function (app, xconfx, apiFactories, apiDeps, errorIfApi if (!setupApp) { //setupApp = express.static(path.join(xconfx.staticpath, 'com.daplie.walnut')); - setupApp = express.static(path.join('lib', 'com.daplie.walnut')); + setupApp = express.static(path.join(__dirname, 'com.daplie.walnut')); } setupApp(req, res, function () { if ('/' === req.url) { From 6cfee0b20bd9ff927b83d817182b015b5f4b8cb7 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 25 May 2017 17:23:39 -0600 Subject: [PATCH 5/5] fix redirect matching --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index de18e68..46f0ad0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -51,7 +51,7 @@ module.exports.create = function (app, xconfx, apiFactories, apiDeps, errorIfApi function notConfigured(req, res, next) { if (setupDomain !== req.hostname) { console.log('[notConfigured] req.hostname', req.hostname); - if (/\.html\b/.test(req.url)) { + if ('/' === req.url[req.url.length - 1] || /\.html\b/.test(req.url)) { redirectSetup(req.hostname, req, res); return; }