diff --git a/install.sh b/install.sh index 41a9af3..a0a9f01 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 @@ -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") @@ -141,7 +142,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" } @@ -149,6 +151,7 @@ install_etc_config() install_service() { install_etc_config + #echo "install service" installable="" if [ -d "$MY_ROOT/etc/systemd/system" ]; then @@ -184,6 +187,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" @@ -201,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" @@ -219,16 +224,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 - sudo chmod -R ug+Xrw /srv/walnut pushd /srv/walnut/core npm install 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 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..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;
}
@@ -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) {