Compare commits

..

2085 Commits

Author SHA1 Message Date
Girish Ramakrishnan 1d8bf58779 Add script to create a release in staging
Fixes #145
2015-01-27 18:23:40 -08:00
Girish Ramakrishnan 9d404b7832 Allow manipulating staging release files 2015-01-27 18:12:34 -08:00
Girish Ramakrishnan 36869cb236 parametrize the download_current function 2015-01-27 18:12:34 -08:00
Girish Ramakrishnan 8d848d5b38 Remove obsolete comment 2015-01-27 16:13:17 -08:00
Girish Ramakrishnan 318e203511 Combine set flags into single command 2015-01-27 16:05:22 -08:00
Girish Ramakrishnan 8bef7c0b05 Add date field to versions.json
Part of #145
2015-01-27 15:31:27 -08:00
Girish Ramakrishnan fd52179fcf Remove unused certs
Fixes #146
2015-01-27 14:14:47 -08:00
Girish Ramakrishnan 7a89f38f8d Add tests for custom domain processing in config.js 2015-01-27 10:49:56 -08:00
Girish Ramakrishnan 2bf481dcd0 When using custom domains, the zone name is the fqdn 2015-01-27 09:21:11 -08:00
Johannes Zellner 5a84681ef3 Adjust run.sh to accomodate postinstall -> start rename 2015-01-27 14:49:47 +01:00
Johannes Zellner ad0929e622 Do not use deprecated api in cors.js 2015-01-27 13:50:58 +01:00
Girish Ramakrishnan c015457747 Add UI to upload custom certificate 2015-01-25 21:53:25 -08:00
Girish Ramakrishnan 700fe9a161 Add upgrade flag to versions file
When set, the box will issue an upgrade request instead of an update
request. The intention here is that if the updater is broken then
we can just create a new source tarball without having to create a
new image.
2015-01-25 19:43:41 -08:00
Girish Ramakrishnan 762a0a93ed Cleanup debug messages 2015-01-25 19:34:23 -08:00
Girish Ramakrishnan 09377062f8 Pass isCustomDomain in opaque data from update code 2015-01-25 19:13:45 -08:00
Girish Ramakrishnan ec45f25038 Implement REST API to upload custom certificate 2015-01-24 21:50:47 -08:00
Girish Ramakrishnan 4288eb3ea4 Remove dead code 2015-01-24 21:25:57 -08:00
Girish Ramakrishnan 88a1f83aa6 Add multipart middleware (uses multiparty) 2015-01-24 17:51:05 -08:00
Girish Ramakrishnan 1e057de8c5 Use HttpSuccess instead of res.send 2015-01-24 15:24:26 -08:00
Girish Ramakrishnan db12133592 Add support for custom domains 2015-01-24 09:36:55 -08:00
Girish Ramakrishnan 953ca61507 Move appFqdn to config.js 2015-01-24 08:26:04 -08:00
Girish Ramakrishnan 16ad270587 adminOrigin can be derived from fqdn
config.js does this already
2015-01-24 07:37:06 -08:00
Girish Ramakrishnan eed8c39a1e haraka does not backup anything 2015-01-24 01:19:00 -08:00
Girish Ramakrishnan d36252e634 Suppress echo error output 2015-01-24 01:15:29 -08:00
Girish Ramakrishnan 6af415c83b Implement setup code new design 2015-01-23 23:11:22 -08:00
Girish Ramakrishnan f9a8916254 wrap in double quotes as changelog can have single quotes 2015-01-23 21:25:10 -08:00
Girish Ramakrishnan 2455975a46 bash scripts: merge the set lines 2015-01-23 15:01:10 -08:00
Girish Ramakrishnan 9f5a7cc1c2 Leave a note that args depend on various components 2015-01-23 14:40:08 -08:00
Girish Ramakrishnan 367b088193 Remove unnecessary variables 2015-01-23 09:11:49 -08:00
Girish Ramakrishnan 80d4a78a9f Verify sourceTarballUrl is https and a tar.gz 2015-01-23 00:16:08 -08:00
Girish Ramakrishnan d98fe190a3 Parse tls cert and key separately
Since those keys contain newlines
2015-01-23 00:09:36 -08:00
Girish Ramakrishnan 0be2c7be8c Add hotfix to ensure directory for progress.json 2015-01-22 23:56:33 -08:00
Girish Ramakrishnan edb49868a0 more script cleanup 2015-01-22 23:50:28 -08:00
Girish Ramakrishnan 240c98d654 Actually commit preinstall directory 2015-01-22 23:48:22 -08:00
Girish Ramakrishnan d3a20853d0 Add default changelog 2015-01-22 23:46:15 -08:00
Girish Ramakrishnan de6a34df98 rework script because getopt does not support optional args 2015-01-22 23:43:42 -08:00
Girish Ramakrishnan a9fa5b37a4 Use sudo -k on Mac 2015-01-22 23:01:49 -08:00
Girish Ramakrishnan ec728dbf65 tls cert and key are part of data
installer has no clue about certs anymore
2015-01-22 22:47:03 -08:00
Girish Ramakrishnan d33c7ffb9b move preinstall code to separate dir 2015-01-22 22:37:04 -08:00
Girish Ramakrishnan 959981516b Update progress indicator 2015-01-22 22:31:10 -08:00
Girish Ramakrishnan a033a62e06 Shutdown requires mandatory time argument 2015-01-22 17:30:37 -08:00
Girish Ramakrishnan 3953b96626 set -u all the scripts 2015-01-22 17:04:37 -08:00
Girish Ramakrishnan 7d8575b628 Rename stopbox.sh to preinstall.sh
Also, make startbox.sh just a helper script
2015-01-22 16:24:20 -08:00
Girish Ramakrishnan 1f04a4f41c Add --revision 2015-01-22 16:24:20 -08:00
Girish Ramakrishnan 37a9df931b Rename supervisor config for oauthproxy 2015-01-22 16:24:19 -08:00
Girish Ramakrishnan 357617997e Configure nginx to show update page when stopping box
This code was moved from the installer code
2015-01-22 16:24:19 -08:00
Johannes Zellner 117f4580ab Purge the Readme.md from outdated or otherwise handled content 2015-01-23 01:12:17 +01:00
Johannes Zellner 7506746892 Remove .sh extension for executable shell scripts 2015-01-23 01:10:56 +01:00
Johannes Zellner 2a06533703 Fix the checkInstall.sh by checking the error 2015-01-23 01:08:02 +01:00
Girish Ramakrishnan b78380f8ba Add missing shift 2015-01-22 11:41:29 -08:00
Girish Ramakrishnan 382d25c192 Remove obsolete update mode 2015-01-22 11:14:37 -08:00
Girish Ramakrishnan 40b4b9624c Provide changelog array as part of box update info 2015-01-22 11:14:37 -08:00
Girish Ramakrishnan 4b75f5738f Clear app update info if response was null 2015-01-22 11:14:37 -08:00
Girish Ramakrishnan 7302546640 Allow adding a changelog 2015-01-22 11:14:33 -08:00
Girish Ramakrishnan cbf68a41e9 Send version information as part of heartbeat
Will help us analyze what version each cloudron is on
2015-01-22 10:42:36 -08:00
Girish Ramakrishnan 550eaa755c Keep package.json sorted 2015-01-22 10:34:38 -08:00
Girish Ramakrishnan 38c5110460 Add script to run gulp 2015-01-22 10:29:30 -08:00
Girish Ramakrishnan 4d4483661f Change button text depending on upgrade/update 2015-01-22 10:29:20 -08:00
Girish Ramakrishnan 1a81409006 reuse fqdn instead of querying hostname from system 2015-01-22 10:11:17 -08:00
Girish Ramakrishnan 3ef6a146f4 Create the version file for bookkeeping 2015-01-22 09:39:32 -08:00
Girish Ramakrishnan fc99bb9b96 Move postinstall scripts under setup 2015-01-22 08:45:02 -08:00
Girish Ramakrishnan b76fe0f9b2 Rename proxy.js to oauthproxy.js 2015-01-22 08:42:30 -08:00
Girish Ramakrishnan 401fb9e024 Move deploymentConfig.json into webadmin 2015-01-22 06:59:40 -08:00
Girish Ramakrishnan 24abe44327 Remove version.json and store version in cloudron.conf 2015-01-22 06:57:09 -08:00
Girish Ramakrishnan 23a483edf3 Remove dead comment 2015-01-22 06:56:34 -08:00
Johannes Zellner 97c3d691e7 Ignore webadmin source when createing a release 2015-01-22 10:24:00 +01:00
Johannes Zellner dccd64b3c3 webadmin: replace broken appstatus.hml with a static error page for now 2015-01-22 10:22:09 +01:00
Johannes Zellner 05f62a673e webadmin: concatenate all js files per page 2015-01-22 10:17:12 +01:00
Johannes Zellner 0abb15994d webadmin: concatenate all view js files 2015-01-22 10:04:08 +01:00
Johannes Zellner 7098c6f816 webadmin: split up into src/ and dist/ 2015-01-22 09:47:03 +01:00
Johannes Zellner de202aa755 webadmin: manage javascript via gulp 2015-01-22 09:37:52 +01:00
Johannes Zellner e3ca163d30 webadmin: process 3rdparty in gulp 2015-01-22 09:24:13 +01:00
Johannes Zellner 476f65b24e webadmin: Use gulp to process html files 2015-01-22 09:11:08 +01:00
Girish Ramakrishnan 4bb372122a Better log output 2015-01-21 21:31:32 -08:00
Girish Ramakrishnan 5f5a2e2e46 Clear update info when no update is available 2015-01-21 21:25:35 -08:00
Girish Ramakrishnan c8abab3bca Add --revert to remove the last release 2015-01-21 21:20:59 -08:00
Girish Ramakrishnan 9de5cf289b rename COUNT to install_count 2015-01-21 18:26:30 -08:00
Girish Ramakrishnan 7ddf858cbb postinstall.sh - Fix coding style 2015-01-21 16:59:00 -08:00
Girish Ramakrishnan 326bad1bc9 Fix coding style of postinstall helper scripts 2015-01-21 16:03:12 -08:00
Girish Ramakrishnan 06f83b51ba Only mark constants as readonly
This is just a coding style thing because bash gets all worked up
if we reuse these variable names in functions as local

example:

    func() {
        local VAR="value" # does not work even if this is local since VAR is readonly
        echo "${VAR}"
    }

    readonly VAR="deal"
    func
2015-01-21 15:52:14 -08:00
Girish Ramakrishnan ede5fe69c1 Coding style fixes to scripts 2015-01-21 15:34:09 -08:00
Girish Ramakrishnan 64333fd21d backup.sh: fix coding style 2015-01-21 15:11:11 -08:00
Girish Ramakrishnan 11cadc9f32 run.sh: Fix coding style 2015-01-21 15:07:01 -08:00
Girish Ramakrishnan 1a9589c976 publish.sh - fix coding style 2015-01-21 14:49:38 -08:00
Girish Ramakrishnan 82d14bd1a5 Use double brackets 2015-01-21 14:33:41 -08:00
Girish Ramakrishnan feb748e9b5 checkInstall.sh - fix coding style 2015-01-21 14:32:45 -08:00
Girish Ramakrishnan d149519fc1 createSourceTarball: fix coding style 2015-01-21 14:29:45 -08:00
Girish Ramakrishnan a2f7a837d0 Ping the MAIL_SERVER to ensure connectivity 2015-01-21 09:47:48 -08:00
Johannes Zellner 99283967e9 Add gulp to allow templating of static webadmin content
Currently only webadmin/error.ejs is templated. gulp html
will generated a error.html based on the values in
deploymentConfig.json

Currently we also commit the templating output to the relevant
branch (eg. for development branch master). This means if a
templated file was changed, prior to committing a change we have
to run gulp to generate the output.

Fixes #132
2015-01-21 17:09:40 +01:00
Johannes Zellner 8090f83e7e webadmin: only include yellowtent.js once 2015-01-21 16:54:10 +01:00
Johannes Zellner 48dcec8d87 Remove old oauth proxy code 2015-01-21 15:28:32 +01:00
Johannes Zellner cbefb773c9 Serve better error pages when we hit an oauth issue
Fixes #129
2015-01-21 15:26:24 +01:00
Johannes Zellner 282b5dbb15 Display error page if csrf tokens are invalid
Fixes #135
2015-01-21 13:34:12 +01:00
Johannes Zellner 51131ce346 Improve logging for updater and fix linter complaints 2015-01-21 11:22:26 +01:00
Johannes Zellner 25c0cf216f Print emails to terminal in case email sending failed and we are running locally 2015-01-21 11:06:17 +01:00
Johannes Zellner 8c865b4f3c Skip PtrRecord check in local mode 2015-01-21 11:05:54 +01:00
Johannes Zellner e565e959da Reduce logging in auth and oauth paths 2015-01-21 11:05:25 +01:00
Johannes Zellner 402f9e44d7 Support three execution environments
They can be switched using NODE_ENV.

NODE_ENV="cloudron": config.CLOUDRON is true, we are running on a deployed cloudron
NODE_ENV="test":     config.TEST is true, we are running unit tests
NODE_ENV="":         config.LOCAL is true, we are running locally
2015-01-21 10:40:48 +01:00
Girish Ramakrishnan cf6364d487 Send app up/down mail only if app is down for more than 2 mins 2015-01-20 19:27:35 -08:00
Girish Ramakrishnan 2ba0b3ca71 Send mail when app is down
Fixes #123
2015-01-20 17:34:58 -08:00
Girish Ramakrishnan 4f53871fb7 Update shrinkwrap file 2015-01-20 17:32:45 -08:00
Girish Ramakrishnan 914e57583d Rename mailAdmins to mailUserEventToAdmins 2015-01-20 16:30:33 -08:00
Girish Ramakrishnan 775ebff2c2 Sprinkle asserts in mailer code 2015-01-20 16:28:08 -08:00
Girish Ramakrishnan f77fbe6dcd Move apphealthtask to top level 2015-01-20 15:53:12 -08:00
Girish Ramakrishnan a23a654836 Run apphealthtask via supervisor 2015-01-20 15:29:05 -08:00
Johannes Zellner 91f1ebdca2 A few steps closer to running the cloudron code locally 2015-01-21 00:22:56 +01:00
Johannes Zellner b82e6045b4 Delete routes respond with 204 and no data
Fixes #136
2015-01-21 00:16:39 +01:00
Girish Ramakrishnan 140a695a69 Ignore network issues when pulling docker
postinstall.sh should never use the network in the first place. The
pull exists merely for dev convenience where we can test those images
using a forced push but not having to new build a new base image
2015-01-20 13:23:25 -08:00
Girish Ramakrishnan 988a418613 fix typo 2015-01-20 12:20:36 -08:00
Girish Ramakrishnan 1353b514f9 Just print out latest version instead of dumping entire version file 2015-01-20 10:48:38 -08:00
Girish Ramakrishnan 46e67a035b Add semver module 2015-01-20 10:48:37 -08:00
Johannes Zellner ffdaea4205 Fix crash in case the error object is not set 2015-01-20 19:38:30 +01:00
Johannes Zellner 8e3da37fc2 proxy: add missing proxy- prefix 2015-01-20 17:48:48 +01:00
Johannes Zellner 663523c7e3 Add supererror to the proxy 2015-01-20 17:42:40 +01:00
Johannes Zellner b9d770e74f webadmin: allow to print the error in case we forward to error.html 2015-01-20 17:27:24 +01:00
Johannes Zellner 6879824477 Do not fail in apptask if client id record is not found 2015-01-20 17:26:22 +01:00
Johannes Zellner 76fda3c3ab Add proxy OAuth credential handling in apptask 2015-01-20 13:01:58 +01:00
Johannes Zellner 78a625602a webadmin: force a reload from server on update 2015-01-20 11:51:58 +01:00
Johannes Zellner 81fb667e4f webadmin: guard http calls in case the response is not json 2015-01-20 11:49:57 +01:00
Johannes Zellner 26cbbd8855 webadmin: add missing errorhandler in getApps() 2015-01-20 11:28:15 +01:00
Girish Ramakrishnan 452c0cce8a Reload supervisor in startbox 2015-01-20 00:43:50 -08:00
Girish Ramakrishnan a2e185735e set -e on the scripts 2015-01-20 00:40:03 -08:00
Girish Ramakrishnan 45fcdd7eaf Add start/stop box scripts
These will be used by the installer to start and stop the box
2015-01-19 20:58:00 -08:00
Johannes Zellner a8eb90b12e Use the new OAuth proxy in nginx app template 2015-01-19 23:37:27 +01:00
Johannes Zellner 4987810ee6 Add proxy supervisor config 2015-01-19 23:27:44 +01:00
Johannes Zellner 3d49667fbf Move NODE_ENV to supervisor configs instead of app.js logic 2015-01-19 23:26:18 +01:00
Johannes Zellner d8b1687c31 Add debug messages to proxy 2015-01-19 23:19:24 +01:00
Johannes Zellner 248a3e5a4e Replace hardcoded URLs with real data from config 2015-01-19 22:24:36 +01:00
Johannes Zellner 5626f490e6 Get OAuth client ID from db 2015-01-19 21:14:22 +01:00
Johannes Zellner 328c3f137a Add database support to proxy 2015-01-19 19:39:48 +01:00
Johannes Zellner bb600a1896 Use regular OAuth flow for proxy auth 2015-01-19 19:25:40 +01:00
Johannes Zellner 697d30a0f2 Create a dummy version.json for running locally 2015-01-19 19:20:37 +01:00
Johannes Zellner 1a88433d0c Add appdb.getByHttpPort() 2015-01-19 19:18:22 +01:00
Johannes Zellner 9749c70659 Initial version of standalone OAuth proxy 2015-01-19 16:26:46 +01:00
Johannes Zellner b6e7dacf78 webadmin: add error.html in case the box server is down 2015-01-19 13:48:44 +01:00
Girish Ramakrishnan d4a493ae74 Add optional versions file argument to new 2015-01-18 15:50:25 -08:00
Girish Ramakrishnan d3623aa534 This line should not exit
Got committed by mistake
2015-01-18 11:58:00 -08:00
Girish Ramakrishnan 8cc249417e Include certificates.conf inline 2015-01-18 11:49:13 -08:00
Girish Ramakrishnan 409f919d4d Ensure top level directory is readable by others
tar --list --verbose --file=box.tar now shows:
drwxr-xr-x girishra/staff    0 2015-01-17 16:57 ./

Without this change, mktemp was creating directories have no r,x for
others and group. This meant that nginx which was running www-user
was unable to access the website inside box code.
2015-01-17 13:59:58 -08:00
Girish Ramakrishnan fd41451d55 Use system nginx service
* do not use supervisor
* nginx.conf modifications to run as daemon
2015-01-17 12:51:59 -08:00
Girish Ramakrishnan ffd6653869 Try using the system location for nginx configuration
This will help us use the system nginx service
2015-01-17 12:12:18 -08:00
Girish Ramakrishnan 3830c10090 Remove dead text 2015-01-16 23:42:03 -08:00
Girish Ramakrishnan 1babdec464 appstore now sends tls info as non-opaque data 2015-01-16 23:26:01 -08:00
Girish Ramakrishnan cff828b352 Leave a note that versions need to be semver sorted 2015-01-16 20:26:24 -08:00
Girish Ramakrishnan fa8b51139d Do not use SSLv3 2015-01-16 15:36:30 -08:00
Girish Ramakrishnan 47eb5b0612 Fix .gitattributes 2015-01-15 22:02:59 -08:00
Girish Ramakrishnan 17cd4f7fec Check length of imageName 2015-01-15 12:22:07 -08:00
Girish Ramakrishnan 8fffb9778b Add imageName to versions file
This is primarily for documentation/readability. We are able to
tell the version of installer by looking at the version file (instead
 of an image id which tell us nothing).

Fixes #120
2015-01-15 12:19:29 -08:00
Girish Ramakrishnan cb70b38e38 Add --list command 2015-01-15 12:13:32 -08:00
Girish Ramakrishnan d5f9c12042 Make new and rerelease as commands 2015-01-15 12:11:02 -08:00
Girish Ramakrishnan 0dbfce184d Ignore various paths during archiving 2015-01-15 11:39:35 -08:00
Girish Ramakrishnan edbb153c71 Move supervisor start to installer 2015-01-14 15:32:59 -08:00
Girish Ramakrishnan 9d111694ea Make redis test work on Mac
This required exporting the redis port out of the virtual box
image.
2015-01-14 14:06:05 -08:00
Girish Ramakrishnan f7639fd347 Cannot use format strings in Error object 2015-01-13 13:09:16 -08:00
Girish Ramakrishnan 6fd6d6e198 Send version instead of imageId for upgrade request 2015-01-13 10:50:10 -08:00
Girish Ramakrishnan 5db02143db Make text less verbose 2015-01-13 09:55:29 -08:00
Girish Ramakrishnan 4313f3a5ff Remove references to revision 2015-01-13 09:33:32 -08:00
Girish Ramakrishnan 2a779eb5bb Remove dead references to installer 2015-01-13 08:58:31 -08:00
Girish Ramakrishnan 70786be2e9 Remove "Update to master" button since we are not git based anymore 2015-01-13 08:57:24 -08:00
Johannes Zellner cfaaf7ebe6 Also warn on unused vars in jshint 2015-01-13 11:58:06 +01:00
Girish Ramakrishnan 8161ff2f8b Fix various bugs 2015-01-13 00:04:28 -08:00
Girish Ramakrishnan afc5745b82 Updater now passes opaque data to the installer 2015-01-12 21:40:27 -08:00
Girish Ramakrishnan ffd233b2a2 Parse variables from data argument 2015-01-12 21:32:12 -08:00
Girish Ramakrishnan 63d315ed32 Move image creation scripts to installer repo 2015-01-12 17:10:44 -08:00
Girish Ramakrishnan 101fbcdbd0 Move installer to separate repo 2015-01-12 16:58:52 -08:00
Girish Ramakrishnan e96e00fd8a Create package.json for the installer 2015-01-12 16:57:05 -08:00
Girish Ramakrishnan 71cb6753f3 Move middleware under src/ 2015-01-12 16:23:51 -08:00
Girish Ramakrishnan 9ecd85d827 Create versions.json in data dir to make tests work 2015-01-12 14:44:15 -08:00
Girish Ramakrishnan 6d30b894e5 version.json must be written in DATA dir 2015-01-12 09:42:14 -08:00
Girish Ramakrishnan 883c78e2b1 force -> rerelease 2015-01-12 09:23:34 -08:00
Johannes Zellner b6bf78b364 Using configS as this is the one used in JavaScript and the tests 2015-01-12 16:20:06 +01:00
Johannes Zellner f114e1f10c Add missing closing bracket when writing version.json 2015-01-12 16:18:26 +01:00
Johannes Zellner 0f782e8b11 Sync main script variables in postinstall.sh and installer.sh
Triggered by typo of "configs" vs. "config"
2015-01-12 15:49:06 +01:00
Girish Ramakrishnan 3629d6e1d4 Implement --new (and remove --reset) 2015-01-11 20:57:15 -08:00
Girish Ramakrishnan fba5ac81ac Set the mime type of versions file to json 2015-01-11 20:42:31 -08:00
Girish Ramakrishnan 0fe48ea40c Add --reset to start afresh from 0.0.1 2015-01-11 20:01:13 -08:00
Girish Ramakrishnan 0e210d8f7c Use gnu-getopt on Mac 2015-01-11 19:35:17 -08:00
Girish Ramakrishnan 1325451d94 Print error when wget fails 2015-01-11 19:15:02 -08:00
Girish Ramakrishnan 276a1caf02 mktemp requires prefix argument on mac 2015-01-11 19:13:18 -08:00
Girish Ramakrishnan 4433857092 Write the installed version in data/version.json
The installed version is different from package.json because the version
is bumped for plain image changes as well

The updater is now simplified to only allow updates when there is a change
in versions file.
2015-01-11 18:36:29 -08:00
Girish Ramakrishnan 0be8a1b207 Add --force and fix command line parsing
--force merely bumps the version up. This is useful when testing box
updates (like a change in docker images)
2015-01-11 12:35:49 -08:00
Girish Ramakrishnan a87ad700bd Comment out set -x 2015-01-11 00:58:09 -08:00
Girish Ramakrishnan d561649f08 New release script: publish.sh
It takes arguments --image <image_id> or --code <source_code_url>

image_id is generated using scripts/createDigitalOceanImage.sh
source_code_url is generated using scripts/createSourceTarball.sh
2015-01-11 00:44:28 -08:00
Girish Ramakrishnan 341d4638e6 Die early if there is no s3cfg 2015-01-10 21:37:31 -08:00
Girish Ramakrishnan 8b5f91da29 Auto-detect mode only if not provided in command line 2015-01-10 20:20:48 -08:00
Girish Ramakrishnan f193b889ab install server never dies
The install server is now always started by the init script.
When started up, it determines it's mode based on the exitence
of box srcdir. If it does not exist, it starts an external
listening provision/restore server. Once the appstore, provisions
the box, it switches to update mode.

If the box srcdir does exist, the installer starts out in update mode.
In update mode, the server listens on localhost:2020. In this
mode, the web interface can ask it to update the box.

Fixes #115
2015-01-09 22:25:37 -08:00
Girish Ramakrishnan 85101e1ed0 Rename UPDATE_URL to INSTALLER_UPDATE_URL 2015-01-09 21:30:56 -08:00
Girish Ramakrishnan 8a35644518 Implement tarball based installation
* The base image contains only installer code. Installer code
  can only be changed with a base image change
* The box code is download from s3 instead of git. The s3 tarball
  consists of node dependancies already

Part of #115
2015-01-09 15:25:28 -08:00
Girish Ramakrishnan 259747fcdc Check exit status immediately because of set -e 2015-01-09 13:57:55 -08:00
Girish Ramakrishnan 5112bcfdde Add bundle.sh
bundle creates a tarball out of the box source code with dependancies
and uploads it to S3

It uses s3-cli which requires a file ~/.s3cfg  like so:
[default]
access_key = AKIAJ3GNZ2C7W5XKAH7Q
secret_key = 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
2015-01-09 13:38:36 -08:00
Girish Ramakrishnan f0f996729f Add s3-cli 2015-01-09 12:43:04 -08:00
Johannes Zellner 922dc5e0e1 Use new image id for dev 2015-01-08 13:57:13 +01:00
Johannes Zellner db0f6d3631 Fix typo on postinstall script 2015-01-08 10:40:07 +01:00
Girish Ramakrishnan 1c71143dc5 Check if redis and test images are present 2015-01-07 22:31:17 -08:00
Girish Ramakrishnan e922915ead Test redis addon 2015-01-07 22:26:32 -08:00
Girish Ramakrishnan 2e64d6cadc Fix query 2015-01-07 21:14:21 -08:00
Girish Ramakrishnan d138e9676e Handle 404 in container removal 2015-01-07 21:07:58 -08:00
Girish Ramakrishnan 6a9b4a4ace Generate the redis url in addons.js instead of relying on container
The main reason for this approach is that otherwise we have to monitor the
stdout stream of the container until the url is outputted.
2015-01-07 21:01:46 -08:00
Girish Ramakrishnan 681ee6c8c4 Add password-generator module 2015-01-07 20:03:47 -08:00
Girish Ramakrishnan ce7f928e3a setup and teardown redis addon 2015-01-07 15:28:34 -08:00
Girish Ramakrishnan 1b483bfb62 Pull latest redis on every update 2015-01-07 13:50:55 -08:00
Girish Ramakrishnan 27364458a7 Fix typo 2015-01-07 13:45:55 -08:00
Girish Ramakrishnan f42c838c4a Pull in redis image 2015-01-07 13:43:53 -08:00
Johannes Zellner 2db84be8ee Sync image creation defaults with heroku config 2015-01-07 22:10:15 +01:00
Johannes Zellner a5d680fd0d Allow specify regions for cloudron images
This reuses the 'regions' argument to transfer the
new image to the list specified. The first entry is the
region, where the temporary droplet is being created.

eg. --regions="ams3 ny2 sfo1"

The image droplet is created in Amsterdam.

The script currently does not wait for all images to be
fully transferred, yet.
2015-01-07 15:57:47 +01:00
Johannes Zellner 91fe4d4f1d Further form validation for app install with ports
We have to use a custom directive to achieve the
dynamic form validation. See
http://stackoverflow.com/questions/23616578/issue-registering-form-control-with-interpolated-name#answer-23617401
2015-01-07 11:25:13 +01:00
Johannes Zellner 98d211b5a0 Add visual form validation to app install view 2015-01-07 10:23:39 +01:00
Girish Ramakrishnan 3782cbc06f Fix typo in README.md 2015-01-06 19:31:59 -08:00
Girish Ramakrishnan 71e1efcd2b barf on error 2015-01-06 11:30:08 -08:00
Girish Ramakrishnan f4cfaeacb9 Use the GNU getopt on Mac
getopts - bash built-in that supports only short form
getopt - separate program and there are two variants - GNU and BSD. The BSD one
  does not support long options.
2015-01-06 11:27:36 -08:00
Girish Ramakrishnan 7d70c52863 createDigitalOceanImage: Add --revision, --size, --region args
Possible region slugs as of today are:
nyc1
ams1
sfo1
nyc2
ams2
sgp1

Possible size slugs are:
512mb
1gb
2gb
4gb
8gb
16gb
32gb
48gb
64gb
2015-01-06 11:02:03 -08:00
Girish Ramakrishnan 2a53f8e532 Implement postgresql setup and teardown 2015-01-06 08:53:58 -08:00
Girish Ramakrishnan b8be2ab2e1 Add stubs for postgresql setup and teardown 2015-01-05 21:42:03 -08:00
Girish Ramakrishnan 39c6f1dc34 Run postgresql addon 2015-01-05 21:42:03 -08:00
Girish Ramakrishnan ae2abd9162 Add postgresql to base image 2015-01-05 21:42:03 -08:00
Johannes Zellner d905d413c0 Mention APP_SERVER_URL in Readme 2015-01-05 14:55:03 +01:00
Johannes Zellner 2eaac28576 Give full feedback to the user in setup.html
Replace the submit-time check with form validation
pre submit.
2015-01-04 18:15:49 +01:00
Johannes Zellner 90e4269428 Add initial project specific .jshintrc 2015-01-04 18:15:12 +01:00
Johannes Zellner 281903be2e Actually allow passwords as the error message says 2015-01-04 18:03:30 +01:00
Girish Ramakrishnan f8a308fb9d Order of arguments in service.sh has changed 2014-12-30 06:27:21 -08:00
Girish Ramakrishnan 08ff79ea6b addons: Remove trailing newline when parsing stdout 2014-12-29 17:29:20 -08:00
Girish Ramakrishnan d3df0b65e4 Update image 2014-12-29 12:09:53 -08:00
Girish Ramakrishnan 10be724519 Put incremental counter in the logfile instead of bash pid 2014-12-29 10:27:11 -08:00
Johannes Zellner e04575b46c Improve error reporting for setup.html 2014-12-29 12:00:11 +01:00
Johannes Zellner 0d0587d2ca Replace assert for mail dns record with 'if' for local development
The assert may have served a purpose but it was too annoying for me
locally. Can always be reverted if there is a neater solution.
2014-12-29 09:45:52 +01:00
Johannes Zellner 3134dfd390 Report more fine grained error at activation route 2014-12-29 09:43:38 +01:00
Girish Ramakrishnan eefe8e46d7 Pull the latest docker images in the postinstall script
This way an 'update' will allow us to test the docker images easily
2014-12-28 15:54:23 -08:00
Johannes Zellner 33481e70ad Remove unused includes in setup.html 2014-12-27 17:53:35 +01:00
Johannes Zellner 152cf1be46 Create separate setup angular application to avoid side effects
This also adds a loading indicator during cloudron admin
creation.
2014-12-27 17:52:09 +01:00
Johannes Zellner 6fa7d1cff9 Fix UserError reference issue 2014-12-27 17:48:52 +01:00
Johannes Zellner 6330223d20 Create .yellowtent/data in db migrate in case it does not exist 2014-12-27 17:24:13 +01:00
Johannes Zellner 6a05222722 Remove node module doubles in package.json 2014-12-27 14:00:24 +01:00
Girish Ramakrishnan c955edf362 Demux docker.exec stream output properly 2014-12-24 20:31:59 -08:00
Girish Ramakrishnan 360cdaa19a Update husky 2014-12-24 20:31:59 -08:00
Girish Ramakrishnan d15a199f72 Install memorystream 2014-12-24 20:24:21 -08:00
Girish Ramakrishnan ebb996f3a1 Upgrade dockerode 2014-12-24 18:53:34 -08:00
Girish Ramakrishnan 6f6d0bbf87 Publish newer dev image 2014-12-24 18:47:11 -08:00
Girish Ramakrishnan d04e37084d data chunks need not be line separated
This also allows the env data to be interpersed with set -e output
2014-12-24 17:53:00 -08:00
Girish Ramakrishnan 941303cefe Ignore stderr from addon script output 2014-12-22 11:30:11 -08:00
Johannes Zellner b0d2a18a94 Temporarily disable browser forward to / in case we get an oauth login error
This prevents an endless loop of redirects/forwards.
We need a real OAuth error page.
2014-12-18 08:10:27 +01:00
Johannes Zellner 721803ed84 Harmonize the webadmin oauth client secret to fix broken login 2014-12-18 08:09:30 +01:00
Johannes Zellner 47fdaf543e Adjust initial setup documentation 2014-12-17 20:10:45 +01:00
Johannes Zellner c83d482185 webadmin: add hack for autofocus on setup.html 2014-12-17 14:38:53 +01:00
Johannes Zellner a2438ed105 husky seems to not ignore missing scripts anymore 2014-12-17 14:24:28 +01:00
Johannes Zellner 182f409fd8 Update README.md info for initial setup 2014-12-17 14:23:57 +01:00
Johannes Zellner 39c428c7d8 webadmin: Fix exception due to non existing error variable in login callback 2014-12-16 11:41:05 +01:00
Girish Ramakrishnan 69ce049704 Use supererror@0.6 2014-12-10 20:10:50 +05:30
Johannes Zellner 6ac3f4eae2 Fixup the sudoers doc in README.md 2014-12-09 17:01:00 +01:00
Girish Ramakrishnan b732076999 x 2014-12-07 18:23:10 +05:30
Girish Ramakrishnan ee819921b5 Make attaches to stdout and stderr explicit 2014-12-07 18:22:38 +05:30
Girish Ramakrishnan 4503c1c6e3 Add debugs 2014-12-07 18:19:59 +05:30
Girish Ramakrishnan 7dea380ea7 Implement mysql addon 2014-11-29 22:44:57 -08:00
Girish Ramakrishnan 254cdcb147 Use safe.query to implement config.get 2014-11-29 13:08:06 -08:00
Girish Ramakrishnan 292fc5c451 Update safetydance 2014-11-29 13:04:04 -08:00
Girish Ramakrishnan 02a3df1875 Store addon settings hierarchically 2014-11-29 12:06:25 -08:00
Girish Ramakrishnan 8ee557e0a7 Keep a map of known addons 2014-11-29 11:31:55 -08:00
Girish Ramakrishnan a2ce26b4a3 Set restart policy to always so that they get restarted on reboot 2014-11-28 22:47:51 -08:00
Girish Ramakrishnan b9dfd9a1bb Fix debug messages 2014-11-28 22:37:16 -08:00
Girish Ramakrishnan 2960a3a5a3 Fix container removal
The installer script shouldn't have to remove the containers because
it's already removed in the update script
2014-11-28 22:37:10 -08:00
Girish Ramakrishnan 23b8e0d775 addons can be undefined 2014-11-28 21:46:11 -08:00
Girish Ramakrishnan 7db03535d1 Format code better 2014-11-28 16:55:00 -08:00
Girish Ramakrishnan 853621cc1d Make sendmail an addon as well 2014-11-28 16:54:02 -08:00
Girish Ramakrishnan 4a0065e8d4 validate the manifest to contain an optional array of strings for addons 2014-11-28 16:44:21 -08:00
Girish Ramakrishnan 5df0aed9fa Add addons to manifest file 2014-11-28 16:28:30 -08:00
Girish Ramakrishnan 16dd15f7b4 Use addons.getEnvironment in apptask 2014-11-28 16:19:25 -08:00
Girish Ramakrishnan 87beff97c7 Add getters/setter for addon config 2014-11-28 12:53:07 -08:00
Girish Ramakrishnan 93310f53d4 Do not use get/add pattern. It is racy
If we really want credentials to be only once, this should possibly
come from the schema
2014-11-28 12:50:38 -08:00
Girish Ramakrishnan 8aa7ae3ff6 Delegate setup of addons to addons code 2014-11-28 10:48:53 -08:00
Girish Ramakrishnan f8bd298d2c Initial step in making oauth as an addon
move oauth allocation code to addons.js
2014-11-28 10:04:42 -08:00
Girish Ramakrishnan c29e8bc47c Add appAddonConfigs table 2014-11-28 09:54:54 -08:00
Girish Ramakrishnan 311fd6793a Announce on startup 2014-11-27 21:13:42 -08:00
Girish Ramakrishnan 77e9f0d4ca Set MYSQL_ROOT_HOST to allow root connections from that host 2014-11-27 21:13:39 -08:00
Girish Ramakrishnan 32c4a01a4e Get hostname and port from DOCKER_HOST env 2014-11-27 16:52:15 -08:00
Girish Ramakrishnan d0a565948a Make tests work with boot2docker 1.3.x
boot2docker now runs https based docker daemon :(
2014-11-27 16:44:46 -08:00
Girish Ramakrishnan 6cd562a683 Pass real docker connect options to test code 2014-11-27 16:29:55 -08:00
Girish Ramakrishnan b8a3d9de0a Move docker connection creation logic to separate file 2014-11-27 16:10:43 -08:00
Girish Ramakrishnan e30361f252 Add missing \ 2014-11-26 17:13:59 -08:00
Girish Ramakrishnan a572914231 Install pwgen in base image required by postinstall script 2014-11-26 17:09:27 -08:00
Girish Ramakrishnan 6e4bdcbe7a New release 2014-11-26 16:59:08 -08:00
Girish Ramakrishnan 44ad297d15 Add hack to update installer as well
Otherwise it's painful to test installer changes
2014-11-26 16:33:43 -08:00
Girish Ramakrishnan 3ebaf951f2 Simplify log filename 2014-11-26 16:28:10 -08:00
Girish Ramakrishnan fc4614f583 Fix debug 2014-11-26 16:18:27 -08:00
Girish Ramakrishnan b8fc8639a7 Setup mysql addon
Also, move the deletion of containers into the installer script.
This is the place where supervisor is stopped, so it's a good idea
to stop the apps and containers there as well.

The actual container removal happens in postinstall because the
postinstall can decide to reuse apps if it wants
2014-11-26 16:03:32 -08:00
Girish Ramakrishnan b28d64dc57 Install mysql addon image 2014-11-26 14:25:23 -08:00
Girish Ramakrishnan 2f3c2ff108 Remove unused requires 2014-11-25 10:34:29 -08:00
Girish Ramakrishnan 8c9c9362b0 Add csurf to standard middleware 2014-11-25 10:33:02 -08:00
Girish Ramakrishnan b066b22c47 Fix debugs 2014-11-25 10:31:04 -08:00
Girish Ramakrishnan b4850cc9d0 Escape $ and fix heremarker 2014-11-24 21:15:55 -08:00
Girish Ramakrishnan b795684791 Only add webadmin client entry in test mode 2014-11-24 19:25:29 -08:00
Girish Ramakrishnan 7c54335746 Add webadmin client correctly in the database 2014-11-24 19:21:42 -08:00
Girish Ramakrishnan f70953063e Kill apps only if there are any 2014-11-24 18:07:23 -08:00
Girish Ramakrishnan a43ef96c99 set the modes for internal bash script 2014-11-24 18:03:07 -08:00
Girish Ramakrishnan b9a5352a46 api server does not impose limit anymore 2014-11-24 16:59:22 -08:00
Girish Ramakrishnan d653c7c9b9 Move postinstall.sh to the top
src/scripts/* is meant for scripts that are invoked by the server
code.
2014-11-24 16:38:15 -08:00
Girish Ramakrishnan da8aa6f5c7 Use node-proxy for private app proxy
Part of #106
2014-11-24 16:28:19 -08:00
Girish Ramakrishnan 172f34ed39 Remove logApiRequests config option 2014-11-24 08:39:58 -08:00
Girish Ramakrishnan 7e15cab21a Add tests for admin user 2014-11-24 08:33:52 -08:00
Girish Ramakrishnan f1671697bb Add userdb tests 2014-11-24 08:26:17 -08:00
Girish Ramakrishnan 639d5fd1ad userInfo is not sent as part of activation anymore 2014-11-23 22:59:41 -08:00
Girish Ramakrishnan 0a98ba5159 Fix circular dep 2014-11-23 22:57:58 -08:00
Girish Ramakrishnan bf191d56af Make Server code function based
Use the class based pattern only if we expect multiple instances
2014-11-23 22:45:01 -08:00
Girish Ramakrishnan 4844f7899c createadmin -> cloudron/activate 2014-11-23 22:06:08 -08:00
Girish Ramakrishnan 0eea3f0e57 Use routes.user.verifyPassword to verify password 2014-11-23 21:39:10 -08:00
Girish Ramakrishnan 04c57ee196 Better error handling 2014-11-23 21:35:57 -08:00
Girish Ramakrishnan 51a80a5c36 Add userdb.adminCount 2014-11-23 19:57:56 -08:00
Girish Ramakrishnan c1ad249eea Merge firsttime and version routes into status 2014-11-23 19:42:33 -08:00
Girish Ramakrishnan aec65fadd8 Move version into cloudron routes 2014-11-23 19:11:40 -08:00
Girish Ramakrishnan c17e063025 namespace apis under cloudron/ 2014-11-23 18:50:24 -08:00
Girish Ramakrishnan aaf143736a Add a FIXME 2014-11-23 18:43:46 -08:00
Girish Ramakrishnan 8d9f57e0b1 Fix url (plural) 2014-11-23 18:37:26 -08:00
Girish Ramakrishnan 3df66f2b2e Use plural in routes 2014-11-23 18:32:41 -08:00
Girish Ramakrishnan 8546387aee Remove distracting comments 2014-11-23 18:15:24 -08:00
Girish Ramakrishnan 8b98e7102d Initialize auth module in start 2014-11-23 18:10:13 -08:00
Girish Ramakrishnan 0ef7b3ebf6 Make the uninitialize funcs async 2014-11-23 14:23:17 -08:00
Girish Ramakrishnan 9a1013896c Make initialize async 2014-11-23 14:15:29 -08:00
Girish Ramakrishnan 959ae1882a Remove existing containers and restore them
This is required should an update change the nginx config or docker
launch config
2014-11-23 13:22:44 -08:00
Girish Ramakrishnan b53db12cc8 Set X-Cloudron-Proxy-Port only for oauth proxy case 2014-11-23 12:40:16 -08:00
Girish Ramakrishnan 4bdbfeff00 Remove unused variables 2014-11-23 12:24:22 -08:00
Girish Ramakrishnan 497766082e Rename proxy to applicationProxy
A future patch is going to use the name proxy for something else :-)
2014-11-23 11:47:22 -08:00
Girish Ramakrishnan 214a3e781d Set busy timeout on main connection as well
cool fact: In sqlite, every command is actually wrapped with an automatic
transaction.
2014-11-23 09:45:49 -08:00
Girish Ramakrishnan 238606aff8 Add code to debug transaction timings 2014-11-23 09:28:54 -08:00
Girish Ramakrishnan 82f462b0cf Rename newTransaction to beginTransaction 2014-11-23 08:58:46 -08:00
Girish Ramakrishnan 4c7a6c6ad6 Update and upgrade both return 202 2014-11-23 01:04:13 -08:00
Girish Ramakrishnan c5af7a53d5 Update supererror version 2014-11-23 00:57:24 -08:00
Girish Ramakrishnan 62335b35cc Keep trying forever until we get the versions file 2014-11-23 00:41:26 -08:00
Girish Ramakrishnan 9598ae77d0 Add latest supererror until PR 2 is merged 2014-11-23 00:23:48 -08:00
Girish Ramakrishnan d4c7f5a8f6 Enable splatchError option of supererror 2014-11-23 00:16:00 -08:00
Girish Ramakrishnan 97f6a1a8ea Rename internalError to nestedError 2014-11-23 00:11:46 -08:00
Girish Ramakrishnan 2794be118e Rename restrictAccessTo to accessRestriction
Doing a db migration for a column rename is too complex in sqlite,
so the initial schema itself is modified.
(you have to create a new table and copy things over)
2014-11-22 22:16:42 -08:00
Girish Ramakrishnan 3cf53820ff Update favicon module 2014-11-22 19:18:04 -08:00
Girish Ramakrishnan a965756e53 Fix deprecation
https://github.com/expressjs/body-parser/blob/3f1b02247702c2966d33ee73610a98d54cf32fe8/lib/types/urlencoded.js#L41-L44
2014-11-22 19:16:34 -08:00
Girish Ramakrishnan bbbdc68a95 Update to latest connect-lastmile 2014-11-22 19:13:21 -08:00
Girish Ramakrishnan e6301af1d5 More module updates 2014-11-22 18:45:59 -08:00
Girish Ramakrishnan 633a20f225 Update packages 2014-11-22 18:40:21 -08:00
Girish Ramakrishnan 0c85fbb453 Output connect-lastmile logs as well 2014-11-22 17:32:58 -08:00
Girish Ramakrishnan 723f6d73ce Use connect-lastmile for express last mile response handling 2014-11-22 17:29:34 -08:00
Girish Ramakrishnan ca6664d619 Use Http* classes to respond to requests 2014-11-22 17:26:24 -08:00
Girish Ramakrishnan f0c5f064fd Add express handlers to middlewares 2014-11-22 17:20:22 -08:00
Girish Ramakrishnan 755146fcc4 Delete any cookie before forwarding to graphite 2014-11-22 17:06:31 -08:00
Girish Ramakrishnan 49ea1c20cb Move graphite proxy to separate routes file 2014-11-22 16:52:02 -08:00
Girish Ramakrishnan ae45f1616a Add a FIXME to remove unauth graphite calls before release 2014-11-22 11:15:06 -08:00
Girish Ramakrishnan 9655943cf6 util.format is our friend 2014-11-22 10:34:07 -08:00
Girish Ramakrishnan c63cf55dba Output the response body 2014-11-22 10:29:13 -08:00
Girish Ramakrishnan b67a87fd16 Fix call to missing callback 2014-11-22 10:26:16 -08:00
Girish Ramakrishnan d9725be93c supervisor config has moved 2014-11-22 10:15:11 -08:00
Girish Ramakrishnan ba18a53357 Remove unused delay 2014-11-22 00:28:39 -08:00
Girish Ramakrishnan 94ca4c2402 Remove dead reference to installer 2014-11-22 00:05:45 -08:00
Girish Ramakrishnan 8c504952fb Fix path to supervisor script 2014-11-21 23:37:50 -08:00
Girish Ramakrishnan d64786d98f Remove unused dir 2014-11-21 23:32:10 -08:00
Girish Ramakrishnan 329e3b068a Fix template path 2014-11-21 23:30:34 -08:00
Girish Ramakrishnan d8f871fb6b Move nginx configs into postinstall 2014-11-21 23:27:19 -08:00
Girish Ramakrishnan 620e8bc1af Move supervisor scripts into postinstall 2014-11-21 23:18:11 -08:00
Girish Ramakrishnan 79d5135946 Only mark apps for restore when restoring
Otherwise, it ends up restoring already running apps for the update
case.
2014-11-21 23:08:37 -08:00
Girish Ramakrishnan a3eda9c8a0 Set cwd to dirname 2014-11-21 22:57:22 -08:00
Girish Ramakrishnan 1a290968ae stdout_logfile needs absolute path 2014-11-21 22:53:46 -08:00
Girish Ramakrishnan 9b4965b22f Set logfile name explicitly
From the docs:
AUTO log files and their backups will be deleted when supervisord restarts.

This has the result that log files disappear after every update
2014-11-21 22:37:16 -08:00
Girish Ramakrishnan 29eaeb1609 Output lastmile debug output 2014-11-21 21:30:32 -08:00
Girish Ramakrishnan bec9baf5d0 Namespace installer debugs 2014-11-21 21:29:34 -08:00
Girish Ramakrishnan 1e6c5cce34 Distinguish hostnames and domain names
hostname - name of an actual addressable thing on the internet
domain name - the name of a network
root domain - this is actually "." or empty. the top most thing
tld, gtld - this is thing under root domain which has an entry in the root servers - com, co.uk etc
fqdn - this is really fully qualified hostname. so the full name in a host
sub domain - refers to a network rather a hostname. example.foo.com is a sub domain iff it's a network. otherwise it would be a hostname. foo.com is a subdomain of com.
zone - a concept of DNS where entries under a sub domain are delegated to a nameserver.
2014-11-21 21:01:56 -08:00
Girish Ramakrishnan 8aa973511a Move supervisor restart to supervisor setup script 2014-11-21 15:57:54 -08:00
Girish Ramakrishnan d5b5c3f28d Fix typo 2014-11-21 15:55:03 -08:00
Girish Ramakrishnan 6dbd6b3607 Add debug 2014-11-21 15:52:52 -08:00
Girish Ramakrishnan f44436ca18 Add callback arg to start 2014-11-21 15:50:43 -08:00
Girish Ramakrishnan 21bd146a3b Make setup script executable 2014-11-21 14:24:58 -08:00
Girish Ramakrishnan f4f24e7347 Make installer run across reboots
The installer is run in provision-mode in the init script

The installer is run as update-mode by supervisor by postinstall

Previously, we used to run the *same* installer code, which was
part of the base image, in both modes. However, after a reboot,
the old installer code is 'gone' and thus we start running the
newer installer code. This distinction is very subtle and this change
makes it more obvious.

If we want the same installer code to run in both modes, then we
really need to split out installer into a separate repository. This
can be done if required later.

This also makes it clear that announce is a feature of the provision
mode.
2014-11-21 14:18:59 -08:00
Girish Ramakrishnan 04cef32cdd Rename internal to update and external to provision 2014-11-21 14:09:19 -08:00
Girish Ramakrishnan b3569ee57f Add test for internal update server 2014-11-21 14:06:24 -08:00
Girish Ramakrishnan 1d4489468b Add test for restore 2014-11-21 14:03:02 -08:00
Girish Ramakrishnan 1f846c3e74 Add internal server tests 2014-11-21 13:57:51 -08:00
Girish Ramakrishnan a3ec0ec4cc Refactor code to start servers separately 2014-11-21 13:44:30 -08:00
Girish Ramakrishnan d05f0d8abb Move announce code to separate file 2014-11-21 11:10:05 -08:00
Girish Ramakrishnan bf1e217144 Make updates go through the installer
Fixes #114
2014-11-20 22:20:35 -08:00
Girish Ramakrishnan 0cd59e658e Create servers separately
This is because the routes are different in internal and external mode
2014-11-20 22:02:32 -08:00
Girish Ramakrishnan d474a8834b Move installer api under /api/v1/installer/
This namespaces the API and makes it easily routable through nginx (if required)
2014-11-20 22:02:07 -08:00
Girish Ramakrishnan d716518b99 Update versions-dev.json 2014-11-20 21:14:15 -08:00
Girish Ramakrishnan b81a431dcd Keep install server running after install/restore
Part of #114
2014-11-20 20:15:50 -08:00
Girish Ramakrishnan 3fc52b640d Print revision in installer script 2014-11-20 17:01:49 -08:00
Girish Ramakrishnan 6cfb1ba949 Move requireAdmin in user routes 2014-11-20 16:59:17 -08:00
Girish Ramakrishnan 3807e98f6a Print update args 2014-11-20 16:59:17 -08:00
Girish Ramakrishnan aefb1f1c07 Updater needs to pass the version instead of revision 2014-11-20 16:57:07 -08:00
Girish Ramakrishnan 63c775b0ae Provision the box using version instead of revision
This allows the installer to be more cognizant of version specific
values if required (like imageId)
2014-11-12 21:53:32 -08:00
Girish Ramakrishnan 23045306a9 Check the type of fields instead of truthiness check 2014-11-12 20:15:24 -08:00
Girish Ramakrishnan 5c8207a9e5 digitalocean requires imageId to be number
From the docs, "number (if using an image ID), or String (if using a public image slug)"
2014-11-12 19:12:30 -08:00
Girish Ramakrishnan 0e5563c3ff Fix test name 2014-11-12 13:15:32 -08:00
Girish Ramakrishnan d4ee1c59f1 Use connect-lastmile in installer 2014-11-12 13:15:29 -08:00
Girish Ramakrishnan 0b16e95b89 Add connect-lastmile 2014-11-12 12:56:33 -08:00
Girish Ramakrishnan 51764191e3 Set the content-type for responses to text 2014-11-12 12:12:46 -08:00
Girish Ramakrishnan 0525ccc4a4 Disable metadata API access to non-root users
The only reason not to use the metadata completely for provisioning
is because many VPS providers do not provide it.

If we rely on a metadata API, we can pretty much remove the installer
server
2014-11-10 16:26:56 -08:00
Girish Ramakrishnan 9309c89a1a Appstore name is not part of image anymore 2014-11-09 10:06:23 -08:00
Girish Ramakrishnan bea71b35f6 Move to v2 api 2014-11-09 10:04:29 -08:00
Girish Ramakrishnan e07ee3e3c8 Do not validate username and password during verification 2014-11-07 21:47:01 -08:00
Girish Ramakrishnan 7f00334437 Handle NOT_FOUND errors 2014-11-07 21:38:15 -08:00
Girish Ramakrishnan 8edcdfb6ea Actually verify password
Fixes #113
2014-11-07 21:30:16 -08:00
Girish Ramakrishnan ec35fcb9a8 Move requirePassword middleware to routes.user 2014-11-07 20:59:25 -08:00
Girish Ramakrishnan 91fa0559f2 Validate new password 2014-11-07 06:32:01 -08:00
Girish Ramakrishnan 9d3199527b Add asserts 2014-11-07 06:27:53 -08:00
Girish Ramakrishnan 08111210a1 Make some TODOs as FIXME 2014-11-06 23:27:14 -08:00
Girish Ramakrishnan 729024b9d8 Convert location to lower case 2014-11-06 23:24:02 -08:00
Girish Ramakrishnan dea72b786e Make a TODO out of a FIXME 2014-11-06 23:22:53 -08:00
Girish Ramakrishnan 8c6a4eceb3 Handle possible errors in commit and rollback 2014-11-06 23:15:56 -08:00
Girish Ramakrishnan 87a8f819c6 Add test to check conflicting location fails 2014-11-06 22:58:48 -08:00
Girish Ramakrishnan ade8ccd90a Remove vbox port bindings forwarding when stopping container 2014-11-06 19:18:17 -08:00
Girish Ramakrishnan 0bb9c321bd Remove VBox forwarding when unconfiguring nginx 2014-11-06 19:12:47 -08:00
Girish Ramakrishnan 967981838f Fix REST response codes
200 - OK
201 - Created (immediately)
202 - Accepted (for future)
204 - Empty response, action done

Fixes #89
2014-11-06 18:44:49 -08:00
Girish Ramakrishnan c24488f90f Remove volume code
Most of it is moved to syncer-app
2014-11-06 18:27:47 -08:00
Girish Ramakrishnan 437d224994 Use validator to validate email 2014-11-06 17:54:49 -08:00
Girish Ramakrishnan c803f66e9a coding style 2014-11-06 17:06:02 -08:00
Girish Ramakrishnan 0165fb412a ARGUMENTS -> BAD_FIELD 2014-11-06 17:02:07 -08:00
Girish Ramakrishnan 25836969e7 Add validator module 2014-11-06 16:57:24 -08:00
Girish Ramakrishnan ed07894c18 Add validation for username and password 2014-11-06 16:53:25 -08:00
Girish Ramakrishnan f9de936e7f Add asserts 2014-11-06 11:52:02 -08:00
Girish Ramakrishnan 250b23b7c1 validate restrictAccessTo 2014-11-06 11:48:38 -08:00
Girish Ramakrishnan 0d938c0d74 Fix error handling 2014-11-06 11:26:50 -08:00
Girish Ramakrishnan ac93de6c18 Do not exit in restore, otherwise the tests quit in the middle 2014-11-06 09:53:20 -08:00
Girish Ramakrishnan b25a9767ef Add test to verify that invalid json does not crash server
express ensures that req.body is { } with invalid json

If not, we have to check assert(body && typeof body === 'object').
This is because typeof null is 'object'.
2014-11-06 09:47:11 -08:00
Girish Ramakrishnan 43aba840a9 Add missing require 2014-11-06 09:41:47 -08:00
Girish Ramakrishnan 92fdc2c84d Check body param type in apps.configure 2014-11-06 09:36:44 -08:00
Girish Ramakrishnan aa585dc4f0 Check the data type of values in the post request 2014-11-06 09:34:48 -08:00
Girish Ramakrishnan fa58516421 Fixup Error classes 2014-11-06 06:50:16 -08:00
Girish Ramakrishnan 5c77d82335 Move to string based error codes 2014-11-05 22:00:42 -08:00
Girish Ramakrishnan 0205e6cfa1 Fix DatabaseError to take errorOrMessage 2014-11-05 15:54:31 -08:00
Girish Ramakrishnan 86c36efcf8 Call callback on error 2014-11-05 14:58:33 -08:00
Girish Ramakrishnan 1fb701ba23 Fix routes/* error handling 2014-11-05 14:50:30 -08:00
Girish Ramakrishnan 48b51e1190 Fix routes/apps error handling 2014-11-05 14:30:31 -08:00
Girish Ramakrishnan a393fda9e0 Use instanceOf instead of util.inherits 2014-11-05 14:27:47 -08:00
Girish Ramakrishnan aa968f903f Change assert pattern coding style 2014-11-05 14:07:50 -08:00
Girish Ramakrishnan c311d48310 Volumes code has been moved out of box 2014-11-05 14:03:52 -08:00
Girish Ramakrishnan fc86bb2262 boxupdate route has been renamed in appstore 2014-11-05 09:45:55 -08:00
Girish Ramakrishnan 9306a7a127 Fix error handling
Express uses res.status. HttpSuccess and HttpError now use the same property
instead of statusCode

HttpError now requires an error object or string as second argument

HttpError now marks all calls with error object as internal errors

Everything else should have a proper message anyway (giving proper
contextual information). This way we don't leak random app information
through our REST API.

HttpSuccess has optional body

204 does not require a body
2014-11-04 15:29:31 -08:00
Girish Ramakrishnan 399d836c18 Better debug messages 2014-11-04 11:31:29 -08:00
Girish Ramakrishnan a6ea73d41a initialize passport explicitly 2014-11-04 11:06:04 -08:00
Girish Ramakrishnan 07e5dc145d Move syncer code to separate repository 2014-11-04 09:30:02 -08:00
Girish Ramakrishnan 7db983afc0 Do not run the installer scripts in test mode 2014-11-04 09:30:01 -08:00
Girish Ramakrishnan 2249da603b Do not dns mail records in test mode 2014-11-04 09:30:01 -08:00
Girish Ramakrishnan 6e0aab8bf8 Make release 2014-11-04 00:02:06 -08:00
Girish Ramakrishnan 9f09f8e7a8 Pass boxVersionsUrl to update script 2014-11-03 22:47:39 -08:00
Girish Ramakrishnan e7fdaac4a1 token is already set when cloudron runs 2014-11-03 22:39:14 -08:00
Girish Ramakrishnan 01c19726f0 Make isDev a feature of the updater
Makes for one less provisioning parameter
2014-11-03 14:19:12 -08:00
Girish Ramakrishnan 2f8f3ee030 Get BOX_VERSIONS_JSON as provision parameter 2014-11-03 14:15:37 -08:00
Girish Ramakrishnan 9b496ff3ac Add separate versions file for dev and stable 2014-11-03 13:32:53 -08:00
Girish Ramakrishnan 1cfe0bfa5f Ensure package.json version is the latest 2014-11-03 13:25:19 -08:00
Girish Ramakrishnan cff2051899 Make 0.2 release 2014-11-03 08:51:48 -08:00
Girish Ramakrishnan 61cbebf7ae retry backup download because of flaky network 2014-11-01 22:47:03 -07:00
Girish Ramakrishnan cd6b034410 ensure next <= current version 2014-11-01 22:16:48 -07:00
Girish Ramakrishnan a7367cb352 Initial update check is 10 seconds after startup 2014-11-01 10:20:17 -07:00
Girish Ramakrishnan 4d101e7972 webadmin: Use box.upgrade instead of imageId 2014-11-01 09:40:22 -07:00
Girish Ramakrishnan d05a73d4ee Check isDev key existence 2014-10-31 23:11:12 -07:00
Girish Ramakrishnan ef40c12554 This marks the first version the updater works 2014-10-31 22:37:17 -07:00
Girish Ramakrishnan e1a35ce514 supervisord init script lies about stopping
Check the pidfile by hand to see if the process is running.

the pidfile sometimes exists and sometimes not when stopping :(
2014-10-31 22:15:37 -07:00
Girish Ramakrishnan 49ff6150d5 Add a comment about the placement of export 2014-10-31 17:53:23 -07:00
Girish Ramakrishnan b039123daa Make updates to use the installer code 2014-10-31 17:50:32 -07:00
Girish Ramakrishnan cf3e98a3f6 Start supervisor by default in the base image
This is nice to have for the update case where we can just stop
all the apps
2014-10-31 16:59:02 -07:00
Girish Ramakrishnan d98bd4c84a Split the app update and box update checker 2014-10-31 16:57:02 -07:00
Girish Ramakrishnan c14e6d1a15 Fix various bash programming errors
1) getopt needs a shortform -o.
2) Need to break out when $1 becomes null
3) remove unnecessary semicolons
4) some magic incantation to pass all args to the postinstall script
2014-10-31 16:28:59 -07:00
Girish Ramakrishnan 527818feda restoreUrl can be empty 2014-10-31 13:43:31 -07:00
Girish Ramakrishnan 95401bf4f2 env is not used anymore 2014-10-31 13:41:00 -07:00
Girish Ramakrishnan 7e748f6fd5 Use cmd line args instead of env vars
It's more work to get env vars through sudo. Besides, env vars
prevent inadvertent collisions with bash variable names anyway.
2014-10-31 12:54:25 -07:00
Girish Ramakrishnan 8726e5eabe backup can now take a callback since it does not restart server 2014-10-31 07:09:16 -07:00
Girish Ramakrishnan 0f1e951499 Run installer as sudo
This is required for the update code to work
2014-10-31 07:01:15 -07:00
Girish Ramakrishnan 8bffd93ab7 Fix typo 2014-10-31 06:59:50 -07:00
Girish Ramakrishnan a393ec63b6 coding style: prefix module globals with g 2014-10-30 19:14:41 -07:00
Girish Ramakrishnan 542062e07f Make release 2014-10-30 17:52:34 -07:00
Girish Ramakrishnan bb646c3c89 APPSTORE_URL is not part of image anymore
The installer now gets the appStoreUrl from the droplet metadata
2014-10-30 14:02:12 -07:00
Girish Ramakrishnan d44c22e3b0 Get appServerUrl from metadata if not provided in cmd line
This allows us to use the same image for both dev and prod.
provisioning is what decides whether something is a dev or prod.
2014-10-30 13:58:59 -07:00
Girish Ramakrishnan 6ab1763d0a restore.sh is not used anymore 2014-10-30 06:21:09 -07:00
Girish Ramakrishnan a8091b6d48 check if package.json version exists in versions.json 2014-10-29 22:40:40 -07:00
Girish Ramakrishnan 30846e7887 Fix code formatting 2014-10-29 22:37:57 -07:00
Girish Ramakrishnan 601df4b515 installer.js should return correct error codes 2014-10-29 22:02:59 -07:00
Girish Ramakrishnan 3e28f86b6c Return success immediately
There is no telling how long the install script takes because
DO networking is so flaky.

This also allows appstore to have a short timeout for the provision
call.
2014-10-29 21:52:28 -07:00
Girish Ramakrishnan 1879b18c6f Stop announce once we get a request 2014-10-29 21:52:25 -07:00
Girish Ramakrishnan 52573f3745 Do not remove config dir itself 2014-10-29 21:12:47 -07:00
Girish Ramakrishnan 13d3b40992 restore: DATA_DIR itself cannot be removed 2014-10-29 20:56:26 -07:00
Girish Ramakrishnan 2b41aa9440 Add installer tests 2014-10-29 20:30:55 -07:00
Girish Ramakrishnan b36fe96040 Fix up package.json 2014-10-29 18:53:26 -07:00
Girish Ramakrishnan 779c9c1392 Rework provisioning
The previous provisioning scheme had issues with updates. Because,
configuration was already part of the base bootstrap, providing an
update meant creating a new image.

The key insight in this new provisioning scheme is to treat config
files used by our code as something that can always be regenerated
on demand. Every update kills the config and recreates it all over.

Current flow is thus:
1. bootstrap init code starts up install/server.js. This server merely
   listens for provision and restore calls.

2. The installer calls install.sh. This script simply checks out the
   requested revision. Note that the installer is from what is in the
   base image. Changing the installer requires a new base image. If a
   restore url is provided, this downloads the restore data.

3. The install.sh calls postinstall.sh of the requested revision.
   It setups the code calling npm install, migrates any data and creates
   configs - collectd, graphite, nginx etc. This also creates cloudron.conf.

   Because postinstall.sh is from requested revision, all the data, configs
   are all based on the requested revision.

Note that installation of new packages should be done at base image creation
time.

The changes also provide separation of announce and hearbeat calls:
    - announce is for cloudron coming up and installer running
    - heartbeat is for box server running

TODO:
    appstore url is only part of image becase installer needs to announce.
    This can be fixed by moving to user metadata

Fixes #110
2014-10-29 15:01:40 -07:00
Girish Ramakrishnan c49de62f25 Move middleware to top level
This allows it to be shared with other servers like the install server
2014-10-28 00:20:44 -07:00
Girish Ramakrishnan 743b40df8e adminOrigin is not sent as part of provision anymore
It was redundant
2014-10-27 23:54:10 -07:00
Girish Ramakrishnan cacf1bdb54 Metadata gets saved as x-amz-meta-content-type 2014-10-27 14:27:14 -07:00
Girish Ramakrishnan 7888256349 Add 0.7.0 and cleanup version.json 2014-10-27 14:22:17 -07:00
Girish Ramakrishnan 9d695572ec Sanity check versions.json before upload 2014-10-27 14:22:05 -07:00
Girish Ramakrishnan 84122b1acb Add script to publish releases to s3 2014-10-27 14:14:26 -07:00
Girish Ramakrishnan 3c341f25dd Add aws-sdk 2014-10-27 14:05:06 -07:00
Girish Ramakrishnan f737e4f368 Bump revision for testing 2014-10-26 22:58:02 -07:00
Girish Ramakrishnan c1e9707df6 backupurl now requires the box version
The box version is encoded in the url in s3 so that the appstore
can restore the backup with this as the 'preferred' version.
2014-10-26 19:25:54 -07:00
Girish Ramakrishnan c625e7ca76 Rename bootstrap init script to cloudron-bootstrap 2014-10-26 14:38:43 -07:00
Girish Ramakrishnan f43f17a7e7 Fix app.js to match new config.js API 2014-10-26 14:18:37 -07:00
Girish Ramakrishnan b90cd29888 Add missing require 2014-10-26 14:03:30 -07:00
Girish Ramakrishnan ad267ccd2e Move announce and restore routes to installer 2014-10-26 12:32:20 -07:00
Girish Ramakrishnan b5ba661bb9 Move announce code to installer.js 2014-10-26 12:08:10 -07:00
Girish Ramakrishnan f97afb8a99 Updater is not a class anymore, just a singleton 2014-10-26 11:32:47 -07:00
Girish Ramakrishnan c781d0201b box versions url is a constant 2014-10-26 11:19:35 -07:00
Girish Ramakrishnan 93cef78c86 Move VERSIONS.json to s3
https://s3.amazonaws.com/cloudron-releases/versions.json
2014-10-25 10:36:24 -07:00
Girish Ramakrishnan 9d5ff39e0e Append restore script log output 2014-10-25 00:50:49 -07:00
Girish Ramakrishnan 4ac6a3e8fa Unset content-type header
When using curl -T, the content-type header is not set and upload
works fine. When using --data-binary, curl sets it to application/x-www-form-urlencoded
which s3 doesn't like.
2014-10-25 00:32:57 -07:00
Girish Ramakrishnan 93535313b3 Append backup logs to same file 2014-10-25 00:21:16 -07:00
Girish Ramakrishnan 61ee27d213 Use btrfs snapshots for backup
backup does not restart containers or the box anymore

The backup has exact same effect as powering off a machine at
that point

Fixes #108
2014-10-24 23:42:44 -07:00
Girish Ramakrishnan 884e88d736 Remove verbose logs for npm install 2014-10-24 23:17:24 -07:00
Girish Ramakrishnan fe17cbce50 data dir is now a btrfs subvolume
This makes it snapshottable
2014-10-24 23:01:23 -07:00
Girish Ramakrishnan b589a26991 Rename postinstall script to migrate_data
postinstall script is run automatically after npm install ends.
This create unnecessary confusion and we want to have more
control over when exactly the migration happens
2014-10-24 22:56:28 -07:00
Girish Ramakrishnan fae156366c Move to btrfs
The docker data as well as user (yellowtent) home is now btrfs.
This will greatly help us in backups. We simply take a btrfs
snapshot and back that up. This way we don't need to stop all
containers and simulates the same thing as a power outage.

Part of #108
2014-10-24 22:17:46 -07:00
Girish Ramakrishnan 80f82883cd Query snapshot id before destroying droplet
Allows us to work in parallel as the droplet is being destroyed
2014-10-24 19:57:28 -07:00
Girish Ramakrishnan 09d24f687b Cleanup config.js code 2014-10-24 18:42:55 -07:00
Girish Ramakrishnan 3e228eb995 Separate data part of config.js 2014-10-24 18:33:20 -07:00
Girish Ramakrishnan 7ec8b3f5ea Make config.baseDir a function 2014-10-24 17:57:07 -07:00
Girish Ramakrishnan 15df364c91 Move all configs to configs/
This makes it easy to delete them in a single shot
2014-10-24 17:45:55 -07:00
Girish Ramakrishnan 049912c096 Sleep a couple of minutes before retrying again 2014-10-24 17:26:14 -07:00
Girish Ramakrishnan 624b4a03ca Use package.json to determine the version
VERSIONS.json is really mean for the updater to get update changes.
Let's not mix the two.
2014-10-24 16:57:29 -07:00
Girish Ramakrishnan 0f8bab034f Show 'upgrade' when image id is as part of update info 2014-10-23 16:30:38 -07:00
Girish Ramakrishnan e62d622e12 Really Finish sorting all requires 2014-10-23 16:08:58 -07:00
Girish Ramakrishnan 7f5ec04a73 Finish sorting all requires 2014-10-23 14:51:00 -07:00
Girish Ramakrishnan 95ef3b9d2b Open App Store in new window 2014-10-23 14:31:53 -07:00
Girish Ramakrishnan 10218c7ecd Make tests pass 2014-10-23 14:30:31 -07:00
Girish Ramakrishnan e01f9007c7 Make Appstore url clickable 2014-10-23 14:29:26 -07:00
Girish Ramakrishnan c5c591d1d8 Make version 0.5.0 2014-10-23 14:18:00 -07:00
Girish Ramakrishnan 98541c1615 sort requires in source code 2014-10-23 14:15:53 -07:00
Girish Ramakrishnan 6d9bf71f8a Basic box upgrade 2014-10-23 13:11:00 -07:00
Girish Ramakrishnan 5ec406bf4d Remove version from cloudron.conf
The version and code move together, it's not really part of cloudron
configuration.

This can maybe even come from package.json later
2014-10-23 12:37:54 -07:00
Girish Ramakrishnan 2498311f24 Update scripts are now under updates/
This is because they are not run by the node.js code
2014-10-23 12:10:04 -07:00
Girish Ramakrishnan 5463b187e1 Remove bogus debug 2014-10-23 12:07:42 -07:00
Girish Ramakrishnan 50f4032988 Update oauth in restore code as well 2014-10-22 21:39:55 -07:00
Girish Ramakrishnan 40e639e710 Combine del and add as replace in clientdb 2014-10-22 21:35:41 -07:00
Girish Ramakrishnan 2046ede44e Send mail dns records registration across restarts
The registration id is saved in the config
2014-10-22 21:22:18 -07:00
Girish Ramakrishnan defe6ad15c Remove config.databaseFileName 2014-10-22 20:05:53 -07:00
Girish Ramakrishnan a77b2e6fc1 Rename variable 2014-10-22 19:35:02 -07:00
Girish Ramakrishnan 90dd30da3b Use set -e in update.sh 2014-10-22 19:32:35 -07:00
Girish Ramakrishnan 133a93010e Drop the square brackets for cmd evaluation 2014-10-22 19:13:32 -07:00
Girish Ramakrishnan 3540a3147b Fix typo 2014-10-22 18:57:24 -07:00
Girish Ramakrishnan 3abc194631 restore script does not need token anymore 2014-10-22 18:43:46 -07:00
Girish Ramakrishnan e53b2d6f0c Add another FIXME 2014-10-22 18:01:02 -07:00
Johannes Zellner 13348b4b79 Fixup linter issues in cloudron.js 2014-10-22 17:57:52 -07:00
Girish Ramakrishnan 5d7a821bf1 Save provision data provided in restore call
Need because with the new restore design, cloudron.conf is not persisted
across restores.
2014-10-22 17:27:57 -07:00
Girish Ramakrishnan c82c4bb712 Add paths.DATA_DIR 2014-10-22 17:14:25 -07:00
Girish Ramakrishnan 9b101b8c83 Backup with no data/ prefix 2014-10-22 13:42:00 -07:00
Girish Ramakrishnan 1d44877358 Run postinstall script in restore and update 2014-10-22 12:17:10 -07:00
Girish Ramakrishnan 39c0a71d97 Simplify update.sh removing fancy logs 2014-10-22 12:13:45 -07:00
Girish Ramakrishnan 21e897830e Make restore script migrate data to latest format 2014-10-22 12:06:01 -07:00
Girish Ramakrishnan c19ac0b361 Do not overwrite code dir on restore 2014-10-22 12:02:47 -07:00
Girish Ramakrishnan 1eee1a21cf Backup only data 2014-10-22 12:00:24 -07:00
Girish Ramakrishnan 7a4d2c2235 Move schema.sql to migrations/ 2014-10-22 11:02:30 -07:00
Johannes Zellner d7ff586b64 Remove unused requires from config.js 2014-10-22 10:18:26 -07:00
Johannes Zellner 3d5a4acd53 Remove unused requires in database.js 2014-10-22 09:16:52 -07:00
Johannes Zellner 43b6dff466 Remove unused requires in apps-test.js 2014-10-22 09:16:42 -07:00
Girish Ramakrishnan 6864306562 Move naked domain config to settingsdb 2014-10-22 08:44:54 -07:00
Girish Ramakrishnan 5bbbf5cba4 Use -p in case .yellowtenttest never existed 2014-10-22 08:32:32 -07:00
Girish Ramakrishnan ac8341cb2d Bring back settingsdb.js
config.js is now meant for instance level data ie data for specific
cloudron instance. The sqlite database is meant for data that is
needed across restores.
2014-10-22 08:02:30 -07:00
Girish Ramakrishnan 18b2389315 Use NGINX_CERT_DIR 2014-10-22 00:39:32 -07:00
Girish Ramakrishnan 689c1cc4c3 Actually add paths.js 2014-10-22 00:35:01 -07:00
Girish Ramakrishnan bc24596d22 Fix typo 2014-10-22 00:27:12 -07:00
Girish Ramakrishnan cb055594c9 Fix scripts for new location of cloudron.conf 2014-10-22 00:04:55 -07:00
Girish Ramakrishnan 66e4a417d1 Fix scripts for new dir structure 2014-10-22 00:02:23 -07:00
Girish Ramakrishnan 93d3245b42 Clarify cloudron.conf vs cloudron.sqlite 2014-10-21 23:42:01 -07:00
Girish Ramakrishnan 9e81fbf05b Move all path config to paths.js
I called it dirs.js first but that wouldn't allow filenames as
part of the API. stdpath.js seemed too 'standard'.
2014-10-21 23:34:23 -07:00
Girish Ramakrishnan fe73fac628 Rework dir structure
data/ is backed up. Everything else is just configuration that does
not need to be backed up.
2014-10-21 22:26:12 -07:00
Girish Ramakrishnan 640b10bbb8 Move data and mount under volumes/ 2014-10-21 22:15:00 -07:00
Girish Ramakrishnan 06465731eb getUserHomeDir need not be a function 2014-10-21 22:04:36 -07:00
Girish Ramakrishnan c3ef6068c3 Use iconsRoot 2014-10-21 21:58:42 -07:00
Girish Ramakrishnan f11adb5e85 Run postinstall script on startup 2014-10-21 20:30:15 -07:00
Girish Ramakrishnan df26fe4845 configRoot is never used 2014-10-21 19:48:34 -07:00
Girish Ramakrishnan dd6e1f66ca Start afresh for every test run
Note that we use ";" instead of && because on the Mac rm -rf
fails because of encfs bugs

Fixes #112
2014-10-21 19:45:35 -07:00
Girish Ramakrishnan f06d305e36 Rename the database to cloudron.sqlite 2014-10-21 19:38:20 -07:00
Girish Ramakrishnan 775988ee7f Run tests with base dir as ~/.yellowtenttest
Part of #112
2014-10-21 18:32:01 -07:00
Girish Ramakrishnan 65b65b8f2c Remove everything except webadmin 2014-10-21 18:32:00 -07:00
Girish Ramakrishnan d38d98e34f Add database.clear 2014-10-21 18:32:00 -07:00
Girish Ramakrishnan ec3bd4763b Add migration script to add admin to clients by default 2014-10-21 18:32:00 -07:00
Girish Ramakrishnan 84965de92c fix typo 2014-10-21 18:32:00 -07:00
Girish Ramakrishnan c513933705 Add clear methods to all tables 2014-10-21 16:39:11 -07:00
Girish Ramakrishnan d1a500e0ed Add initial migration scripts
Part of #112
2014-10-21 13:38:27 -07:00
Girish Ramakrishnan 6885e37409 Add db-migrate 2014-10-21 12:24:56 -07:00
Girish Ramakrishnan 3555c72f8d env vars are strings 2014-10-21 11:17:54 -07:00
Girish Ramakrishnan 772cefbfc6 Quote values in supervisor configs 2014-10-20 18:20:46 -07:00
Girish Ramakrishnan 9da9312086 Cleanup scripts 2014-10-20 16:52:33 -07:00
Girish Ramakrishnan 9f34ecdfa0 Store all data in data/ instead of .yellowtent/ in cloudrons
When run locally, it's still .yellowtent/
2014-10-20 16:44:14 -07:00
Girish Ramakrishnan 439107e6cb Remove unused script 2014-10-20 16:32:22 -07:00
Girish Ramakrishnan b1071790a6 Pretty print the config 2014-10-17 23:41:20 -07:00
Girish Ramakrishnan 1fe9e85293 Fix typo in dns check code 2014-10-17 22:01:05 -07:00
Girish Ramakrishnan b84896a95f Wait for DNS changes to complete
Fixes #111
2014-10-17 21:25:59 -07:00
Girish Ramakrishnan 0807f5caee Add native-dns module 2014-10-17 20:30:25 -07:00
Girish Ramakrishnan a5cab916e2 Bump version to 0.5.0 2014-10-16 14:56:56 -07:00
Girish Ramakrishnan 2abfac8a0d Release version 0.4.0 2014-10-16 14:56:33 -07:00
Girish Ramakrishnan 32cc2d2e2a Send isDev is /api/v1/config 2014-10-16 14:42:46 -07:00
Girish Ramakrishnan c44779e639 Provision based on isDev value in provision call from app server 2014-10-16 14:29:41 -07:00
Girish Ramakrishnan 665b9c6e06 Do not backup the certs
These are our certs!
2014-10-16 14:08:03 -07:00
Girish Ramakrishnan 9a672ec3b3 Add a note not to backup any other dir 2014-10-16 13:58:39 -07:00
Girish Ramakrishnan 0de57a01ab Just use docker exec instead of nsenter
New in docker 1.3

Fixes #109
2014-10-16 13:52:49 -07:00
Girish Ramakrishnan 6be3cc9bb7 Return values with callback 2014-10-16 13:31:59 -07:00
Girish Ramakrishnan a8e86bbf90 Fix indentation of heredoc 2014-10-16 13:06:45 -07:00
Girish Ramakrishnan 8155a7d0b2 Retry git and npm command till it succeeds
It's fine to run them forever since after 30m the appstore
will recreate it anyway
2014-10-16 12:40:40 -07:00
Girish Ramakrishnan e8a123b439 Improve log messages in initialization script 2014-10-16 12:26:01 -07:00
Girish Ramakrishnan c88496873b Install certificates provided during provisioning 2014-10-16 10:26:41 -07:00
Girish Ramakrishnan 4c8fa56175 Just use heroku for the moment since heroku keeps dying on me
Heroku has to be the most unstable service ever
2014-10-15 23:56:17 -07:00
Girish Ramakrishnan e72d2e1e4f Move to cloudron.io domain 2014-10-15 19:27:04 -07:00
Johannes Zellner 4e8438afdc Add TODO to check the private apps user role 2014-10-15 18:01:42 -07:00
Johannes Zellner e318160ec6 webadmin: display the access restriction in app details 2014-10-15 09:23:15 -07:00
Johannes Zellner fbc511cc73 webadmin: create restrictAccessToLabel angular filter 2014-10-15 09:23:00 -07:00
Johannes Zellner 2d42f0e81a webadmin: Add restrictAccessTo select fields in install and config forms 2014-10-15 09:22:29 -07:00
Johannes Zellner ea4e51e252 Adjust Client to restrictAccessTo REST api changes 2014-10-15 09:21:47 -07:00
Johannes Zellner 7b9d1fe91c Add restrictAccessTo field for app install and configure 2014-10-15 09:21:11 -07:00
Johannes Zellner f65a6172b5 Rename isPrivate to restrictAccessTo in appsdb 2014-10-15 08:33:33 -07:00
Johannes Zellner c93f6dbd4a Add isPrivate field to appdb 2014-10-14 13:52:14 -07:00
Johannes Zellner 3bbacabd2e Add app proxy route
This will add a proxy route for apps which are set to run
in private mode. At the moment there is no UI to make apps
private.
2014-10-14 13:52:14 -07:00
Johannes Zellner 05d311cedf Make script includes absolute to webadmin for login session views 2014-10-14 13:52:14 -07:00
Johannes Zellner fcf9936509 Only send welcome mails for non admins
This can only ever be an admin here if it is the very
first one.
2014-10-14 13:52:14 -07:00
Girish Ramakrishnan 4ea1bc65c9 Fix appstore url 2014-10-14 13:28:09 -07:00
Johannes Zellner 1b225da0de Adjust oauth test suite to new user roles 2014-10-12 15:35:07 -07:00
Johannes Zellner 22128ad3b7 Ignore origin passed from oauth client but use the one in the db
Fixes #105
2014-10-12 14:09:38 -07:00
Girish Ramakrishnan 6dcb9a1eae Pass token to restore script 2014-10-10 16:29:28 -07:00
Girish Ramakrishnan 05db80fdae Add a TODO that restore should only be done in a fresh image 2014-10-10 15:57:09 -07:00
Girish Ramakrishnan b8b72ffea4 I like dots 2014-10-10 13:16:19 -07:00
Girish Ramakrishnan c2950f9a1b On ubuntu, tar is /bin/tar 2014-10-10 12:10:55 -07:00
Girish Ramakrishnan 0315b27d61 Fix debug 2014-10-10 11:39:51 -07:00
Girish Ramakrishnan 9a94238a11 Pass backup url to updater to avoid circular reference 2014-10-10 11:37:57 -07:00
Girish Ramakrishnan 98a045ec0b Fix missing require 2014-10-10 11:12:01 -07:00
Johannes Zellner 37f2dd6df6 webadmin: use ng-src instead of src in img tags 2014-10-10 11:04:12 -07:00
Johannes Zellner c03f62339a webadmin: use https:// for gravatar 2014-10-10 11:00:09 -07:00
Johannes Zellner a421943e1c Add angular-m5 for now to setup.html this is only temporarily 2014-10-10 10:52:15 -07:00
Girish Ramakrishnan f388cc6058 Stop container before deleting it
This is attempting to fix
Thu, 09 Oct 2014 06:30:22 GMT box:apptask Apptask completed for 326e4abd-aa72-4069-abf3-238757b3167d { [Error: HTTP code is 500 which indicates error: server error - Cannot destroy container 4524791d0efe279ce556a6c10c484bd09e5163f4279a5de84fa30836be49ebf4: Unable to remove filesystem for 4524791d0efe279ce556a6c10c484bd09e5163f4279a5de84fa30836be49ebf4: remove /var/lib/docker/containers/4524791d0efe279ce556a6c10c484bd09e5163f4279a5de84fa30836be49ebf4: directory not empty

See https://github.com/docker/docker/issues/8203
2014-10-10 09:57:13 -07:00
Girish Ramakrishnan 5dd57f6327 Fix quoting in scripts 2014-10-10 09:54:12 -07:00
Girish Ramakrishnan 9028b4f6b5 Use execFile instead of exec 2014-10-10 09:54:12 -07:00
Johannes Zellner 15dc7ac13c webadmin: use better fitting default gravatar 2014-10-10 09:47:45 -07:00
Johannes Zellner 7aeb66a603 webadmin: fun, use gravatar for user icon 2014-10-10 09:43:44 -07:00
Johannes Zellner 7e895a83bf Revert "Stop container before deleting it"
This reverts commit 872316f64d.
2014-10-10 09:30:45 -07:00
Girish Ramakrishnan 79d1940506 Fix boolean logic from eb21b531 2014-10-10 08:53:32 -07:00
Girish Ramakrishnan b0c2fd7129 Quote all the things! 2014-10-10 08:42:01 -07:00
Johannes Zellner 875bb35807 Write some oauth documentation of what the routes do
Since we deviate slightly from the oauth standard,
much like everyone seems to do, we need to document it better
as the topic is certainly not trivial
2014-10-10 08:30:57 -07:00
Johannes Zellner 0595d7895f Merge branch 'rolescopes' 2014-10-10 08:04:16 -07:00
Girish Ramakrishnan b447298388 print out the request body 2014-10-10 00:57:04 -07:00
Girish Ramakrishnan 957633ed64 Fix qouting 2014-10-10 00:56:56 -07:00
Girish Ramakrishnan ad18353557 Do not set any header 2014-10-10 00:16:14 -07:00
Girish Ramakrishnan c94b54ae31 Use execFile instead of exec
exec is dangerous because of arg escaping trap
2014-10-09 23:52:41 -07:00
Girish Ramakrishnan 10b1fbee69 Quote the assignment 2014-10-09 22:36:18 -07:00
Girish Ramakrishnan fa338fb105 debug the backup url 2014-10-09 19:37:15 -07:00
Johannes Zellner 6140f2ad3f Only ever use the scopes from the clientdb when handing out tokens 2014-10-09 17:54:51 -07:00
Johannes Zellner a2847bd918 Remove * oauth scope and make it explicit 2014-10-09 17:54:26 -07:00
Johannes Zellner 5a16c41429 Remove scope and redirectURL from authcodedb 2014-10-09 17:53:59 -07:00
Girish Ramakrishnan 0efa500612 Use backup url api to backup and restore box data
Part of #60
2014-10-09 17:36:52 -07:00
Johannes Zellner 717fb5045c Add oauth scope field to clientdb 2014-10-09 17:14:28 -07:00
Girish Ramakrishnan 7fe2bd12c1 Box must send heartbeat with fqdn
Hearbeat makes sense only after provisioning at which point
config.fqdn is setup correctly
2014-10-09 13:46:45 -07:00
Johannes Zellner bf570f6f23 Add 2gb swapfile to the base image 2014-10-09 10:59:10 -07:00
Johannes Zellner cf05cd4c19 Create images only with 512mb droplets 2014-10-09 10:35:12 -07:00
Johannes Zellner 6f1b208f47 If oauth client asks for admin capabilities only allow admins to login
This requires nicer error handling
2014-10-09 09:21:48 -07:00
Girish Ramakrishnan 872316f64d Stop container before deleting it
This is attempting to fix
Thu, 09 Oct 2014 06:30:22 GMT box:apptask Apptask completed for 326e4abd-aa72-4069-abf3-238757b3167d { [Error: HTTP code is 500 which indicates error: server error - Cannot destroy container 4524791d0efe279ce556a6c10c484bd09e5163f4279a5de84fa30836be49ebf4: Unable to remove filesystem for 4524791d0efe279ce556a6c10c484bd09e5163f4279a5de84fa30836be49ebf4: remove /var/lib/docker/containers/4524791d0efe279ce556a6c10c484bd09e5163f4279a5de84fa30836be49ebf4: directory not empty

See https://github.com/docker/docker/issues/8203
2014-10-08 23:42:40 -07:00
Girish Ramakrishnan d4e08c06b0 Not sure what the v arg means. Set it to false 2014-10-08 23:39:17 -07:00
Girish Ramakrishnan 76b3a7f3df Use . as progress indicator 2014-10-08 22:48:55 -07:00
Girish Ramakrishnan 11997a4adc Logging rules must be at the very end 2014-10-08 22:03:20 -07:00
Girish Ramakrishnan 112e77dc20 Log dropped incoming packages 2014-10-08 19:35:35 -07:00
Girish Ramakrishnan 99952e5bab Firewall the box
This change firewalls everything except the internal bridge. An upcoming
change should disable icc as well but that requires us to link all the
apps with the mail container.

Part of #59
2014-10-08 19:23:15 -07:00
Girish Ramakrishnan 92ae8ec615 Add DNS port to reserved ports 2014-10-08 15:00:52 -07:00
Girish Ramakrishnan a35fddcb59 Add more ports to reserved ports 2014-10-07 17:06:46 -07:00
Girish Ramakrishnan 2dab41683b Remove Select * 2014-10-07 14:53:19 -07:00
Girish Ramakrishnan 3ba7632987 Remove SELECT * from queries
Stolen from SO article (https://stackoverflow.com/questions/321299/what-is-the-reason-not-to-use-select)

If you specify columns in a SQL statement, the SQL execution engine will error if that column is removed from the table and the query is executed.
You can more easily scan code where that column is being used.
You should always write queries to bring back the least amount of information.
As others mention if you use ordinal column access you should never use select *
If your SQL statement joins tables, select * gives you all columns from all tables in the join
2014-10-07 09:17:55 -07:00
Girish Ramakrishnan 020b509e2c Do not assert if ip is null
IP is null when there is no network connectivity
2014-10-07 09:17:55 -07:00
Girish Ramakrishnan aad31c46e0 Rickshaw does not like null data 2014-10-06 23:08:43 -07:00
Girish Ramakrishnan b0c788e621 Cleanup rendering of appdetails graphs 2014-10-06 23:02:49 -07:00
Girish Ramakrishnan 37f2c5c9a1 Refactor graph rendering 2014-10-06 22:43:23 -07:00
Girish Ramakrishnan 3bc9cba036 Handle null data from graphite 2014-10-06 22:23:41 -07:00
Girish Ramakrishnan c3a1ca7877 Check if a port is reserved when installing app 2014-10-06 19:07:19 -07:00
Girish Ramakrishnan 3ea6aff5e1 Server should only listen on the loopback 2014-10-06 19:02:39 -07:00
Girish Ramakrishnan 18059c4f8a Cache the IP 2014-10-06 18:34:19 -07:00
Girish Ramakrishnan 0f68e3bebc graphite runs on port 8000 2014-10-06 18:24:27 -07:00
Girish Ramakrishnan e05243a72b Start haraka and graphite containers on startup
The default restart policy for containers is "no". As a result,
the service container (graphite, haraka) are not started on
system reboot.

The apps themselves are resumed by apps.js. That code also handles
resumption of app tasks should the box have crashed/rebooted midway.

This code could have been placed in a supervisor script or an init
script. init script means tighter integration into the system OS
which we want to avoid. supervisor script could be done at some point
should we need a more sophisticated "pre-start" script.

Fixes #98
2014-10-06 14:25:23 -07:00
Girish Ramakrishnan 324011d04f Remove debugging code
Not sure how this got committed
2014-10-06 11:02:36 -07:00
Girish Ramakrishnan ebc5c56b11 Display location on sidebar now that we allow multiple instances 2014-10-04 02:36:11 -07:00
Girish Ramakrishnan b31320bff4 Allow multiple instances of apps
Fixes #93
2014-10-04 01:24:13 -07:00
Johannes Zellner 9e2614a0d8 After password reset, redirect the user to the webadmin 2014-10-04 00:49:50 -07:00
Johannes Zellner 5a01c84936 Send new users to the webadmin 2014-10-04 00:47:26 -07:00
Johannes Zellner c2fe5fc0a0 Also print the login url in welcome emails 2014-10-04 00:37:15 -07:00
Johannes Zellner 1d242d18f4 Generate random passwords for new user and send them via mail 2014-10-04 00:21:27 -07:00
Girish Ramakrishnan 669f0d2eca Fix typo 2014-10-04 00:12:43 -07:00
Girish Ramakrishnan b7156f7b49 break after finding an app 2014-10-04 00:07:08 -07:00
Girish Ramakrishnan b311571dee arp -d can fail 2014-10-03 20:42:23 -07:00
Girish Ramakrishnan 04fc6b6364 Enable backup logs 2014-10-03 20:41:27 -07:00
Johannes Zellner 18a931c04f webadmin: make navbar responsive 2014-10-03 19:16:32 -07:00
Girish Ramakrishnan 81fd432764 Add a hack to forget the old MAIL_SERVER mac 2014-10-03 18:59:27 -07:00
Johannes Zellner 39916b351a webadmin: Remove context menu for profile 2014-10-03 18:49:47 -07:00
Johannes Zellner 2af697bc90 Disable autocomplete for password reset form 2014-10-03 18:35:43 -07:00
Johannes Zellner 94e30052db Finalize password reset 2014-10-03 18:16:57 -07:00
Johannes Zellner 0fdb5e3df0 Add missing password reset view 2014-10-03 17:41:59 -07:00
Girish Ramakrishnan a2baf856ae Add NET_ADMIN caps so that haraka can configure interface 2014-10-03 17:13:48 -07:00
Johannes Zellner ada282e70d Add initial form to enter new password after reset 2014-10-03 16:55:56 -07:00
Girish Ramakrishnan 1e02b9e8f4 Set the mail server static IP in haraka container instead
This makes it work across starts (like after a backup)
2014-10-03 16:05:18 -07:00
Girish Ramakrishnan 973a3b2849 Add MAIL_DOMAIN and make MAIL_USERNAME only have username 2014-10-03 15:34:29 -07:00
Johannes Zellner 8cceab7c38 Actually send reset tokens 2014-10-03 15:32:56 -07:00
Johannes Zellner 7ce2c252f0 Add more routes for password reset and attempt to send a mail 2014-10-03 15:08:19 -07:00
Girish Ramakrishnan f6697d4e4c Fix typo 2014-10-03 10:45:35 -07:00
Girish Ramakrishnan 4f615a1249 Give mail server a static IP
Docker containers get a new IP on every restart. This causes a problem
since we export the MAIL_SERVER as an env variable in apps.
2014-10-03 09:53:02 -07:00
Johannes Zellner a1bc095fbd Add initial password reset view 2014-10-03 03:40:24 -07:00
Girish Ramakrishnan d3f9712eb8 Send mails asap 2014-10-03 03:06:47 -07:00
Girish Ramakrishnan 84c917e438 Fix typo 2014-10-03 02:54:52 -07:00
Girish Ramakrishnan 09c9bdc32c Fix mailer issues 2014-10-03 02:42:26 -07:00
Girish Ramakrishnan 9559917272 Fix missing var 2014-10-03 02:35:40 -07:00
Girish Ramakrishnan 03175b3d06 Move mailer notifications outside routes code 2014-10-03 02:33:04 -07:00
Girish Ramakrishnan d30f4c44c2 Better email notifications 2014-10-03 02:32:01 -07:00
Girish Ramakrishnan ed74695d22 Remove bogus default email id 2014-10-03 02:32:01 -07:00
Johannes Zellner 9e61a3e7e5 Do not try to stop the box code on update
The backup should already stop it
2014-10-03 02:29:51 -07:00
Johannes Zellner c65e5143b0 Do not start box code at end of backup if we are updating 2014-10-03 02:23:11 -07:00
Johannes Zellner b6a0f429e7 Actually pass in the S3 credentials not just the variable name 2014-10-03 02:05:00 -07:00
Girish Ramakrishnan 73fffaa6d9 Fix email rendering 2014-10-03 01:01:08 -07:00
Johannes Zellner e53666f0e8 Run a backup prior to an update 2014-10-03 00:54:36 -07:00
Johannes Zellner e451acf271 Move backup code to cloudron.js 2014-10-03 00:44:08 -07:00
Johannes Zellner eadfb9d837 Send 403 instead of 401 if admin tries to delete user providing wrong password 2014-10-03 00:33:21 -07:00
Johannes Zellner cb4aa12c75 Remove log output for docker proxy if running in test mode 2014-10-03 00:22:23 -07:00
Johannes Zellner 24552b0eef Remove stray console.dir() 2014-10-03 00:21:58 -07:00
Johannes Zellner fb7519a7e2 Do not error if the app icon does not exist on uninstallation 2014-10-03 00:21:40 -07:00
Johannes Zellner 0d7910661d Add supererror to apphealthtask 2014-10-02 23:36:43 -07:00
Johannes Zellner dda50935b6 Add missing AND in sql statement 2014-10-02 23:35:46 -07:00
Johannes Zellner fb316edf0a cloudron.getIp() should also respect wifi devices 2014-10-02 23:04:50 -07:00
Girish Ramakrishnan bad41d7a7e Use async.mapSeries 2014-10-02 13:22:47 -07:00
Girish Ramakrishnan de57fbb0aa Fix typo 2014-10-02 13:16:12 -07:00
Girish Ramakrishnan b0e0b441f4 Fix missing require 2014-10-02 13:11:57 -07:00
Girish Ramakrishnan 20d1a54674 mail: Notify admins and user when a user was added 2014-10-02 12:59:35 -07:00
Girish Ramakrishnan c9dcfc3c23 Render email using ejs templates 2014-10-02 11:10:28 -07:00
Girish Ramakrishnan acd868640d Make it a debug statement 2014-10-02 09:59:46 -07:00
Girish Ramakrishnan 444fc6c0d2 Check DNS PTR record before sending email
This allows us to activate the cloudron asap but no mails are sent
out until the PTR records are setup.
2014-10-02 09:59:14 -07:00
Girish Ramakrishnan 8137079cb3 Add a mail queue
This is primarily so that we can tune the code later to send emails
at specific points (like after we ensure the dns has propagated)
2014-10-02 09:49:17 -07:00
Johannes Zellner db2d9651aa Remove unused requires in server.js 2014-10-02 08:38:04 -07:00
Johannes Zellner 47d2d957aa webadmin: use a default error handler for all ajax requests in console.js
This allows us to logout if any request fails due to invalid
token. This can for example happen if you revoke the tokens for
the webadmin.
2014-10-01 16:53:50 -07:00
Johannes Zellner 22e3055bf2 webadmin: Remove call to nonexisting login() 2014-10-01 16:32:08 -07:00
Johannes Zellner 7303e703e8 Disable autocomplete for all forms besides login 2014-10-01 16:17:58 -07:00
Johannes Zellner 778c42ce36 Remove redundant form tag in login view 2014-10-01 16:14:21 -07:00
Girish Ramakrishnan 68989ad7a3 dkim does not have outbound signing policy anymore
http://www.faqs.org/rfcs/rfc4871.html does not have a section for 'o'
2014-10-01 08:54:09 -07:00
Girish Ramakrishnan 4ee3f7b350 Add more mail hooks 2014-10-01 06:17:54 -07:00
Girish Ramakrishnan 05473b4dc1 Fix debug scope 2014-10-01 06:11:28 -07:00
Girish Ramakrishnan e2342fc653 Send welcome email 2014-10-01 06:05:17 -07:00
Girish Ramakrishnan a58c1cf503 Display user's email 2014-09-30 21:57:40 -07:00
Girish Ramakrishnan d6d50324d6 _dmarc and _domainkey are reserved subdomains 2014-09-30 21:34:41 -07:00
Girish Ramakrishnan ed29754f63 Keep track of dns record ids 2014-09-30 17:11:12 -07:00
Girish Ramakrishnan dba3527ba8 Mail DNS records must be double quoted 2014-09-29 23:28:43 -07:00
Girish Ramakrishnan 54b46240fb Send SPF records as type TXT 2014-09-29 22:27:31 -07:00
Girish Ramakrishnan 43f21a7a39 Fix parsing of public key file 2014-09-29 17:29:47 -07:00
Girish Ramakrishnan 480d7b9bfd Set loglevel to verbose 2014-09-29 17:21:20 -07:00
Girish Ramakrishnan 0b082d2a2a Read public key as string 2014-09-29 17:07:27 -07:00
Girish Ramakrishnan 8888e4bbe7 Refactor getCertificate code
Kill timer on uninitialize as well
2014-09-29 14:47:33 -07:00
Girish Ramakrishnan d5f1ccfd1d Add mail DNS records
Part of #46
2014-09-29 14:47:28 -07:00
Girish Ramakrishnan 8393ee7c25 subdomain registration API now takes an array 2014-09-29 13:27:09 -07:00
Johannes Zellner 2ca9bedf45 webadmin: angular based form validation for create user 2014-09-29 09:55:43 -07:00
Johannes Zellner b3d93742b3 webadmin: show validation errors for user creation 2014-09-29 08:36:25 -07:00
Johannes Zellner cee89b44a6 webadmin: add basic form validation for first user creation 2014-09-28 20:21:01 -07:00
Johannes Zellner 94e1652422 webadmin: add some basic field validation for user creation 2014-09-28 20:09:56 -07:00
Johannes Zellner 17061a1f74 webadmin: creating any user requires an email address 2014-09-28 19:45:26 -07:00
Johannes Zellner 51b916ac0e webadmin: creating the first user requires an email address 2014-09-28 19:36:45 -07:00
Girish Ramakrishnan 0b18fdca1b Add type of subdomain API 2014-09-28 18:50:47 -07:00
Girish Ramakrishnan 802c2deb93 Set MAIL_USERNAME for app to use as from address for emails 2014-09-28 15:31:48 -07:00
Girish Ramakrishnan dbbc6d1881 run node script as yellowtent user 2014-09-28 14:47:35 -07:00
Girish Ramakrishnan 4ba5967746 Export MAIL_SERVER env variable for apps 2014-09-28 13:17:59 -07:00
Girish Ramakrishnan e15d516374 Save mailServer IP in cloudron config 2014-09-28 13:16:23 -07:00
Girish Ramakrishnan d32b127da4 Always set defaults in config object
Set defaults and then overwrite them with any saved config object
2014-09-28 12:53:12 -07:00
Girish Ramakrishnan 8590bc7054 Generate the dkim keys in haraka container
If the appdata dir of haraka is prepopulated, then the setup
script is skipped.
2014-09-28 08:40:35 -07:00
Girish Ramakrishnan 08456655de Fix typo 2014-09-28 00:15:23 -07:00
Girish Ramakrishnan 144fde9e43 Set DOMAIN_NAME env variable in the haraka container 2014-09-27 23:51:37 -07:00
Girish Ramakrishnan 920fe2df6f Fix haraka setup script 2014-09-27 23:13:13 -07:00
Girish Ramakrishnan 03289fb55f Add haraka mail relay server as part of base image
Part of #46
2014-09-27 13:09:01 -07:00
Girish Ramakrishnan 7bcca1ad2a Fix speling 2014-09-26 18:28:26 -07:00
Girish Ramakrishnan 17d24d23b2 Fix refactoring error 2014-09-26 18:28:03 -07:00
Girish Ramakrishnan d8310bdc1a Fix typo 2014-09-26 16:07:12 -07:00
Girish Ramakrishnan f2b910a22a Move provisioning code to cloudron.js 2014-09-26 15:11:30 -07:00
Girish Ramakrishnan 46ce72a8d1 Remove business logic from cloudron routes code 2014-09-26 14:57:21 -07:00
Girish Ramakrishnan 0cd077da0a Move updater code into cloudron.js 2014-09-26 14:33:08 -07:00
Girish Ramakrishnan 04e3325953 Move heartbeat code to cloudron.js 2014-09-26 14:21:25 -07:00
Girish Ramakrishnan c59432323f Move announce code to cloudron.js 2014-09-26 14:13:30 -07:00
Girish Ramakrishnan e9f4cbcee0 Move box specific logic to cloudron.js 2014-09-26 13:00:02 -07:00
Girish Ramakrishnan 5e4b01cdda Namespace cloudron routes 2014-09-26 12:45:50 -07:00
Girish Ramakrishnan 6b3cddc0d4 Add checkInstall.sh to npm test 2014-09-26 12:09:41 -07:00
Girish Ramakrishnan 52e7ec9d65 Add checkInstall.sh script to check sudo setup
Checks if all sudo scripts return OK with --check argument
2014-09-26 12:05:46 -07:00
Johannes Zellner 3c727c646a Add Cross-site request forgery protection middleware csurf
Fixes #81
2014-09-26 09:56:19 -07:00
Johannes Zellner f61c49ea73 Update sqlite3 module to version 3.0.0 2014-09-26 09:53:19 -07:00
Johannes Zellner 309e2f5389 webadmin: disable autofill for user deletion dialog 2014-09-25 14:32:44 -07:00
Girish Ramakrishnan 374ac8590c Leave a note about USER_HZ 2014-09-24 15:08:06 -07:00
Girish Ramakrishnan 7e85ccb819 Display app graphs
https://www.kernel.org/doc/Documentation/cgroups/memory.txt

Part of #74
2014-09-24 11:11:29 -07:00
Girish Ramakrishnan efbf4c1205 Collect max usage in bytes 2014-09-24 10:56:32 -07:00
Girish Ramakrishnan 624245f820 Display graphs in appdetails page 2014-09-24 10:08:10 -07:00
Johannes Zellner 397cfda62c allocate oauth credentials during app install should fail when attempted twice 2014-09-24 07:56:11 -07:00
Girish Ramakrishnan 6aa7166f15 Collect appdata du information 2014-09-23 23:48:58 -07:00
Girish Ramakrishnan c531825eb8 Change ownership of collectd dir 2014-09-23 23:18:44 -07:00
Girish Ramakrishnan 1233ebc1e4 Implement collection of app memory/cpu statistics
per-app collectd configuration is dynamically added/removed.
2014-09-23 22:31:19 -07:00
Girish Ramakrishnan 36213bc477 Move collectd configs inside backup dir 2014-09-23 21:51:04 -07:00
Johannes Zellner 7df45b535a Merge branch 'revokation' 2014-09-23 21:04:12 -07:00
Johannes Zellner abc1c903e3 webadmin: disable token deletion button if there are no tokens 2014-09-23 20:54:48 -07:00
Johannes Zellner ced1618460 Fix clientdb.getAllWithDetails() query to use outer join correctly 2014-09-23 20:54:28 -07:00
Johannes Zellner 2bca7a95a2 webadmin: rework the security ui to adjust to server changes 2014-09-23 18:05:47 -07:00
Johannes Zellner 61db9bc698 Make oauth clients and tokens REST resources
This only covers functionality we use so far
2014-09-23 18:05:15 -07:00
Johannes Zellner 03f15dbe22 Update the database tests 2014-09-23 18:04:07 -07:00
Johannes Zellner b4087645ac Add clientdb.getAll*() methods 2014-09-23 18:03:49 -07:00
Johannes Zellner de2f796651 Add tokendb.getByUserIdAndClientId() 2014-09-23 18:03:24 -07:00
Girish Ramakrishnan 04ef971b83 Add girish/base:0.7
Fixes #87
2014-09-23 17:12:38 -07:00
Girish Ramakrishnan 1fffd986f0 Add non-minified rickshaw files
rickshaw is from a240899625
d3 is from 3.4.11
2014-09-23 00:40:38 -07:00
Johannes Zellner 1abbde33d7 Only add webadmin as oauth client if not already there 2014-09-22 17:30:40 -07:00
Johannes Zellner 2c97b89524 Show oauth client credentials in webadmin 2014-09-22 17:08:27 -07:00
Johannes Zellner 24bd8070cd webadmin: fixup the accordion collapsing 2014-09-22 16:56:08 -07:00
Johannes Zellner f6a5bfcdcd webadmin: The oauth client view is now an accordion 2014-09-22 16:33:03 -07:00
Johannes Zellner 615cf9150a Adjust the special casing for webadmin for oauth scopes 2014-09-22 16:32:33 -07:00
Johannes Zellner 66afa93259 webadmin: make security a separate view 2014-09-22 16:04:23 -07:00
Johannes Zellner 0507a633ea Introduce appId for clientdb 2014-09-22 15:51:43 -07:00
Girish Ramakrishnan 265ecbeffc call transformNull on all metrics 2014-09-22 14:07:22 -07:00
Girish Ramakrishnan 4f2b818786 Fix graphs 2014-09-22 12:58:23 -07:00
Girish Ramakrishnan c078871188 Implement month and year charts
Month charts don't work properly for some reason
2014-09-22 11:43:25 -07:00
Johannes Zellner 313a09bbb0 webadmin: Do list active clients instead of access tokens 2014-09-22 10:16:09 -07:00
Johannes Zellner a7a7824fb4 Also fetch the scopes for tokens when getting active clients 2014-09-22 10:15:51 -07:00
Johannes Zellner 37dd2597b2 Add route to delete all tokens by active oauth client 2014-09-22 09:57:01 -07:00
Johannes Zellner d259c4888b Add clientdb.getByClientId() unit tests 2014-09-22 09:39:52 -07:00
Johannes Zellner 8a5b736af9 Add tokendb.delByUserIdAndClientId() 2014-09-22 09:26:06 -07:00
Johannes Zellner 8b59f11df4 Add route to list all active oauth clients for a user 2014-09-22 08:43:04 -07:00
Johannes Zellner c3fc4a727d Add query to list active oauth clients for a user 2014-09-22 08:42:33 -07:00
Girish Ramakrishnan 3fdfaa144c nginx: redirect everything other than nginx_status 2014-09-22 08:07:21 -07:00
Girish Ramakrishnan 0698e5e8b7 Add legend to disk chart 2014-09-22 08:01:52 -07:00
Johannes Zellner 2075a47631 Actually use the oauth client scope for tokens we hand out 2014-09-22 07:59:03 -07:00
Johannes Zellner 0d1811561c webadmin: add access token deletion action 2014-09-22 07:55:10 -07:00
Girish Ramakrishnan c72fc8759e Various fixes to graphing 2014-09-22 06:18:09 -07:00
Johannes Zellner 799b38061c Make the create admin access token a WebAdmin token 2014-09-21 18:34:58 -07:00
Johannes Zellner d9120146e1 webadmin: initial token list for settings panel 2014-09-21 18:17:31 -07:00
Johannes Zellner 975504b70a Add token resource routes to list and delete tokens 2014-09-21 18:17:15 -07:00
Johannes Zellner 79649c4c76 Add tokendb.getByUserId() 2014-09-21 18:16:46 -07:00
Johannes Zellner 05ae667b7a Fixup linter issues in tokendb 2014-09-21 18:16:46 -07:00
Girish Ramakrishnan a492ba88cf update graphs in Client.onReady 2014-09-21 18:06:48 -07:00
Girish Ramakrishnan 0567ba8867 Get started on graphs 2014-09-21 18:03:19 -07:00
Girish Ramakrishnan 1336c324cd Add rickshaw from a240899625c2d83961b3e682cd77ab8e5199a866 2014-09-21 17:59:31 -07:00
Girish Ramakrishnan 32956cc8d7 Move proxy middleware definition 2014-09-21 17:59:31 -07:00
Johannes Zellner 3da1aedc60 webadmin: remove myapps views 2014-09-21 17:10:47 -07:00
Johannes Zellner 6867546dd5 Do not crash if creating a backup locally without aws config 2014-09-21 16:47:20 -07:00
Johannes Zellner 132571e359 webadmin: display installationState and installationProgress 2014-09-21 12:19:48 -07:00
Johannes Zellner eb2d5f6207 webadmin: do not use angular helpers but do it the old way
This should fix the appdetails refresh
2014-09-21 11:41:45 -07:00
Girish Ramakrishnan 30c6a1b21e Keep graphite urls open for testing 2014-09-20 11:17:44 -07:00
Girish Ramakrishnan c50cdfd918 Make logs api protected 2014-09-19 23:42:53 -07:00
Girish Ramakrishnan 4d9091afab Add graphite routes to nginx 2014-09-19 23:41:11 -07:00
Girish Ramakrishnan da357efd9c $timeout not used anymore 2014-09-19 23:00:30 -07:00
Girish Ramakrishnan 0e38a73395 Add /api/v1/graphs route 2014-09-19 19:59:32 -07:00
Johannes Zellner 1cd425bcb0 Ensure app install and get routes return similar objects 2014-09-19 17:52:31 -07:00
Girish Ramakrishnan 1cf1060d18 Make graphite/ calls authenticated
Fixes #82
2014-09-19 07:56:47 -07:00
Girish Ramakrishnan bd96ad3c26 remove spurious log 2014-09-19 07:34:07 -07:00
Girish Ramakrishnan b44a9cda05 Keep deps sorted 2014-09-19 07:32:19 -07:00
Girish Ramakrishnan 4e79aa44cc Make docker proxy more robust 2014-09-19 07:29:15 -07:00
Girish Ramakrishnan cfac836eb5 Enable the test 2014-09-19 00:53:35 -07:00
Girish Ramakrishnan a92d961fc0 Add tests for logs and logStream 2014-09-19 00:47:03 -07:00
Girish Ramakrishnan 133f9fe56d Implement log download
Fixes #83
2014-09-18 23:06:35 -07:00
Girish Ramakrishnan 5946c67dce Bump test app version 2014-09-18 23:06:31 -07:00
Girish Ramakrishnan 52a572522e Fix typo 2014-09-18 22:33:36 -07:00
Johannes Zellner b1f8e581bf Make bootstrap script an init script 2014-09-18 12:49:14 -07:00
Girish Ramakrishnan 7b4bca5d90 Append does not seem to work 2014-09-17 16:14:40 -07:00
Girish Ramakrishnan ffa5fa335d Add more debugs for testing 2014-09-17 16:12:29 -07:00
Girish Ramakrishnan 926dd8ae35 Escape $ since they are expanded in heredoc 2014-09-17 16:12:25 -07:00
Girish Ramakrishnan bd74a364ce Write logfiles with pid and also append
This will help confirm if the scripts are running twice for some
reason.
2014-09-17 15:05:46 -07:00
Girish Ramakrishnan 8b3ee3e0df Make bootstrap run at the very end 2014-09-17 15:02:37 -07:00
Girish Ramakrishnan 89ccfe3895 move sync into initialization script 2014-09-17 15:01:59 -07:00
Girish Ramakrishnan bd4c10f6d3 supervisor and nginx should never be running 2014-09-17 15:01:31 -07:00
Girish Ramakrishnan 37a8984d29 /var/log/cloudron should already exist at this point 2014-09-17 15:00:03 -07:00
Girish Ramakrishnan 10a7b6685d Revert "Remove redirection, already redirected in bootstrap init.d script"
This reverts commit 45c771d6f8.
2014-09-17 11:50:24 -07:00
Girish Ramakrishnan db48b7ac0b Looks like service makes the script terminate 2014-09-17 11:25:30 -07:00
Girish Ramakrishnan 45c771d6f8 Remove redirection, already redirected in bootstrap init.d script
(checking if this is the root cause of bootstrap.sh running twice)
2014-09-17 10:51:36 -07:00
Johannes Zellner 403c94e8df Only unmount aufs filesystems if there are some 2014-09-17 10:21:05 -07:00
Girish Ramakrishnan 31cf9909d7 Enable and disable collectd appropriately 2014-09-17 10:05:13 -07:00
Girish Ramakrishnan 55ce1046df Make script barf one error 2014-09-17 10:03:01 -07:00
Johannes Zellner a6bcae1aa0 webadmin: add page offset and make tabs clickable for graphs 2014-09-17 09:39:05 -07:00
Girish Ramakrishnan bbfe07ab91 Setup -> Install 2014-09-17 09:37:43 -07:00
Girish Ramakrishnan 8f7c4fa534 Attempt disk usage images 2014-09-17 00:16:54 -07:00
Girish Ramakrishnan 50668fd9c5 disable disk plugin which is measuring iops 2014-09-16 23:44:12 -07:00
Girish Ramakrishnan 567306f3b4 hardcode Hostname for predictable graphite targets 2014-09-16 23:21:51 -07:00
Girish Ramakrishnan c07f493ca2 Display tab in graphs view 2014-09-16 20:39:00 -07:00
Girish Ramakrishnan a7b4f816fb Add graphs view filler 2014-09-16 19:06:44 -07:00
Girish Ramakrishnan d5ac037ffc bump the graphite docker version 2014-09-16 19:06:43 -07:00
Girish Ramakrishnan 92cf82af15 Monitor nginx logs using the tail plugin
I guess real analysis must be done using elasticsearch
2014-09-16 17:18:52 -07:00
Girish Ramakrishnan 0fd494f592 Remove dead configs in nginx config 2014-09-16 16:57:41 -07:00
Girish Ramakrishnan 85df77409b Cleanup collectd.conf 2014-09-16 16:25:55 -07:00
Girish Ramakrishnan 77daac69c3 Update to latest graphite image 2014-09-16 16:23:38 -07:00
Girish Ramakrishnan 770acdf395 Make graphite data part of backup 2014-09-16 16:09:21 -07:00
Girish Ramakrishnan 86e7061819 collectd: configure df and disk 2014-09-16 12:04:44 -07:00
Girish Ramakrishnan 9bf5b1104e collectd: Enable vmem plugin 2014-09-16 11:54:12 -07:00
Girish Ramakrishnan 20add2bee4 collectd: disable rrdtool
afaict, we don't need it since we use graphite as backend
2014-09-16 11:49:17 -07:00
Girish Ramakrishnan e1ded03f1f collectd: Enable collection of box process stats 2014-09-16 11:40:41 -07:00
Girish Ramakrishnan f4c9c42859 collectd: enable swap space monitoring 2014-09-16 11:33:37 -07:00
Girish Ramakrishnan 52ff80f9bc Enable collectd ping plugin 2014-09-16 11:29:05 -07:00
Girish Ramakrishnan e4c891fff8 Enable nginx status in collectd 2014-09-16 11:25:52 -07:00
Girish Ramakrishnan 62cb58b5b1 Run docker in background 2014-09-16 08:05:25 -07:00
Girish Ramakrishnan fc8a47774b Remove girish/base:0.4 2014-09-15 22:16:04 -07:00
Girish Ramakrishnan 4e1ae532de Move graphite to separate container
Only collectd needs to run in the host
2014-09-15 20:14:57 -07:00
Girish Ramakrishnan 7bb96f3523 Add collectd and graphite support to base image 2014-09-15 02:04:23 -07:00
Girish Ramakrishnan c39d307bcc Fix deps 2014-09-15 02:04:23 -07:00
Girish Ramakrishnan b0e8625cab Implement logs using ServerSent events
The hard lesson is that SSE sucks.
*) The cross-origin policy is not exactly well defined but this doesn't affect us
*) There is no way to set Authorization header and we have to rely on cookies
*) Have to use a polyfill to make work on IE

Also
*) timeout module does not close if headers are sent. So, it never closes SSE
*) nginx buffers responses until completion, so we have to disable that with X-Accel-Buffering header

The auth header basically means we have to move back to long polling or support
special auth just for SSE :-(
2014-09-13 01:51:22 -07:00
Girish Ramakrishnan 69c6d3a3fb Bump test image version 2014-09-12 17:19:53 -07:00
Girish Ramakrishnan 779c6013d0 Add config.iconsRoot 2014-09-12 17:17:32 -07:00
Johannes Zellner 450530c95c Add session logout for OAuth test suite 2014-09-12 12:06:14 -07:00
Johannes Zellner 9596671a64 Remove stray backslash 2014-09-12 12:02:23 -07:00
Johannes Zellner a7ab2ddfe9 Remove unused OAuth token grant 2014-09-12 12:00:11 -07:00
Johannes Zellner aa03287cc7 Add OAuth test suite to allow manual OAuth testing 2014-09-12 10:23:53 -07:00
Johannes Zellner 294059ff08 Only give out wildcard oauth scope to the webadmin
This will break our current other clients (quassel app and ngircd)
They now have to explicitly request the 'profile' scope and only that
2014-09-12 10:20:15 -07:00
Johannes Zellner 2a779fda6d Do not crash if apps.uninitialize() is called twice 2014-09-12 08:59:14 -07:00
Johannes Zellner 01b87f80ef Do not print the password in plaintext when DEBUG is set 2014-09-12 08:54:34 -07:00
Johannes Zellner 957c7a5efd Introduce oauth scope to authcodes 2014-09-12 08:22:26 -07:00
Girish Ramakrishnan 3b08db3f4c Display app logs
Note done completely. Needs autoscroll and some fixes in longpolling.
angular does not seem to provide chunked progress in ajax
2014-09-12 05:40:04 -07:00
Girish Ramakrishnan 4d2c5c14e7 Update node packages
From the output of npm outdated.

npm install underscore@* nodejs-disks@* js-yaml@* passport@* passport-oauth2-client-password@* --save
2014-09-12 04:32:56 -07:00
Girish Ramakrishnan 33c6516172 Update dockerode 2014-09-12 04:32:56 -07:00
Girish Ramakrishnan 3439dcf28c Navigate to admin-localhost 2014-09-12 04:32:56 -07:00
Johannes Zellner 6a48b9ed10 The sudoers entry for scripts cannot contain spaces for ALL=(ALL) 2014-09-11 14:29:30 -07:00
Johannes Zellner 5f758b3d5e Remove legacy support for auth_token and 'Token <tok>' in auth header 2014-09-11 08:43:32 -07:00
Johannes Zellner a184e1fb01 Make bearer token verification implicit for scoped routes 2014-09-11 08:34:18 -07:00
Johannes Zellner 7292a23bab Add oauth scopes for each scoped route
All tokens are still given out with the
wildcard scope. The syncer and file related
routes don't have scopes. As well as the
firsttime use and provisioning routes.

We now have the following scopes so far:

- root      /api/v1/..
- profile   /api/v1/profile
- users     /api/v1/users/..
- apps      /api/v1/apps/..
- settings  /api/v1/settings/..

Each token can carry a comma separated list
of scopes, the token is good for.
2014-09-10 18:01:21 -07:00
Johannes Zellner 2c03aa275d Allow to specify a redirect URL on session logout 2014-09-10 18:00:03 -07:00
Girish Ramakrishnan a94b6956bb Better error messages 2014-09-10 15:13:33 -07:00
Johannes Zellner fc9a3b3511 Add OAuth scope testing middleware 2014-09-10 14:52:03 -07:00
Johannes Zellner fbd658bf66 Use OAuth scope attached to the token to proceed
passport attaches the scope to req.authInfo, where we can pick it
up in other middlewares for verification
2014-09-10 13:14:50 -07:00
Johannes Zellner d927a5b086 Remove unused tokendb.getByUserId 2014-09-10 12:57:41 -07:00
Johannes Zellner a5d9871a75 Enforce and check deployment env argument for createDigitalOceanImage.sh 2014-09-10 11:51:56 -07:00
Johannes Zellner 05ed941973 Add some missing expect()s to database test 2014-09-10 11:48:16 -07:00
Johannes Zellner 9b1f51e932 Introduce OAuth scope field for tokens
All tokens are as before now good for each route.
The scope for that is "*"
2014-09-10 11:42:20 -07:00
Johannes Zellner a532eecdc5 Remove unused require() in clientdb 2014-09-10 11:36:12 -07:00
Johannes Zellner 65f0992d55 Improve debug logging for OAuth routes 2014-09-10 09:15:37 -07:00
Johannes Zellner 3a183fbf64 Reorder routes in server.js to enhance visibility of what we have 2014-09-10 08:15:19 -07:00
Johannes Zellner 8938dc436b Cleanup manifest resources on app uninstallation 2014-09-09 22:33:46 -07:00
Johannes Zellner 7ce61bcb1c webadmin: cache also the title from the appstore on app installation 2014-09-09 22:12:39 -07:00
Johannes Zellner 095a3832fc webadmin: don't rely on polling to get newly installed app 2014-09-09 22:02:25 -07:00
Johannes Zellner 98704f9fb9 Store installed app icons locally in data/icons 2014-09-09 21:36:11 -07:00
Johannes Zellner a718e68892 Do not redefine 'error' and other minor things 2014-09-09 17:32:43 -07:00
Johannes Zellner 9af3e37fd0 Fixing more linter issues 2014-09-09 17:24:02 -07:00
Johannes Zellner 84f1305a96 webadmin: cleanup logout() 2014-09-09 16:45:11 -07:00
Johannes Zellner 215a22dd44 Remove noise from yellowtent.js 2014-09-09 16:39:59 -07:00
Johannes Zellner ac5167461f Remove /api/v1/token and adjust webadmin accordingly 2014-09-09 16:30:24 -07:00
Johannes Zellner 69cce25832 Add some /api/v1/config tests 2014-09-09 15:36:35 -07:00
Johannes Zellner e260f55556 webadmin: angular needs special treatment for sending a json body with DELETE 2014-09-09 09:44:32 -07:00
Johannes Zellner 0355f26485 Reenable the logout route for the time being 2014-09-09 09:29:53 -07:00
Johannes Zellner 5a82cd7b17 Fixup webadmin's client.js to fit new /api/v1/users 2014-09-09 08:50:25 -07:00
Johannes Zellner 1cf9f86882 Fix apps tests for new /api/v1/users 2014-09-09 08:40:06 -07:00
Johannes Zellner 4726dba2df Fix settings tests for new /api/v1/users 2014-09-09 08:33:49 -07:00
Johannes Zellner 5465df3e19 Fix volume tests for new /api/v1/users 2014-09-09 08:32:43 -07:00
Johannes Zellner f186cc8917 Refactor the /api/v1/users routes 2014-09-09 08:29:17 -07:00
Johannes Zellner 4aaa55acdb webadmin: append fqdn to app configuration form 2014-09-09 08:09:46 -07:00
Johannes Zellner 734abbd910 webadmin: append fqdn to app installation form 2014-09-09 08:03:33 -07:00
Johannes Zellner 7b038291ce webadmin: fix refresh on app install view 2014-09-09 00:52:56 -07:00
Johannes Zellner 998a9ca962 Ensure we actually call the correct heartbeat URL 2014-09-08 08:30:24 -07:00
Johannes Zellner 31ff3c4ec0 Cleanup some linter issues 2014-09-08 08:20:42 -07:00
Johannes Zellner 882645afcf Rely on heartbeat to notify appstore on restart 2014-09-08 08:13:22 -07:00
Johannes Zellner d0c50e9580 Announce with config.fqdn instead of os.hostname()
This breaks one test but it's too late to fix the test
will do tomorrow
2014-09-07 22:52:42 -07:00
Johannes Zellner 75ea497711 Non 200 status codes on announce after reboot are ok
This happens when the cloudron itself rebooted and the
appstore had no clue of that. But in case the appstore
triggered the reboot, the cloudron will announce itself
and thus concludes a successful reboot
2014-09-07 22:14:08 -07:00
Johannes Zellner 938dd62a4a The cloudron should announce itself once every restart 2014-09-07 21:48:04 -07:00
Johannes Zellner 7298e066ba Add reboot route and webadmin UI
The reboot route will also be called from the reboot action
in the appstore to attmept a soft reboot, rather than a power
cycle.
2014-09-07 19:27:31 -07:00
Johannes Zellner c1460f419e webadmin: fix state bug in side panel during 2014-09-07 16:16:40 -07:00
Johannes Zellner f8837ba284 webadmin: remove useless returns 2014-09-07 16:01:28 -07:00
Johannes Zellner d02f498c2f webadmin: ensure app details controller waits for Client to be ready 2014-09-07 15:46:11 -07:00
Johannes Zellner b789395941 webadmin: ensure we display a fallback icon for apps in appstore 2014-09-07 14:20:29 -07:00
Johannes Zellner 1b90b5bb09 webadmin: remove some noisy console logs 2014-09-07 12:03:29 -07:00
Girish Ramakrishnan 9eece04682 Fix error when box does not app update information yet 2014-09-06 20:46:04 -07:00
Girish Ramakrishnan f00ea968a9 Make apps resume on reboot
Add a new runState to mark apps that died by themselves (or by
the docker daemon).

Fixes #75
2014-09-06 20:19:42 -07:00
Girish Ramakrishnan dcbba0f0e8 Use updateWithConstraints in setHealth 2014-09-06 20:12:25 -07:00
Girish Ramakrishnan 6811d1a380 Update app object only if update succeeded 2014-09-06 20:03:45 -07:00
Girish Ramakrishnan c93863ef58 Create separate partition for docker images and appdata
This allows us to track their usage easily

Note that files created using dd/truncate are sparse files!
https://wiki.archlinux.org/index.php/sparse_file

Part of #72
2014-09-06 18:43:27 -07:00
Girish Ramakrishnan 0fa3f63673 Upgrade ubuntu as well 2014-09-06 18:43:27 -07:00
Girish Ramakrishnan 878b2ccfe9 Remove code that updates the box repo
This code was used previously when we used to run setup script
over and over again on same base image. This is not done anymore.
2014-09-06 18:43:27 -07:00
Girish Ramakrishnan 59623d783c /etc/yellowtent is not used anymore 2014-09-06 18:43:27 -07:00
Johannes Zellner 665d7981d8 webadmin: add real form validation to password change 2014-09-06 11:32:44 -07:00
Johannes Zellner 77a8af452d Set the proper angular app name in JS code 2014-09-06 10:57:57 -07:00
Girish Ramakrishnan 35015687f3 Set scrub_data=true when destroying droplet
This is set by default from what I understand but this is good to
set explicitly so we remeber this should we move away from DO.

https://github.com/fog/fog/issues/2525
https://www.digitalocean.com/company/blog/transparency-regarding-data-security/
2014-09-06 09:16:28 -07:00
Girish Ramakrishnan 16d9daa0bd Rename YellowTent application to Application 2014-09-06 08:33:41 -07:00
Johannes Zellner 016a94b3a6 Add delay module as dev dependency
This is useful to simulate a slow network easily
and helps thus to debug our angular ui.
2014-09-05 17:52:35 -07:00
Johannes Zellner a8b8603946 webadmin: hook up the admin flag toogle to the rest call 2014-09-05 17:38:40 -07:00
Johannes Zellner 0f4a114c8f Add new route to set admin flag
We might want to consolidate the /user(s) routes at some point
2014-09-05 09:01:45 -07:00
Johannes Zellner 56c2de6c37 Add means to set the admin flag for users 2014-09-05 08:19:38 -07:00
Girish Ramakrishnan b68603bbfd Remove spurious log 2014-09-04 19:43:46 -07:00
Girish Ramakrishnan 5bc4e6e46f exposeAs -> hostPort 2014-09-04 19:34:16 -07:00
Girish Ramakrishnan 95769661ac Remove spurious debug 2014-09-04 19:30:18 -07:00
Girish Ramakrishnan 08c165d4a1 Release 0.3.0 2014-09-04 14:40:34 -07:00
Girish Ramakrishnan d6cc39dd01 Fix VERSIONS.json 2014-09-04 14:37:53 -07:00
Girish Ramakrishnan 2705667546 make first argument the suffix 2014-09-04 14:33:56 -07:00
Girish Ramakrishnan 2d1a594453 tcp_ports -> tcpPorts 2014-09-04 12:09:36 -07:00
Girish Ramakrishnan e2ab01339d Pull in base:0.4 as well 2014-09-04 11:30:56 -07:00
Girish Ramakrishnan 785b021129 Backup every 4 hours 2014-09-04 07:19:45 -07:00
Girish Ramakrishnan e8f7c74a0f Compare against appStoreId 2014-09-03 23:28:53 -07:00
Girish Ramakrishnan fd9d475c1e Send appStoreId when querying updates 2014-09-03 22:54:13 -07:00
Girish Ramakrishnan 062313bfbc Give up on json yet again 2014-09-03 20:23:19 -07:00
Girish Ramakrishnan 615b559652 Fix typo 2014-09-03 20:15:17 -07:00
Girish Ramakrishnan a72de47c6e In dev, use latest version 2014-09-03 20:10:05 -07:00
Girish Ramakrishnan cefc7736db Release 0.2.0 2014-09-03 19:51:39 -07:00
Girish Ramakrishnan 548e23cbbe Update script may not exist for a version
In such a case, we just update the code
2014-09-03 19:46:06 -07:00
Girish Ramakrishnan 7905a572ab config.js should always have the upcoming version 2014-09-03 19:46:00 -07:00
Girish Ramakrishnan c2a3ceb22e Use config.version instead of pkg.version 2014-09-03 19:39:44 -07:00
Girish Ramakrishnan 92c4ba2bbc Pull specific version of base 2014-09-03 16:09:24 -07:00
Girish Ramakrishnan b0ac3b5de0 Create version 0.1.0
Fix update script to call scripts using their version number
2014-09-03 15:55:43 -07:00
Girish Ramakrishnan 8352a6618c Fix apptask states
Fixes #67
2014-09-03 15:07:42 -07:00
Girish Ramakrishnan a76e891b5f Add asserts 2014-09-03 14:52:01 -07:00
Girish Ramakrishnan 75c2d9df05 remove oauth credentials during installation
this is needed if an app that was pending install was aborted midway
and we attempt to install it again (for example, during restore/resume)
2014-09-03 14:04:49 -07:00
Girish Ramakrishnan d3abc9c071 Only stopTask when committed in database 2014-09-03 11:00:21 -07:00
Girish Ramakrishnan df5e6484e3 Add appdb.exists 2014-09-03 10:31:28 -07:00
Girish Ramakrishnan b4cfb0214b apptask: Do not kill existing task until the db operation succeeds 2014-09-03 10:05:35 -07:00
Girish Ramakrishnan 8408954f46 Restart nginx after update 2014-09-03 08:37:33 -07:00
Girish Ramakrishnan c58f6f3253 Update the version in cloudron.conf in updater script 2014-09-03 08:32:50 -07:00
Girish Ramakrishnan 83bfb7d0f7 Stop the box before upgrade
This is required should the upgrade scripts do any db
manipulation, for example
2014-09-03 08:16:29 -07:00
Girish Ramakrishnan bce609ed52 Make APPSTORE_URL configurable
Specify dev or alpha as first argument
2014-09-03 08:13:12 -07:00
Girish Ramakrishnan 4458dd4dfd Add more apps tests 2014-09-03 07:56:42 -07:00
Girish Ramakrishnan 0d66bc5e3c Add apps test 2014-09-02 16:03:34 -07:00
Girish Ramakrishnan 2355be222b Query VERSIONS.json from git repo 2014-09-02 12:59:28 -07:00
Girish Ramakrishnan 182d5a9969 Rename boxUpdate to boxUpdateInfo 2014-09-02 11:17:46 -07:00
Girish Ramakrishnan b0d220b409 rename updateInfo to appUpdateInfo 2014-09-02 11:15:40 -07:00
Girish Ramakrishnan 6378ad34e0 Use tag or sha1 in droplet and image name
Using branch name doesn't make much sense since branches can move
2014-09-02 10:53:33 -07:00
Girish Ramakrishnan 225e0959db Add revision to snapshot name as well 2014-09-02 10:10:57 -07:00
Johannes Zellner 28b0b93363 Allow updates to origin/master on dev deployment 2014-09-01 12:52:25 -07:00
Johannes Zellner 09454012a7 Save new version after update in configuration 2014-09-01 12:38:34 -07:00
Johannes Zellner e4789c27aa Call the update.sh with the revsion argument 2014-09-01 12:38:16 -07:00
Johannes Zellner 5d3b828bb5 webadmin: Show update version and changelog in dialogs 2014-09-01 12:23:59 -07:00
Johannes Zellner 03c3d1d71f Only send the show the next version for box updates 2014-09-01 12:11:27 -07:00
Johannes Zellner 60cf05e5c4 Make box and app update info available 2014-09-01 12:04:48 -07:00
Johannes Zellner 03d7ecf6ea Add VERSIONS.json and make the update check on interval 2014-09-01 11:54:58 -07:00
Girish Ramakrishnan 3cfd2c5e26 droplets cannot have _ in box name
because _ is not valid subdomain
2014-08-29 13:54:06 -07:00
Girish Ramakrishnan d6ecb4aa55 Allow creation of DO images for a specific revision 2014-08-29 13:25:56 -07:00
Girish Ramakrishnan c192020a4b Rename script 2014-08-29 11:05:58 -07:00
Girish Ramakrishnan 026f8694a4 Leave a note on why runState is reset 2014-08-28 14:42:32 -07:00
Girish Ramakrishnan 371ce2ca80 Fix openApp link in appstore view 2014-08-28 13:24:02 -07:00
Girish Ramakrishnan 553f401292 Allow multiple instances of apps
Fixes #68
2014-08-28 13:14:02 -07:00
Girish Ramakrishnan a83572e561 Use path.join instead 2014-08-28 13:14:02 -07:00
Girish Ramakrishnan e82997c412 app_id -> appId
we use camelCase everywhere
2014-08-28 11:32:23 -07:00
Girish Ramakrishnan dfb23f2869 Do not use the object based binding
It's verbose
2014-08-28 11:25:51 -07:00
Girish Ramakrishnan 8e504773ab Do not waste time with json -I -f 2014-08-28 08:58:30 -07:00
Girish Ramakrishnan 5bbcb9ff8c Add the in-place replace flag 2014-08-28 08:44:01 -07:00
Johannes Zellner 642a92d485 Show nice error page if something goes wrong during OAuth 2014-08-28 08:19:00 -07:00
Girish Ramakrishnan 53b8ee26c9 Replacing token still does not work at times 2014-08-28 08:15:18 -07:00
Girish Ramakrishnan 7671af7b09 run the app when runState is null
The runState is null during restore. And also for the small time
immediately after the install of an app.
2014-08-28 03:36:40 -07:00
Girish Ramakrishnan d5accd2858 Ignore 409 in subdomain registration 2014-08-28 03:32:59 -07:00
Girish Ramakrishnan 7d90646e11 Start containers after backup 2014-08-28 03:18:35 -07:00
Girish Ramakrishnan 9b760829ea Move to different directory before replacing source dir
You get errors in the shell like below:

shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

This is probably the reason why the json binary didn't work
2014-08-28 03:08:38 -07:00
Girish Ramakrishnan ad1f14ba67 Log command line args for debugging 2014-08-28 02:35:12 -07:00
Girish Ramakrishnan 5ddbf27435 reset fields to null on restore 2014-08-28 02:14:28 -07:00
Girish Ramakrishnan 4d70600ef1 print the git revision 2014-08-28 01:55:05 -07:00
Girish Ramakrishnan b23af68b59 Do not use json binary
Use a custom script instead
2014-08-28 01:30:48 -07:00
Girish Ramakrishnan cb0a4a8ad8 Implement restore
The restore script set installation state as pending_restore for
all apps.
2014-08-27 23:30:56 -07:00
Girish Ramakrishnan d3bc50bfe8 Disable hock.throwOnUnmatched
Without this, hock throws when the server makes queries for the appstore
(like the announce).
2014-08-27 23:12:47 -07:00
Girish Ramakrishnan fd1b0fe8ce Use startTask in resume 2014-08-27 23:05:14 -07:00
Girish Ramakrishnan 6eda87eb84 Separate out delete and create volume 2014-08-27 22:53:58 -07:00
Girish Ramakrishnan 6988bf1759 Remove extran line 2014-08-27 21:00:21 -07:00
Girish Ramakrishnan 3f9d7da260 Backup and restore the box code 2014-08-27 20:55:43 -07:00
Girish Ramakrishnan b125ce1d2b Install npm modules and chown ownership 2014-08-27 20:34:22 -07:00
Girish Ramakrishnan 967e6647de ip is not part of config anymore 2014-08-27 19:57:02 -07:00
Girish Ramakrishnan 76d85b209a Update bootstrap.sh to have the latest update.sh location 2014-08-27 19:16:53 -07:00
Girish Ramakrishnan 312dbd369c Fix various bugs in appdb.setHealth 2014-08-27 19:08:08 -07:00
Girish Ramakrishnan 8600d3ec34 Show health icon based on app.healthy instead of runState 2014-08-27 18:24:27 -07:00
Girish Ramakrishnan 9c8b54f614 Move update scripts inside src/
The scripts/ dir is for helper scripts to be run by hand
The src/scripts dir is for scripts to be run by code
2014-08-27 18:03:48 -07:00
Girish Ramakrishnan f21cb3716c Fix typo 2014-08-27 17:57:19 -07:00
Girish Ramakrishnan de8365c3ce Detect IP locally so there is one less setting to fixup on restore
The appstore still send the IP across just in case
2014-08-27 17:48:55 -07:00
Girish Ramakrishnan 4516b8f408 Add TODO 2014-08-27 15:53:38 -07:00
Girish Ramakrishnan c39689694e Prefix private varibles with _ 2014-08-27 14:13:36 -07:00
Girish Ramakrishnan 5b6f53824b Clear backup timer when server stopped 2014-08-26 17:44:50 -07:00
Johannes Zellner 6724798de8 webadmin: prepare for adding and removing user as admins 2014-08-26 11:03:33 -07:00
Johannes Zellner 6b5b2f1686 Do not show app reconfiguration button if the app is not installed 2014-08-25 09:35:18 -07:00
Johannes Zellner eb21b531b3 Do not fail during reconfiguration if there is no such container 2014-08-25 09:34:01 -07:00
Johannes Zellner 98a91c2b4f Only install app if state is PENDING_INSTALL 2014-08-25 09:28:43 -07:00
Johannes Zellner 6a3350a54c Do not make healthtask exit on error 2014-08-25 09:28:17 -07:00
Johannes Zellner bf77f77b56 Also restart nginx after restore 2014-08-25 03:52:46 -07:00
Johannes Zellner 632b3c488c Finally fix the token replacement 2014-08-25 03:38:01 -07:00
Johannes Zellner 23ca086e12 Fix token replacement 2014-08-25 03:22:17 -07:00
Girish Ramakrishnan d8e556230c Fix various bloopers in update code 2014-08-25 03:08:27 -07:00
Girish Ramakrishnan 883275ebc9 Fix typo 2014-08-25 03:08:27 -07:00
Girish Ramakrishnan 23a67e921e Show update button only if a new version is available 2014-08-25 03:08:26 -07:00
Johannes Zellner 84cf457b4e Fixup token replacement in restore.sh 2014-08-25 02:43:19 -07:00
Girish Ramakrishnan e0625be396 webadmin: Add update button 2014-08-25 02:35:13 -07:00
Johannes Zellner 3549542c3d Replace token with new value on restore 2014-08-25 02:09:36 -07:00
Girish Ramakrishnan 592742eaab Add app update routes 2014-08-25 01:59:21 -07:00
Girish Ramakrishnan b4b03bbe2a config.update signals availability of box update 2014-08-25 01:51:49 -07:00
Girish Ramakrishnan b3f26a78d5 Send appIds in boxupdate request 2014-08-25 01:47:34 -07:00
Girish Ramakrishnan d76965c777 Use post for boxupdate queries 2014-08-25 01:12:56 -07:00
Girish Ramakrishnan 14f805fa47 Remove available 2014-08-25 01:09:58 -07:00
Johannes Zellner 1c56934a4d When restoring finish request to appstore always for now 2014-08-25 00:51:17 -07:00
Girish Ramakrishnan 03e89699b9 appdb: add getAppVersions 2014-08-24 23:31:48 -07:00
Girish Ramakrishnan d80ed67dd7 Implement app update
Part of #34
2014-08-24 23:17:41 -07:00
Girish Ramakrishnan 4f7fa7ea45 log to /var/log/cloudron/ 2014-08-24 22:55:51 -07:00
Girish Ramakrishnan ff575243dc Save app version in apps table 2014-08-24 22:50:50 -07:00
Girish Ramakrishnan ff2ae3a5f5 Update containerId in db after container deletion 2014-08-24 22:03:25 -07:00
Girish Ramakrishnan 7cc1888ff0 Use GLOB in sql query
GLOB is case-sensitive and uses shell matching
LIKE is case-insensitive and use % and _ instead of * and ?
2014-08-24 21:54:34 -07:00
Johannes Zellner a3e98fa550 Make backup filename compatible with JS Date() 2014-08-24 20:51:16 -07:00
Girish Ramakrishnan ceac771967 Remove unused file 2014-08-24 19:22:20 -07:00
Girish Ramakrishnan 930cbc071f Implement restore script 2014-08-24 19:22:16 -07:00
Girish Ramakrishnan ec4cd4a213 Update bootstrap scripts with path to new scripts dir 2014-08-24 17:44:12 -07:00
Girish Ramakrishnan b718dd75f1 S3_BUCKET was mistakenly overriden 2014-08-24 17:40:25 -07:00
Girish Ramakrishnan e672f13fd6 Move source scripts to src/scripts 2014-08-24 17:32:44 -07:00
Girish Ramakrishnan 501f2f54cd Check for 304 in start/stop container
This is part of Docker rmeote API v1.13 to signal that the container
has not been modified (it's already in that state)
2014-08-24 17:18:48 -07:00
Girish Ramakrishnan 1c733b7fbb Do not override PENDING states in db
The apphealthtask basically keep the database and the docker app
state in sync. But it should not overwrite any of the *_PENDING_*
commands which are commands from the REST API to the apptasj.
2014-08-24 16:37:46 -07:00
Girish Ramakrishnan 49e55b9dec Return 409 for bad state 2014-08-24 16:20:00 -07:00
Girish Ramakrishnan 9c52d48046 Do not resume explicitly stopped apps 2014-08-24 16:18:31 -07:00
Johannes Zellner 7f21c675ff Reduce noise when expecting an error in a test 2014-08-24 15:06:39 -07:00
Girish Ramakrishnan c86ff884fa Enable configure/start/stop buttons in the correct state 2014-08-24 14:58:09 -07:00
Johannes Zellner 2f8430526d Add restore route 2014-08-24 14:56:25 -07:00
Johannes Zellner deb7698a8a Ensure provisioning route gets all needed aws credentials 2014-08-24 14:56:25 -07:00
Girish Ramakrishnan 790992d777 Mark app as running 2014-08-24 14:42:38 -07:00
Girish Ramakrishnan cff35457fd Start docker proxy before the app 2014-08-24 13:48:22 -07:00
Girish Ramakrishnan c61f837a8d Unset health in error or stopped state 2014-08-24 13:18:21 -07:00
Johannes Zellner b609c6c4d7 webadmin: poll for box to come back alive after backup 2014-08-24 13:16:35 -07:00
Johannes Zellner 6a4c192d3e Send empty object for backup route 2014-08-24 13:14:50 -07:00
Johannes Zellner 3280a8c975 Actually reset git in update 2014-08-24 13:11:54 -07:00
Johannes Zellner bd0b5cde96 Fix the appdb JOINS 2014-08-24 13:01:43 -07:00
Johannes Zellner d8b36dd342 webadmin: show modal dialog during backup 2014-08-24 12:08:03 -07:00
Johannes Zellner c8a5ce118f Remove unused unmountall.sh 2014-08-24 12:02:41 -07:00
Johannes Zellner 2548340659 Move update script execution to the Updater 2014-08-24 12:01:08 -07:00
Johannes Zellner c480dd9862 webadmin: show backup button only when running on dev 2014-08-24 11:50:28 -07:00
Johannes Zellner 631bce8da0 Sync filesystems before we shutdown 2014-08-24 11:44:53 -07:00
Girish Ramakrishnan 58ad822841 Redirect backup output to logfile 2014-08-24 09:16:34 -07:00
Girish Ramakrishnan e78dfedd9f Schedule a backup every midnight 2014-08-24 04:42:16 -07:00
Johannes Zellner 609616b89b Fix syntax error in bootstrap.sh 2014-08-24 04:39:11 -07:00
Girish Ramakrishnan ad62bf95b0 Do not be cute with shell scripting 2014-08-24 04:33:25 -07:00
Girish Ramakrishnan ae1e49824c tar does not like absolute paths 2014-08-24 04:23:26 -07:00
Girish Ramakrishnan b570a73f23 Give up on trying to teach sudo to preserve env 2014-08-24 04:12:39 -07:00
Johannes Zellner accf4576f6 make create image script poll for droplet IP 2014-08-24 02:21:43 -07:00
Girish Ramakrishnan 32837e36ef Implement backup
Fixes #32
2014-08-24 01:58:03 -07:00
Johannes Zellner 0ffe837c60 Allow bootstrap.sh to run as root without password 2014-08-24 01:39:55 -07:00
Johannes Zellner d9d125468c Log everything to /var/log/cloudron/ 2014-08-24 01:38:57 -07:00
Girish Ramakrishnan dd2a8e9224 Resume all docker apps on startup
Fixes #64
2014-08-23 21:24:37 -07:00
Girish Ramakrishnan ad4285d55a Send appId instead of id 2014-08-23 21:21:51 -07:00
Girish Ramakrishnan 68fdce4b67 Continue if oauth creds not found 2014-08-23 20:38:57 -07:00
Johannes Zellner 7b3f715fe4 webadmin: Fix typo in dev updater 2014-08-23 20:28:22 -07:00
Girish Ramakrishnan 894032e53c Make configure and start btn-primary 2014-08-23 20:24:01 -07:00
Girish Ramakrishnan d5c7ac1207 Ingore any unlink errors
Probably because the file does not exist in the first place
2014-08-23 20:19:14 -07:00
Girish Ramakrishnan 49af0ce6b6 do not barf if image/container was not found 2014-08-23 18:28:52 -07:00
Girish Ramakrishnan e58ae3627a console.error instead 2014-08-23 18:27:40 -07:00
Girish Ramakrishnan 4102350343 Adapt to new manifest format 2014-08-23 17:14:09 -07:00
Girish Ramakrishnan 20f8c74190 Implement a docker proxy to speed up the tests 2014-08-23 14:24:47 -07:00
Girish Ramakrishnan 323710f735 old nginx config can be removed
Should have been part of f51f0ff56c

Fixes #37
2014-08-23 12:48:06 -07:00
Girish Ramakrishnan 327b198f33 Register and unregister subdomain with appId 2014-08-23 12:42:10 -07:00
Johannes Zellner 056e70ff78 webadmin: remove appstore list flickering and mark installed apps 2014-08-23 12:07:04 -07:00
Girish Ramakrishnan f51f0ff56c Generate nginx configs based on appid instead of location
Part of #37

This lets us not remember the old location (for removal)
2014-08-23 12:04:54 -07:00
Girish Ramakrishnan e9996d3eb2 Remove installationState arg from appdb.add
Always add with pending install state
2014-08-23 11:40:07 -07:00
Girish Ramakrishnan 565d8844ca Fix bugs in appdb.update 2014-08-23 11:23:53 -07:00
Girish Ramakrishnan ba3d8ba6d2 Fix tests 2014-08-23 11:04:29 -07:00
Girish Ramakrishnan bed631123f installationProgress can be null 2014-08-23 11:02:16 -07:00
Girish Ramakrishnan 42740638c8 Fix typo 2014-08-23 10:59:13 -07:00
Girish Ramakrishnan 602bae1af5 webadmin: Rename applist to appstore 2014-08-23 10:48:51 -07:00
Girish Ramakrishnan 3f1f2517d6 Make uninstall fail if any of the steps fail 2014-08-23 10:15:51 -07:00
Girish Ramakrishnan 7a5722f04d Add installationProgress field to indicate progress 2014-08-23 10:07:29 -07:00
Girish Ramakrishnan 0d05f34aca Display configure button on error or installed 2014-08-23 09:54:35 -07:00
Girish Ramakrishnan 4ff9c9547d Make portBindings part of app object 2014-08-23 09:26:59 -07:00
Girish Ramakrishnan 9e5cc01141 Implement app reconfiguration
We need to store the old location somewhere to delete the old
nginx config correctly
2014-08-23 09:16:35 -07:00
Girish Ramakrishnan 117dba4196 Fix suggested_locations 2014-08-23 08:22:09 -07:00
Johannes Zellner df0acac2a9 webadmin: Show update button when update is available 2014-08-23 04:33:10 -07:00
Girish Ramakrishnan 90c81a4cb4 Refactor apptask 2014-08-23 04:04:28 -07:00
Johannes Zellner 49d65c3b42 Add Updater to query the appstore for new box versions 2014-08-23 02:33:35 -07:00
Girish Ramakrishnan 112946c3ce Make portBindings a simple map of container -> host port 2014-08-23 02:11:34 -07:00
Johannes Zellner 19c4122289 Do not stringify the Error object 2014-08-23 01:51:22 -07:00
Girish Ramakrishnan 1f2a07a67d Rename exposeAs to hostPort 2014-08-23 00:50:56 -07:00
Girish Ramakrishnan 92d1aebe40 Make healthy a separate bit in the database
Do not alter the run state
2014-08-23 00:10:59 -07:00
Girish Ramakrishnan 72c06d5774 Return port bindings as part of app object 2014-08-22 23:55:50 -07:00
Girish Ramakrishnan 119917529f webadmin: Rename appconfigure to appinstall 2014-08-22 11:44:11 -07:00
Johannes Zellner 615e6a1d6b webadmin: hide UI when update is in progress 2014-08-22 08:34:50 -07:00
Johannes Zellner 4b51dbef54 deliver latest git revision and show in webadmin 2014-08-22 08:25:26 -07:00
Johannes Zellner 4e7b017bb5 Store provisioned IP in config.js 2014-08-22 07:40:23 -07:00
Johannes Zellner 8b4a4b052d explicitly run with /bin/bash 2014-08-22 07:32:57 -07:00
Johannes Zellner e2ca2c9b24 webadmin: hide actions if unprivileged user 2014-08-22 07:27:43 -07:00
Johannes Zellner 7eaac0e7ae Add basic update.sh 2014-08-22 07:16:21 -07:00
Girish Ramakrishnan 8de4062cc4 Add UI to start/stop apps 2014-08-21 22:28:54 -07:00
Girish Ramakrishnan e63172ad57 Do not require passwords for start, stop app routes
Disable it for the moment
2014-08-21 22:20:28 -07:00
Girish Ramakrishnan 2fd90a9a2a Add route to start and stop apps 2014-08-21 20:43:23 -07:00
Girish Ramakrishnan 8ae5a662f9 apptask: Update to ISTATE_ERROR in install 2014-08-21 18:04:27 -07:00
Johannes Zellner 1c343de3d4 webadmin: do not travel to /dashboard when attempting to logout 2014-08-21 16:39:15 -07:00
Johannes Zellner 62d6d2fa27 webadmin: fade content views 2014-08-21 16:33:43 -07:00
Johannes Zellner 17b0497411 webadmin: refresh user list after user deletion 2014-08-21 16:23:07 -07:00
Johannes Zellner d059354631 webadmin: show userlist after usercreation 2014-08-21 16:21:13 -07:00
Johannes Zellner 1a3e269749 webadmin: remove acute combo box plugin 2014-08-21 15:45:46 -07:00
Johannes Zellner ac51ab46fd webadmin: remove unused splash view 2014-08-21 15:40:02 -07:00
Johannes Zellner 209e8b01fc webadmin: remove spin.js 2014-08-21 15:38:37 -07:00
Johannes Zellner 41f9885f69 webadmin: move script includes to the top 2014-08-21 15:34:26 -07:00
Johannes Zellner 687abe4f3b webadmin: remove unused angularjs ui.bootstrap 2014-08-21 15:32:15 -07:00
Johannes Zellner dcde3a07b6 webadmin: add basic user creation 2014-08-21 14:28:22 -07:00
Johannes Zellner b06b8df746 webadmin: add user deletion dialog 2014-08-21 14:09:26 -07:00
Johannes Zellner e81f42f508 webadmin: Enable userlist view 2014-08-21 11:49:03 -07:00
Girish Ramakrishnan 422f6d4981 Display app title in configure screen 2014-08-21 08:41:27 -07:00
Girish Ramakrishnan b08b0a5494 Change cert generation dir 2014-08-20 01:54:39 -07:00
Girish Ramakrishnan df63793c61 Change naming convention of files under cert/*.
Follow the naming convention as used in provisioning by appstore:

host.cert = public cert
host.info = textual output
host.key = private key
host.pem = key file and cert file combined into one
2014-08-20 01:35:56 -07:00
Girish Ramakrishnan 525aa523ff Copy over nginx setup code from scripts/bootstrap.sh
Copying nginx/* from source repo copies over a lots of other files
2014-08-20 00:49:42 -07:00
Girish Ramakrishnan 79a06beb4f generate admin.conf from template
6fe11f869a broke it probably
2014-08-20 00:45:42 -07:00
Girish Ramakrishnan f302062306 Move nginx cert dir to be under backup dir 2014-08-20 00:34:02 -07:00
Girish Ramakrishnan f46f1e3154 Remove any existing volume from a previous bad uninstall 2014-08-19 23:31:38 -07:00
Girish Ramakrishnan 30fad2d889 Access app.manifest carefully
manifest may not be valid if download of manifest had failed
2014-08-19 23:18:27 -07:00
Girish Ramakrishnan aa2f07ae63 Increase counter to make it pass consistently 2014-08-19 23:17:29 -07:00
Girish Ramakrishnan 664d0e652c Update README
Setting hostname or FQDN is not needed anymore after 6fe11f8
2014-08-19 23:07:02 -07:00
Johannes Zellner 32dc09649f Fix this/that typo 2014-08-19 22:31:21 -07:00
Johannes Zellner 5d5b824883 Do not use FQDN setting as a token...
...when announcing the cloudron with the appstore server
2014-08-19 22:20:26 -07:00
Johannes Zellner 6fe11f869a Do not depend on os.hostname() for fqdn
The non provisioned boxes will always be configured
to work on localhost. This includes the webadmin OAuth
records. After the cloudron gets provisioned, the FQDN
will be set to the correct value, which requires regeneration
of the OAuth client records.
2014-08-19 22:05:50 -07:00
Girish Ramakrishnan 4994325a79 Don't set NODE_TLS_REJECT_UNAUTHORIZED
The issue had to do with intermediate cert installation

See 9009d98c4f392 in appstore
2014-08-19 18:46:55 -07:00
Girish Ramakrishnan c816861530 Pick specific properties to be set in config 2014-08-19 18:45:36 -07:00
Girish Ramakrishnan 349436aa66 Add underscore 2014-08-19 18:43:49 -07:00
Girish Ramakrishnan 74403385b9 Increase announce timer retry interval
5 seconds is way too often
2014-08-19 18:39:23 -07:00
Johannes Zellner f0a349710b Verify clientId with clientSecret instead of appId with clientSecret 2014-08-19 16:29:43 -07:00
Girish Ramakrishnan 1e7f806a11 Setup oauth variables when creating container
APP_ORIGIN
    The origin of the app. Like https://foo-box.domain.com
    The box cannot use os.hostname(). This is because docker sets up
    the container's hostname() to be just the host name (and not FQDN)
    and node uses gethostbyname(). This is simply a convenience instead
    of executing hostname -f.

ADMIN_ORIGIN
    The origin of the box admin. Like https://admin-box.domain.com

OAUTH_CLIENT_ID
OAUTH_CLIENT_SECRET
    Self explanatory oauth variables

Part of #47
2014-08-19 12:47:14 -07:00
Johannes Zellner dd1ceeed2f Fix makeDocs.sh 2014-08-19 11:28:44 -07:00
Johannes Zellner affa254b41 Some more linter cleanups 2014-08-19 09:36:39 -07:00
Johannes Zellner 8fe325e3bb Some linter cleanups 2014-08-19 09:33:57 -07:00
Johannes Zellner 4386c9033c Allocate OAuth credentials for apps during installation 2014-08-19 09:31:09 -07:00
Johannes Zellner 4fa693de8b webadmin: Move script tags back to the page header 2014-08-18 08:03:00 -07:00
Johannes Zellner b4117f320b Add 'ip' to config.js 2014-08-17 18:09:55 -07:00
Johannes Zellner 5fe37b1dff Use HttpError for update route 2014-08-17 18:09:53 -07:00
Johannes Zellner 96e609dbc5 Reload webadmin after update 2014-08-17 18:09:36 -07:00
Johannes Zellner 2c9e3b9b5d Fix typo for progress dialog 2014-08-17 17:46:54 -07:00
Johannes Zellner dbf5c7f6fe Add in-progress modal dialog during update 2014-08-17 17:42:10 -07:00
Johannes Zellner 2040409968 Show IP address in settings panel 2014-08-17 17:29:55 -07:00
Johannes Zellner 911ef5f4bf Add some basic git based update route 2014-08-17 17:29:49 -07:00
Johannes Zellner 7e27c96b67 Fixup the icon url for apps 2014-08-17 16:51:30 -07:00
Girish Ramakrishnan 6da1e829f3 Adjust routes to match new appstore routes
Part of #29
2014-08-13 17:02:18 -07:00
Girish Ramakrishnan ae9819848b Reverse the arguments in DatabaseError 2014-08-13 15:46:47 -07:00
Girish Ramakrishnan a737e6d1a4 Move business logic + validation from routes code to apps.js
Part of #57
2014-08-13 15:17:01 -07:00
Girish Ramakrishnan cf748fe501 Do not use db directly in routes
Part of #57
2014-08-13 14:32:46 -07:00
Girish Ramakrishnan ed28afdb78 Change name of droplet on each run 2014-08-12 18:05:48 -07:00
Girish Ramakrishnan 59f2f48c14 Fix path to script 2014-08-12 18:03:38 -07:00
Girish Ramakrishnan becda1274f Fix path to ssh keys 2014-08-12 17:45:16 -07:00
Girish Ramakrishnan 62cde20fc2 Better shell scripting 2014-08-12 17:30:48 -07:00
Girish Ramakrishnan 7fc0fd0b9b From appstore repo 2014-08-12 16:56:06 -07:00
Girish Ramakrishnan 2684264e3f Finish base image creation script 2014-08-12 16:21:05 -07:00
Girish Ramakrishnan f6ad431936 chmod +x nsenter 2014-08-11 18:39:55 -07:00
Girish Ramakrishnan 8c04c94465 Automate createBaseUbuntuImage 2014-08-11 18:09:12 -07:00
Johannes Zellner 393fa560c9 Add unit test for stats route 2014-08-11 17:58:46 -07:00
Johannes Zellner 435f6748ec webadmin: make sure the forms have input focus 2014-08-11 17:48:49 -07:00
Johannes Zellner 1eac153ab2 webadmin: add loading indicator for appstore view 2014-08-11 17:26:19 -07:00
Johannes Zellner 2a852d4ad3 webadmin: add more installation states 2014-08-11 17:13:58 -07:00
Johannes Zellner 0abc418ea0 webadmin: show appicon in app details view 2014-08-11 16:51:29 -07:00
Johannes Zellner ebf33288cf Add server stat route 2014-08-11 16:48:27 -07:00
Johannes Zellner dcaabc6303 webadmin: Add angular filter for app installation states 2014-08-11 16:31:03 -07:00
Johannes Zellner 6df1f27b57 webadmin: rename the main page to Cloudron Webadmin 2014-08-11 16:05:12 -07:00
Girish Ramakrishnan 0d3bfb7cd1 Install nsenter
Fixes appstore's issue 10
2014-08-11 13:57:49 -07:00
Girish Ramakrishnan 819fd06beb Set the content-type explicitly to javascript
Otherwise it is set to html and you get an error like so:
Resource interpreted as Script but transferred with MIME type text/html: "https://admin-hash.cloudron.us/api/v1/oauth/yellowtent.js".
2014-08-11 13:45:19 -07:00
Johannes Zellner f9c8026091 webadmin: add modal confirm dialog for app deletion 2014-08-11 11:03:41 -07:00
Johannes Zellner 1af9dadad2 Revert "Locally the appstore is running on non ssl"
This reverts commit c609848281.
2014-08-11 10:37:00 -07:00
Johannes Zellner b905ad2c2f webadmin: add more details for installed apps 2014-08-10 23:49:13 -07:00
Johannes Zellner 72bafc8397 webadmin: Add a placeholder dashboard 2014-08-10 23:28:26 -07:00
Johannes Zellner 3dbd44109e webadmin: no need to explicitly creating a new row 2014-08-10 23:08:56 -07:00
Girish Ramakrishnan 81d237038b X-Originating-IP is some email header
X-Forwarded-For gives the address of the client which connected to the proxy
X-Forwarded-Port gives the port the client connected to on the proxy (e.g. 80 or 443)
X-Forwarded-Proto gives the protocol the client used to connect to the proxy (http or https)
X-Forwarded-Host gives the content of the Host header the client sent to the proxy.

I am not sure if rewriting Host header to $host is a good idea.
2014-08-10 22:57:07 -07:00
Girish Ramakrishnan af400a038e Set various proxy headers in nginx config
These headers are required for apps like wordpress to figure the
site url. It is not clear why they do not just use relative urls.

http://cmanios.wordpress.com/2014/04/12/nginx-https-reverse-proxy-to-wordpress-with-apache-http-and-different-port/
2014-08-10 22:31:42 -07:00
Johannes Zellner 4ec9e6d3ca webadmin: show installed apps count and add placeholder if 0 2014-08-10 19:01:13 -07:00
Johannes Zellner 6488675193 webadmin: redirect to apps details during installation 2014-08-10 18:56:37 -07:00
Johannes Zellner 5851f43672 webadmin: add an appdetails view and show apps in the menu 2014-08-10 18:44:25 -07:00
Girish Ramakrishnan 6b84b8fdf4 webadmin: Port bindings are not passwords 2014-08-10 17:17:28 -07:00
Girish Ramakrishnan 892a42f190 webadmin: fix downloading of manifest 2014-08-10 16:53:55 -07:00
Johannes Zellner 3e052175a3 webadmin: style app configuration form 2014-08-10 16:54:49 -07:00
Johannes Zellner 833e58d00f webadmin: Only show 'No Apps available' when we finished retrieving the apps 2014-08-10 12:49:08 -07:00
Johannes Zellner f06746ae6d webadmin: restyle appstore gridview
Bootstrap seems to work just fine with wrapping the elements
depending on the window size, even though we will exceed the 12
column limit
2014-08-10 12:22:24 -07:00
Johannes Zellner c609848281 Locally the appstore is running on non ssl 2014-08-10 12:20:39 -07:00
Johannes Zellner a3511c7a47 webadmin: Remove unused function and properties from the Client 2014-08-09 22:56:11 -07:00
Johannes Zellner cec3902cbb webadmin: some cleanup for setup.html 2014-08-09 22:45:52 -07:00
Johannes Zellner 8172fe923f Set viewport meta tag for OAuth views 2014-08-09 22:39:41 -07:00
Johannes Zellner f9981683b7 webadmin: enable settings link in profile menu 2014-08-09 22:20:28 -07:00
Johannes Zellner afdb739b59 webadmin: add main content animation stub 2014-08-09 22:18:15 -07:00
Johannes Zellner d61d046977 webadmin: show username in navbar 2014-08-09 21:53:12 -07:00
Johannes Zellner 794ecc8347 Only show webadmin UI when MainController has finished initialization 2014-08-09 21:51:39 -07:00
Johannes Zellner dd232e17ea Make admin creation on first time a independent setup step 2014-08-09 21:33:55 -07:00
Johannes Zellner 471291261b Style password change form 2014-08-09 21:10:23 -07:00
Johannes Zellner ab8ef07f84 Fix settings page refresh and style it according to bootstrap theme 2014-08-09 21:06:08 -07:00
Johannes Zellner 6b5c6679bd Make use more use of the bootstrap theme's styles for form and buttons 2014-08-09 20:10:55 -07:00
Johannes Zellner cd8eb63acf Remove unused assets for webadmin and OAuth views 2014-08-09 20:10:36 -07:00
Johannes Zellner dab348ee6b Use sb-admin also in OAuth views 2014-08-09 19:30:05 -07:00
Johannes Zellner c4b3e680a9 Add missing /api/v1/ route prefix 2014-08-09 13:29:52 -07:00
Johannes Zellner 3b0326a69f Run npm install as user with HOME set for that user 2014-08-09 13:12:11 -07:00
Johannes Zellner 98e2bab53d Support https appstore urls when fetching certificate 2014-08-09 13:00:17 -07:00
Johannes Zellner 9d77aa3cbd Fix some linter issues of unused requires 2014-08-09 12:54:49 -07:00
Johannes Zellner 17bec272ab Add fetching certificate from appstore and restart nginx 2014-08-09 12:54:02 -07:00
Girish Ramakrishnan 19922de374 Bump test app version 2014-08-09 10:31:30 -07:00
Girish Ramakrishnan e002fa99aa Remove docker image on app removal
Fixes #55
2014-08-08 21:24:39 -07:00
Girish Ramakrishnan e1935309e0 Fix typo 2014-08-08 19:01:38 -07:00
Girish Ramakrishnan 16a650f65e Pull all base docker images 2014-08-08 13:19:54 -07:00
Girish Ramakrishnan e6fa61f76a Template the admin and app config files with srcdir 2014-08-07 18:02:02 -07:00
Girish Ramakrishnan 6b6be410fd Change nginx prefix directory 2014-08-07 17:00:18 -07:00
Girish Ramakrishnan b0139a3be0 pidfile and logfile are required for ubuntu scripts 2014-08-07 15:43:25 -07:00
Girish Ramakrishnan c83545a2b7 Install rcconf 2014-08-07 15:40:06 -07:00
Johannes Zellner d19094202b Fix typo to create the supervisor log folder 2014-08-07 15:35:31 -07:00
Girish Ramakrishnan 5f7d67655b Store log to persistent storage 2014-08-07 15:00:54 -07:00
Girish Ramakrishnan d01398e460 Fix some bloopers
set -e has already done
Just skip checkout altogether
2014-08-07 12:10:07 -07:00
Girish Ramakrishnan bfb1e584bf Copy mime.types to nginx configuration 2014-08-07 11:55:53 -07:00
Girish Ramakrishnan fa10e77def Do not start supervisor automatically
The bootstrap.sh script enables it after it's done configuring
supervisor
2014-08-07 11:53:02 -07:00
Girish Ramakrishnan 3424e51ba4 Give name to checkout branch 2014-08-07 11:46:00 -07:00
Girish Ramakrishnan de2cc8a905 Run npm install as yellowtent user 2014-08-07 11:31:17 -07:00
Girish Ramakrishnan fab5e40aae Make scripts error out automatically 2014-08-07 11:27:48 -07:00
Girish Ramakrishnan f3f4731a04 Update the code as yellowtent user 2014-08-07 11:23:54 -07:00
Girish Ramakrishnan a280ff77f1 sudoers file is already setup in bootstrap.sh 2014-08-07 11:18:50 -07:00
Girish Ramakrishnan 04f33d365e Rename BASEDIR to SRCDIR 2014-08-07 10:59:25 -07:00
Girish Ramakrishnan f7b49d1449 Fix typo 2014-08-07 10:59:24 -07:00
Girish Ramakrishnan 38c5b94449 Update README with notes for creating box images 2014-08-07 10:51:07 -07:00
Girish Ramakrishnan 1c8cdc1f31 Move nginx files away from repo
Fixes #52
2014-08-07 06:22:12 -07:00
Girish Ramakrishnan f406f873d0 Alias ~/.yellowtent as BACKUP_DIR 2014-08-07 06:17:52 -07:00
Girish Ramakrishnan 09a7e6244b Rename BASEDIR to SRCDIR 2014-08-07 06:13:44 -07:00
Girish Ramakrishnan 0e7648be50 coding style: use camel case 2014-08-07 06:04:18 -07:00
Johannes Zellner e30445b4c4 Make better use of Error objects 2014-08-06 22:46:41 -07:00
Johannes Zellner 3257d2ed98 Fixup apps test for changed subdomains REST API 2014-08-06 22:46:28 -07:00
Johannes Zellner d50aaa0429 No need to stringify Error objects
The stringify actually looses information.
2014-08-06 22:16:19 -07:00
Johannes Zellner 427b270ca1 Use console.error() instead of debug() if we have an error 2014-08-06 22:04:52 -07:00
Johannes Zellner 68372e9b3e Only log box* with debug() when deployed 2014-08-06 21:52:13 -07:00
Johannes Zellner 4ddf83f3f9 Fixup linter issues 2014-08-06 21:34:54 -07:00
Johannes Zellner 3ae937b516 /api/v1/subdomains/ route now contains an s 2014-08-06 21:31:59 -07:00
Johannes Zellner 8d9a0189bb Use new supererror 2014-08-06 20:34:42 -07:00
Girish Ramakrishnan b6be2997f3 Fix logs
fixes #54
2014-08-06 19:35:34 -07:00
Girish Ramakrishnan 785d19f0af Simplify announce test 2014-08-06 18:41:23 -07:00
Girish Ramakrishnan d166b0fbd4 Add tests for config.js 2014-08-06 16:10:39 -07:00
Girish Ramakrishnan 93a6d5f886 TODO: add config tests 2014-08-06 15:51:45 -07:00
Girish Ramakrishnan 7a3285369a Announce repeatedy until successful
Fixes #51
2014-08-06 12:51:38 -07:00
Girish Ramakrishnan 49579da5b3 Tweak various timeouts to make the tests pass consistently
An option is to disable docker.pull during tests
2014-08-06 11:29:44 -07:00
Johannes Zellner 2cc774f956 Update shrinkwrap file 2014-08-06 09:26:12 -07:00
Girish Ramakrishnan 6e7869ef3b Check config.token to verify if already provisioned 2014-08-06 07:25:11 -07:00
Girish Ramakrishnan dcbc632ba9 Remove settingsdb
We now use config as our key/value store

A nice side-effect is that this makes get-test-set atomic.
2014-08-05 15:58:31 -07:00
Girish Ramakrishnan 91b999cadd Move all config data back to a json file
We used to have a yellowtent.conf previously. This change moves back to
the old pattern except the file is called cloudron.conf.

- naked_domain hack is not needed in config.js
- We can load the config.js synchronously and without db being initialized
- works better multiprocess. Initially, I thought I can just pass the config as
  command line or child_process.send() and use the config in apptask. But, apptask
  uses database code which uses config.js. This means then that we either pass
  config around everywhere or we have a config.load() which is asynchronous.

Eventually: we remove settingsdb as well

Probably fixes #50
2014-08-05 15:11:49 -07:00
Girish Ramakrishnan 3f6fa46226 Add db error handlers 2014-08-05 15:11:49 -07:00
Girish Ramakrishnan 27a6eb69f3 Merge box stdout and stderr logs 2014-08-05 15:11:49 -07:00
Johannes Zellner 2f8ca758b5 Adjust to use new boxes announce REST api 2014-08-05 15:00:48 -07:00
Girish Ramakrishnan ffdff37476 Add test for port bindings 2014-08-05 08:24:20 -07:00
Johannes Zellner 1a83225983 Add empty naked_domain config variable in config.js 2014-08-05 07:42:02 -07:00
Johannes Zellner 4fc3bb9f38 Let us know which config key triggered the assert 2014-08-05 07:36:39 -07:00
Johannes Zellner c7aa8a7fc4 Make APP_SERVER_URL explicitly only used for production mode 2014-08-05 07:16:57 -07:00
Girish Ramakrishnan 5804d6d78a Close the hock server in cleanup 2014-08-05 07:08:54 -07:00
Johannes Zellner 593f4a7fad Fixup some linter issues 2014-08-05 06:59:10 -07:00
Girish Ramakrishnan 0d1a5a4b6d Test subdomain registation and unregistration
Fixes #30
2014-08-05 04:43:58 -07:00
Girish Ramakrishnan fbad5317e5 More apptask tests
Part of #30
2014-08-05 04:15:46 -07:00
Girish Ramakrishnan eb3d2deacf Remove unnecessary testcase 2014-08-05 03:35:27 -07:00
Johannes Zellner 8074d3bb94 Fix wrong usage of settingsdb result 2014-08-04 23:53:53 -07:00
Johannes Zellner 0850e6ca2d Replace last occasions of appstoreOrigin with appServerUrl 2014-08-04 23:31:14 -07:00
Johannes Zellner dd619a258d Swap supervisor config file names 2014-08-04 23:28:35 -07:00
Johannes Zellner 19afa8f5f1 Remove any system provided supervisor configs 2014-08-04 22:23:24 -07:00
Johannes Zellner 15bd1c7eb3 Create nginx and box supervisor manifests during bootstrap
Previously we were linking the supervisor config
directory into /etc/supervisor and using template manifests,
which got changed during bootstrapping. In order to avoid
changing files in the git repository and more harder to
follow 'sed's the bootstrap.sh now simply creates those files
directly with appropriate values.
This also eliminates the yellowtent.json, as those values
are now passed via the process.env, set in the supervisor
manifest for the box
2014-08-04 21:50:38 -07:00
Girish Ramakrishnan 81110fd673 test: check that app is running
part of #30
2014-08-04 20:17:00 -07:00
Girish Ramakrishnan a1b7bf628c Test app installation
Part of #30

The test requires docker to be running
2014-08-04 19:20:20 -07:00
Girish Ramakrishnan 9d3d130d31 Make reloadnginx.sh always return 0 for the tests 2014-08-04 17:44:26 -07:00
Girish Ramakrishnan 7844b5bc52 Initial version of app installation test
Part of #30

The actual app installation itself cannot be verified because
nock does not work across processes (apptask is run as a separate
process).
2014-08-04 14:07:22 -07:00
Girish Ramakrishnan 9ab960d7ed Add tests for setting/unsetting naked domain 2014-08-04 14:02:12 -07:00
Girish Ramakrishnan 2ce9167792 Add sinon as dependancy 2014-08-04 12:02:46 -07:00
Girish Ramakrishnan d4e3418c1d Add tests for settings route 2014-08-04 11:48:55 -07:00
Girish Ramakrishnan 9c8bb1c771 Add comment on the purpose of BASE_DIR env var 2014-08-04 10:59:21 -07:00
Girish Ramakrishnan 9bb3b5540b doc: add comment on webadmin oauth client insertion 2014-08-04 10:53:20 -07:00
Girish Ramakrishnan 89932532a2 Ensure each item added to config has been set in config.js 2014-08-04 10:40:40 -07:00
Girish Ramakrishnan 22bb5778aa Remove awkwardly named initialize2 2014-08-04 10:35:13 -07:00
Girish Ramakrishnan c5f4077795 Let routes code require config.js directly 2014-08-04 10:31:42 -07:00
Girish Ramakrishnan 49bb6bcbdb Close database on exit 2014-08-04 10:16:50 -07:00
Girish Ramakrishnan 0b38cf5d45 database.create also initializes database 2014-08-04 10:14:00 -07:00
Girish Ramakrishnan d59d2b9516 Let tables use database module directly
- solves circular dependancy
- do not have to init each and every table code
- allows database to do pooling smartly
2014-08-04 08:25:15 -07:00
Girish Ramakrishnan af73d975bd doc: routes/apps 2014-08-03 13:52:18 -07:00
Girish Ramakrishnan c335f08d52 Fix grammar 2014-08-03 11:12:39 -07:00
Girish Ramakrishnan 797fceebd4 Use async.series 2014-08-03 11:04:16 -07:00
Girish Ramakrishnan 156d34c3c7 Rename config.silent to config.logApiRequests 2014-08-03 10:01:11 -07:00
Girish Ramakrishnan 82bc3ce416 NODE_ENV is always set to production when undefined already 2014-08-03 10:00:05 -07:00
Girish Ramakrishnan 0320409f93 Use config.js directly instead of passing it around
Treat config.js as a global object

BASE_DIR env is set in the config.js so that child processes
(like apphealthtask, apptask) pick up the correct baseDir
2014-08-03 09:59:59 -07:00
Girish Ramakrishnan 8828e7baaf Use safe instead of exceptions 2014-08-02 18:23:31 -07:00
Girish Ramakrishnan 61a97bc3b1 Source config.js directly 2014-08-02 18:12:29 -07:00
Girish Ramakrishnan 92a14997a7 More appconfig tests
Part of #30
2014-08-01 15:44:24 -07:00
Johannes Zellner 881f1aa420 Only show navigation if we are logged in 2014-08-01 14:38:41 -07:00
Johannes Zellner 96fd490d4f Initial cutover to sb-admin theme
Theme is from http://startbootstrap.com/template-overviews/sb-admin-2/
2014-08-01 14:29:42 -07:00
Girish Ramakrishnan abfa4d0b12 Set config value before callback 2014-08-01 14:09:30 -07:00
Girish Ramakrishnan dfb39358d0 More updates to README 2014-08-01 13:34:04 -07:00
Girish Ramakrishnan 7daad02e0b Fix README.md to provide correct paths to sudo scripts 2014-08-01 13:32:03 -07:00
Johannes Zellner a01d9e4c58 Sync config object with settingsdb on startup and provisioning 2014-08-01 11:19:20 -07:00
Girish Ramakrishnan c38ce36b7d Initial apptask tests
Part of #30
2014-08-01 10:51:39 -07:00
Johannes Zellner 80eb87069c Capture bootstrap script output in log file 2014-08-01 08:35:56 -07:00
Johannes Zellner 2b4d927b42 Make bootstrap script exectuable 2014-08-01 08:19:03 -07:00
Johannes Zellner e466a49e62 Cleanup node_modules on cloudron 2014-07-31 18:02:16 -07:00
Johannes Zellner a9b2020270 Ensure npm install succeeds 2014-07-31 17:48:30 -07:00
Johannes Zellner d50d464b48 Use supererror 2014-07-31 12:39:33 -07:00
Johannes Zellner caccc3eaf5 explicitly use bash to execute the certificate script 2014-07-31 12:35:24 -07:00
Johannes Zellner 33a9721cdf Fixup the certificate generation 2014-07-31 12:33:14 -07:00
Girish Ramakrishnan 61caf680f2 Provide app's fqdn instead of url
This is because url requires home_url which in turn requires the
manifest downloaded.

Fixes #45
2014-07-31 12:09:48 -07:00
Girish Ramakrishnan 98c6408e0d More changes to README 2014-07-31 11:47:54 -07:00
Girish Ramakrishnan 8991a12135 Add settingsdb.set callback 2014-07-31 11:40:09 -07:00
Girish Ramakrishnan f1c78dfcb8 Fix supervisorctl path in reloadnginx.sh on Mac 2014-07-31 11:23:30 -07:00
Girish Ramakrishnan e74061aea7 Update README 2014-07-31 11:23:30 -07:00
Johannes Zellner be384a6f03 Generate self signed certs based on hostname during bootstrap 2014-07-31 11:15:01 -07:00
Johannes Zellner e06227c52d Temporarily disable certificate retrieval from appstore 2014-07-31 10:09:15 -07:00
Johannes Zellner 696f95e0d7 move most settings from yellowtent.conf to the settingsdb 2014-07-31 09:31:28 -07:00
Johannes Zellner 3919bce140 Ignore known hosts warnings for creating base images 2014-07-31 09:31:03 -07:00
Johannes Zellner f92ca8bb03 Move bootstrap script to box
Instead of executing the bootstrap script via ssh,
we now run it once the box boots the first time.
It will update the repo and run the box code, which
needs to contact the appstore in order to get provisioned.
2014-07-31 08:16:35 -07:00
Johannes Zellner 4ef5296cb8 Add initial provisioning route
This will replace the ssh provisioning
and simply sets token, appstore details, and fqdn
It will succeed only once.
2014-07-31 08:13:15 -07:00
Girish Ramakrishnan 297cc122b3 Show naked domain app list as a combo box
Refs #40
2014-07-31 03:04:30 -07:00
Girish Ramakrishnan 5bf88117ae Remove naked domain config on app uninstall
Refs #40
2014-07-31 03:04:08 -07:00
Girish Ramakrishnan dcac24fae5 Parse/Stringify manifest in db code
We store the manifest itself as a string in the database. Everywhere
else in code, it is just a js object.
2014-07-30 23:06:59 -07:00
Girish Ramakrishnan 033dade88b Refresh app status periodically 2014-07-30 22:09:58 -07:00
Girish Ramakrishnan 3f2b45279b Redirect to myapps on app install 2014-07-30 21:57:51 -07:00
Girish Ramakrishnan 1170b0f95f Domain argument is not required 2014-07-30 21:04:03 -07:00
Johannes Zellner dce7a49eb7 Only add user to docker group after installing docker 2014-07-30 17:26:52 -07:00
Girish Ramakrishnan e38a544ef7 Use hyphen based subdomains for apps
Instead of
    appname.username.cloudron.us
we now use
    appname-username.cloudron.us

This allows us to get a wildcard certificate for cloudron.us and the
ssl stuff will work.

The motivation for appname-username instead of username-appname is primarily
UI at this point. We can show a suffix easily on the right side of a line edit.

Fixes #49
2014-07-30 13:52:47 -07:00
Girish Ramakrishnan 5c47eb2d7c Validate app subdomain 2014-07-30 10:10:24 -07:00
Johannes Zellner afda56bea5 Send heartbeat for now only every hour 2014-07-10 22:52:12 -07:00
Johannes Zellner 3dcd938951 Disable nginx init scripts
nginx is handled via supervisor
2014-07-10 22:51:36 -07:00
Johannes Zellner b84f81feb4 Also escape the eval backticks 2014-07-09 13:26:16 -07:00
Johannes Zellner 9aefeaa9fc Escape the shell variables for the init script 2014-07-09 13:13:16 -07:00
Johannes Zellner 45dec6e9df Add convenience script to produce a base image 2014-07-09 11:12:20 -07:00
Johannes Zellner 3437474837 Make the announce init script retry until it succeeds 2014-07-09 10:59:05 -07:00
Johannes Zellner 933d3381b6 Actually send the hostname of the newly created droplet 2014-07-07 10:26:26 -07:00
Johannes Zellner acb6bf12ca Fix typo in base image creation script 2014-07-07 08:10:56 -07:00
Johannes Zellner 171c8c2453 Echo all commands during base image creation 2014-07-07 08:09:22 -07:00
Johannes Zellner 9090a91c14 Enable the init script for bootstrapping 2014-07-03 17:45:49 -07:00
Johannes Zellner ae1f708213 Set default FQDN to os.hostname() 2014-07-03 16:15:49 -07:00
Johannes Zellner 5a6c09b899 Create a base image creation script
As this script is part of the box repo, it is actually
not intended to be run from here, but we need to store it
somewhere for now. The idea is to copy it to a pristine
ubuntu droplet, run it and then create a new base image for
cloudrons off of that droplet.
2014-07-03 16:10:41 -07:00
Girish Ramakrishnan 19b5342af9 Update gitignore 2014-07-02 11:38:48 -07:00
Girish Ramakrishnan daf9d17274 Better debug messages 2014-07-02 11:37:19 -07:00
Girish Ramakrishnan 0ff31a6b2c Refactor uninstall into async.series
async really needs a 'on error continue anyway'.

https://github.com/caolan/async/issues/549
2014-07-02 09:47:11 -07:00
Girish Ramakrishnan 1a8322753b Skip subdomain unregister for dev 2014-07-01 22:14:32 -07:00
Girish Ramakrishnan 3b484dbe51 Reload nginx for config changes instead of restarting
Restarting nginx means that existing connections get dropped. Supervisor
does not support sending arbitrary signals to processes, so we have to
do this the hard way.

Since nginx runs as root, we need a helper sudoers script.

http://stackoverflow.com/questions/13632399/sending-general-signal-to-child-process-of-supervisord
https://www.ruby-forum.com/topic/917257
https://github.com/Supervisor/supervisor/issues/53
https://github.com/Supervisor/supervisor/issues/179
2014-07-01 21:45:36 -07:00
Girish Ramakrishnan 8370356f5d Do not start app if installation failed 2014-07-01 21:45:36 -07:00
Girish Ramakrishnan 3aebd93376 Set NODE_TLS_REJECT_UNAUTHORIZED only for apptask process
apptask module is currently used for setting up naked domain as well
by the main server code.
2014-07-01 20:31:50 -07:00
Girish Ramakrishnan 4e9195c457 better error message 2014-07-01 20:30:26 -07:00
Girish Ramakrishnan 3458f0f068 Use fqdn instead of hostname to generate nginx configs
This change makes it clear that we are really after the fqdn and not the hostname.
The code has been working only because Digital Ocean sets the hostname
to be the FQDN.

What I learnt about hostnames
-----------------------------
The kernel has get/sethostname() and get/setdomainname() system calls.
There is restriction on what can be set as the hostname. init scripts
usually set the contents of /etc/hostname. How hostname is setup depends
on the distribution - it could be the simple name OR the fqdn. CentOS
for example puts the FQDN and ubuntu puts the simple name.

DigitalOcean puts the name of the box in /etc/hostname. So far this has
worked in our favor because os.hostname() which uses gethostname() gave
us the FQDN.

Docker sets only the simple name in /etc/hostname but sets up the
OS host/domain name correctly. This mean os.hostname() does not provide
the FQDN in docker. Altering it is not possible because it requires the
the SYS_ADMIN caps which container don't have (unless --priveliged).

Also, hostname -f first does gethostname(), then does a DNS lookup
using getaddrinfo() or the deprecated getaddressbyname(). Using that IP,
it does a reverse lookup.

The DNS system itself using nsswitch.conf to determine look up order.
The first entry in /etc/hosts file is taken as the domain entry for
reverse lookups.
2014-07-01 20:07:46 -07:00
Johannes Zellner ca262a77de Login user automatically when he creates an admin 2014-06-29 23:20:01 -07:00
Girish Ramakrishnan 21a47ac825 Skip subdomain registration during dev 2014-06-29 18:04:40 -07:00
Johannes Zellner 5ba4f098bb Fixup url in appstatus.html to point to admin 2014-06-29 15:57:08 -07:00
Johannes Zellner 879376d112 Only allow Bearer login for domain and apps routes 2014-06-29 15:21:26 -07:00
Johannes Zellner 6b65bbe969 Do not include bootstrap angular components in appstatus.html 2014-06-29 15:06:47 -07:00
Johannes Zellner e6e6c631b4 Make sure we server appstatus.html correctly when apps are installing 2014-06-29 13:25:02 -07:00
Johannes Zellner 9497417d72 Show myapps as a default route 2014-06-29 12:18:23 -07:00
Johannes Zellner 1729ed5b9c Only allow bearer tokens for /api/v1/user/token
This avoids that the browser is showing a Basic login
dialog if Bearer token is invalid
2014-06-29 12:17:04 -07:00
Johannes Zellner 19980747df Add bootstrap to appstatus.html 2014-06-29 11:26:01 -07:00
Johannes Zellner eea0dcc3f0 Cleanup settings view 2014-06-29 11:21:00 -07:00
Johannes Zellner 84c659a58a Hide User and Volume management 2014-06-29 11:16:11 -07:00
Johannes Zellner 0bc170a27c Remove unused login view and controller 2014-06-29 11:14:07 -07:00
Johannes Zellner 78b1afb45a Use login_callback for oauth login 2014-06-29 11:12:24 -07:00
Girish Ramakrishnan 333fe0e1b8 webadmin: Add Client.getApps and Client.removeApp 2014-06-28 23:30:34 -07:00
Girish Ramakrishnan 1b949ef83f Mark naked domain as not-required 2014-06-28 22:08:09 -07:00
Girish Ramakrishnan fbdbe644f5 naked domains can be setup only for apps 2014-06-28 22:08:09 -07:00
Girish Ramakrishnan 3a2c108232 res might be null 2014-06-28 22:08:09 -07:00
Girish Ramakrishnan b74725aabc Add missing semicolon 2014-06-28 22:08:08 -07:00
Girish Ramakrishnan b50c70e9bb Add settings API
We will use this to store key/value pairs
2014-06-28 22:08:08 -07:00
Johannes Zellner ff1d8b7d0f Do not set URL when login succeeded 2014-06-28 20:17:41 -07:00
Johannes Zellner 18146c1a73 Actually make the logout 2014-06-28 19:33:20 -07:00
Johannes Zellner 8599578f6d Do not show uninitialized messages 2014-06-28 19:10:24 -07:00
Johannes Zellner bf126b8e9a Move from popup to redirecturi for webadmin oauth 2014-06-28 19:04:29 -07:00
Girish Ramakrishnan c14b050b33 Add settingsdb
We will use this to store key/value pairs
2014-06-28 18:48:31 -07:00
Johannes Zellner fc10a20aa9 More rename of origin to adminOrigin 2014-06-28 18:08:54 -07:00
Girish Ramakrishnan e6a772e35b create naked_domain.conf in run.sh 2014-06-28 18:03:41 -07:00
Girish Ramakrishnan 9a90151f2a Rename origin to adminOrigin 2014-06-28 17:58:40 -07:00
Girish Ramakrishnan b1c9f8cfd4 Move admin to admin.subdomain.com
By default, we have the naked domain point to admin. This is a redirect
because the auth code always redirects to admin.*. For apps, we won't
do a redirect.
2014-06-28 17:20:59 -07:00
Girish Ramakrishnan 89724bceb6 Include certificates.conf to get the correct deployed cert 2014-06-28 15:27:56 -07:00
Girish Ramakrishnan ad20de5582 Move nginx template into nginx dir 2014-06-28 15:26:50 -07:00
Girish Ramakrishnan 603cf7db21 Use ejs template for nginx application config 2014-06-28 13:28:00 -07:00
Girish Ramakrishnan e74bfd9e41 Create task for every app that has not been installed 2014-06-28 13:09:02 -07:00
Girish Ramakrishnan e74bfbad8e cleanup nginx config 2014-06-28 13:09:02 -07:00
Johannes Zellner 7e4840db4b Update to new husky version 2014-06-28 11:36:02 -07:00
Johannes Zellner 6355eb79a4 Pass token for heartbeat in query 2014-06-28 10:38:04 -07:00
Girish Ramakrishnan f227b3c271 Fix appstatus.html 2014-06-28 10:05:17 -07:00
Girish Ramakrishnan c1742ad6d2 Simplify apptask state management
The state machine was written to handle restarts. This behavior
while awesome is unnecesary and complicates code. Simplify by
just using an async.series()
2014-06-28 10:04:28 -07:00
Girish Ramakrishnan 8f27c01cf4 Implement runtime state
This separation makes it possible for apphealthtask to go in parallel
and not worry about it the app being uninstalled.

Fixes #27
2014-06-28 02:32:41 -07:00
Girish Ramakrishnan 434693976f process -> install 2014-06-28 01:40:25 -07:00
Girish Ramakrishnan 0dd57d0565 Rename STATUS_* to ISTATE_* 2014-06-28 01:17:30 -07:00
Girish Ramakrishnan b5625534ef Rename statusCode to installationState 2014-06-28 01:11:30 -07:00
Girish Ramakrishnan fd47077987 Remove statusMessage from schema
There's no need to save the status message in the database. Only
need to print it out in the logs.
2014-06-28 01:02:37 -07:00
Girish Ramakrishnan dcd6dfa711 Set error states 2014-06-28 00:31:11 -07:00
Girish Ramakrishnan 5a2bb95f74 rmdirapp -> rmappdir 2014-06-27 23:40:26 -07:00
Girish Ramakrishnan d5baa13828 FATAL_CALLBACK does not exist anymore 2014-06-27 23:32:26 -07:00
Johannes Zellner 605c9015cc Make subdomain unregistration non fatal 2014-06-27 21:06:58 -07:00
Girish Ramakrishnan 4a3f08ede3 Move to uninstalled state only if uninstall succeeds 2014-06-27 12:06:19 -07:00
Girish Ramakrishnan 767047e2a2 Fix apptask state management
Fixes #22
2014-06-26 22:11:52 -07:00
Girish Ramakrishnan 8ef012e6fe Monitor exited apps and restart them correctly
If an app had exited, we only attempt to start the container. Since
the volume should already exist from a previous run.

Not sure if the healthtask should trigger a restart of the app or
similar automatically. Currently, this is only done for server restart.
2014-06-26 18:33:31 -07:00
Girish Ramakrishnan 0ce3727e36 Add missing callback 2014-06-26 18:15:29 -07:00
Girish Ramakrishnan 914c9c8074 Register subdomain immediately after nginx configuration
I don't think it matters if we do subdomain registration first or
nginx first. Nginx first has the mild advantage that we are sure
that nginx is ready to show status page before the dns is done
propagating.
2014-06-26 17:53:16 -07:00
Girish Ramakrishnan bdb12b57a9 Add app status page
Visiting the subdomain when the app is not responding or being installed now
displays the appstatus.html page.

nginx configuration gleaned from various sources:
http://www.cyberciti.biz/faq/custom-nginx-maintenance-page-with-http503/
http://forum.nginx.org/read.php?2,231364,231424
http://mailman.nginx.org/pipermail/nginx/2012-March/032463.html
2014-06-26 17:49:41 -07:00
Johannes Zellner f9a55793a6 Add husky to add git push hooks for running the tests 2014-06-26 16:33:51 -07:00
Girish Ramakrishnan ca20a7777a Set superagent timeout
Note that the timeout is a global timeout for the entire request.
2014-06-26 14:22:04 -07:00
Girish Ramakrishnan 458d0be8be Remove task for tasks when it exits 2014-06-25 20:30:40 -07:00
Girish Ramakrishnan f9f133e97d Unregister subdomain on app delete
Fixes #23
2014-06-25 20:23:17 -07:00
Girish Ramakrishnan a828dde674 Fix typo 2014-06-25 15:57:21 -07:00
Girish Ramakrishnan cb0857091b Fix apptask design
Initially I tried moving the code to a proper task system like que.
However, I could not figure out how to make task cancellation work.
For example, if an app is installing and user cancels it, we want
to kill the installation task. Que does not provide any way to manage
processes. Secondly, there is no way to attach ids to tasks. The id
is autogenerated (incremented number) which means I cannot get at the
task by appid.

Current design: spin out apptask processes for every app's install/uninstall.
An install/uninstall kills any existing apptask process associated with
that task.

apphealth check is a separate process. It is always running and it just
pings all running/dead apps.
2014-06-25 15:56:31 -07:00
Girish Ramakrishnan 1257ad2877 Remove dead code 2014-06-25 08:16:42 -07:00
Girish Ramakrishnan 366a8596aa apps module does not need config anymore 2014-06-24 15:04:41 -07:00
Johannes Zellner daa7262734 Skip user decision dialog until we have OAuth scopes
Since for now we do not have special scoping for
access tokens, presenting a decision dialog to the
user and let him approve makes not much sens.
This commit will skip this step, without interrupting
the normal OAuth flow.
2014-06-24 07:54:07 -07:00
Johannes Zellner 9ed5aac955 Serve up a config object containing appstoreOrigin
This also changes the webadmin to pickup the appstoreOrigin
from the config object to avoid hardcoding
2014-06-23 23:17:43 -07:00
Johannes Zellner a84734302c Remove unused logs view in webadmin 2014-06-23 18:53:30 -07:00
Johannes Zellner 6efffde9e5 Specify ssl certs in separate file 2014-06-23 18:31:04 -07:00
Girish Ramakrishnan 9c658515d0 Keep dependancies alphabetical 2014-06-23 08:36:41 -07:00
Johannes Zellner a64337d0c9 Put childprocess logs into /var/log
The default is /tmp. logrotation will happen
automatically done by supervisor
2014-06-23 08:19:41 -07:00
Johannes Zellner 376fca6d8a Show full box configuration on startup 2014-06-22 12:38:56 -07:00
Girish Ramakrishnan f2990c7fe1 Remove isRefreshPending 2014-06-21 01:47:55 -07:00
Girish Ramakrishnan 40696d9697 apptask: Rename variables 2014-06-21 01:47:55 -07:00
Girish Ramakrishnan 3c8b795e57 Do not update the appdb outside apptask
Updating outside apptask might lead to the statusCode being
overwritten.
2014-06-21 01:47:55 -07:00
Girish Ramakrishnan bfb86e950b Process each app to completion 2014-06-21 01:47:55 -07:00
Girish Ramakrishnan 4e8cdecd1b apptask: Move state handling code to separate function 2014-06-21 01:47:55 -07:00
Johannes Zellner 362d8bea5f Enable full debugging output for now on the cloudrons 2014-06-21 01:20:09 -07:00
Girish Ramakrishnan 47c097cd53 Add database.create
This basically splits out initialize and create database part.
server.js will call create database but not apptask.
2014-06-20 23:24:06 -07:00
Girish Ramakrishnan c55001a86a configRoot is already created by the server code 2014-06-20 22:16:27 -07:00
Girish Ramakrishnan 7e1ebce96c Add note about clearing sudo cache 2014-06-19 22:07:07 -07:00
Girish Ramakrishnan 2a9ef0d927 Make apptask a separate process
Need to fix the db code so that we don't initialize twice. And there
is also some oauth related code in database that should not be there.
2014-06-19 21:50:08 -07:00
Girish Ramakrishnan 48c6c098e3 Move config variables to config.js
This way they can be required by various modules as needed. Instead
of passing them around everywhere like we do now.
2014-06-19 21:03:39 -07:00
Girish Ramakrishnan b3cedab483 Rename config.js to volumeconfig.js 2014-06-19 20:02:00 -07:00
Girish Ramakrishnan aae36c173f Remove optimist dependancy 2014-06-19 19:50:13 -07:00
Girish Ramakrishnan b4651066dc Update README 2014-06-19 16:49:01 -07:00
Girish Ramakrishnan 297354c069 HOME is not preserved by sudo when calling rmappdir
Ubuntu has configured sudo to preserve HOME. This is not the case with
debian or arch. This appears to be a compile time option even.

Explicitly specify that the HOME needs to preserved.

http://unix.stackexchange.com/questions/91384/how-is-sudo-set-to-not-change-home-in-ubuntu-and-how-to-disable-this-behavior
http://unix.stackexchange.com/questions/13240/etc-sudoers-specify-env-keep-for-one-command-only
2014-06-19 14:49:32 -07:00
Girish Ramakrishnan 23404e69c9 Print appdata path instead of home 2014-06-19 14:22:42 -07:00
Girish Ramakrishnan c69934d896 Add --check argument to rmappdir.sh 2014-06-19 14:21:07 -07:00
Girish Ramakrishnan 6f8c7a693b Typo in app health calculation 2014-06-19 13:11:53 -07:00
Girish Ramakrishnan b9d330b62e Output debug message for healthy app
With DEBUG=box:*, we don't get superagent output anymore.
2014-06-19 13:09:13 -07:00
Girish Ramakrishnan 339446dccc Explicitly pass supervisor config path
Otherwise it picks up the system default config
2014-06-19 13:06:25 -07:00
Girish Ramakrishnan ec4c4cdbeb Access box using https://HOSTNAME 2014-06-19 13:02:12 -07:00
Girish Ramakrishnan 4372216a82 Set NODE_ENV to production by default 2014-06-19 12:54:27 -07:00
Girish Ramakrishnan 31b4d40b00 Update README.md to reflect reality 2014-06-19 12:06:11 -07:00
Girish Ramakrishnan 35bd376a2b Use the 'box' namespace for all debug output 2014-06-19 10:18:11 -07:00
Johannes Zellner 8c2bc69cfd Setup box process environment to run as different user
Supervisor does not spawn a shell to run the application,
thus the process environment of supervisord will be inherited.
This can be overridden with 'environmen=...' in the config file
2014-06-18 23:37:07 -07:00
Johannes Zellner 440e42fe98 Run box as user 'yellowtent' 2014-06-18 22:49:41 -07:00
Johannes Zellner bc9e085330 Disable /etc/sudoers.d/yellowtent assert until we have a better solution 2014-06-18 22:25:11 -07:00
Johannes Zellner f3dd285c6c Run box from withing the project root dir
The box root dir (NGINX_ROOT) is provided either via run.sh
or /etc/default/supervisor
2014-06-18 22:11:15 -07:00
Girish Ramakrishnan 1aac4dd48a Add rmappdir.sh script
Host-mounted volumes contain files that are owned by user ids of the container.
However, these values leak through to the host. As a result, one needs to
be the root user to remove the appdata directory.

Initially, a setuid shell script was planned. However, most unixes don't
allos setuid on shell scripts.

We use sudo instead. A special suderos file needs to exist. For example,

In /etc/sudoers.d/rmappdir.sh, add

USERNAME host = (root) NOPASSWD: BOXDIR/src/rmappdir.sh
2014-06-18 00:22:59 -07:00
Girish Ramakrishnan c62a9d9d74 appstore is now https based 2014-06-17 15:59:26 -07:00
Girish Ramakrishnan fad0d5d74e Make the title clickable
For some reason making ng-href an expression doesn't work.
    ng-href="https://{{ app.location + '.' + window.location.host }}"

window.location.host is always empty :(
2014-06-14 21:30:09 -07:00
Girish Ramakrishnan 3a4a43f16d Use hostname instead of localhost as default origin 2014-06-14 21:03:25 -07:00
Girish Ramakrishnan 59f507da04 Enable TLS for apps
The main nginx conf automatically redirects all http to https. This
means that apps need to be doing TLS on their vhost configs as well.

Currently, they all share the same cert and key. This works only because
the cert and key are wildcard certficates.
2014-06-14 21:03:05 -07:00
Girish Ramakrishnan 6180c24e43 Add wildcard self-signed certficate
openssl genrsa 2048 > host.key
openssl req -new -x509 -nodes -sha1 -days 3650 -key host.key > host.cert
openssl x509 -noout -fingerprint -text < host.cert > host.info
cat host.cert host.key > host.pem
2014-06-11 10:54:11 -07:00
Girish Ramakrishnan 8da4b2e5a2 Implement subdomain registration for apps 2014-06-11 10:47:49 -07:00
Girish Ramakrishnan 8c71c038b1 Revert 676a1adff1
Leave it to the app to copy it's data into /app/data as needed.
There are many advantages to this approach:
1. The app won't rely needlessly on some initial data in /app/data.
This means we can clear the data dir should the user ask to and the
app will work as expected.

2. box code will now just work on the Mac :)
2014-06-10 23:47:31 -07:00
Girish Ramakrishnan f625e6e537 docker port has changed in 1.0 2014-06-09 14:11:17 -07:00
Girish Ramakrishnan 0f2628e338 data.config -> data.Config 2014-06-08 10:33:35 -07:00
Girish Ramakrishnan b34dbc18c9 Add a note that appdata delete doesn't work
docker has no concept of user namespace yet. This means that
whatever files are created by the container is seen on the host
appdata as a file by that user. If root is running in the container,
then the volume has files owned by root. This means that our app
code cannot delete the directoy anymore.

Note that some versions of docker even change the permissions of
the app's volume on host to root.root. This behavior apparently changes
depending on whether the volume is empty (!)

I tried playing around with setfacl/getfacl but that doesn't help
because the container can remove any ACL we set.

I see two options:
  - a setuid script
  - a sudo NOPASSWD script

Links to various issues:
https://github.com/dotcloud/docker/issues/2969
https://github.com/dotcloud/docker/issues/2360
https://github.com/dotcloud/docker/issues/2372
https://github.com/dotcloud/docker/issues/3124
https://github.com/dotcloud/docker/issues/2975
https://github.com/dotcloud/docker/issues/5189
https://github.com/dotcloud/docker/issues/1737
2014-06-06 22:58:09 -07:00
Girish Ramakrishnan ec71381ef1 Remove nginx configuration on uninstall 2014-06-06 16:38:46 -07:00
Girish Ramakrishnan e18d642789 Better logs 2014-06-06 16:24:05 -07:00
Girish Ramakrishnan 676a1adff1 Setup app data volume with /app/data of container
It turns out that mounting a host path in /app/data will shadow
the contents of the container /app/data. I expected docker to
copy all files from /app/data of container into the volume.
Since docker doesn't do this for us, we have to copy over the
contents ourselves before we start the container.

https://github.com/dotcloud/docker/issues/1992

Without this change, every app that has any 'initial' config
will have to basically write a setup script which has to run
on startup.

This changes is a little untested because volume mounting cannot
be tested on the Mac through boot2docker.

Notes:
1. The VOLUME cmd in Dockerfile merely exposes the directory to
be available for other container to mount as volumes (i.e they
will be available for --volumes-from)
2014-06-06 13:46:05 -07:00
Girish Ramakrishnan 5cf8cea60b Store app data under appDataRoot
Initially there was a plan to integrate this with the volume code but
that is a little complicated. The apptask runs in spirit as a separate
process. This means that we need to figure a way to send it the username
and password to create volumes. A work around might be to create the volumes
in the routes code instead. However, the uninstall still needs to happen
in apptask code which makes it asymmetric.

Lastly, we need to ensure that app id does not clash with user volumes.
2014-06-06 01:23:23 -07:00
Girish Ramakrishnan d9ab4ce4ef volume: rename config to options 2014-06-06 00:39:34 -07:00
Girish Ramakrishnan d0cf60ed28 Register all existing apps with the health tracker 2014-06-06 00:28:15 -07:00
Girish Ramakrishnan 0e8be87eb3 Implement multiple port bindings
moves port bindings to separate table
2014-06-06 00:12:50 -07:00
Girish Ramakrishnan 2d11fb9513 Implement a basic database connection pool
sqlite3 module that we use does not explicitly support transactions.
The only model that works for transactions is to create a separate
database connection using sqlite3_open().

https://github.com/mapbox/node-sqlite3/issues/304
http://www.sqlite.org/isolation.html
2014-06-06 00:12:50 -07:00
Johannes Zellner 1e6956fa17 Do not hardcode origin in webadmin 2014-06-05 21:45:07 -07:00
Johannes Zellner 61e4759e82 Ensure we add the origin as the callback url for webadmin oauth 2014-06-05 20:20:36 -07:00
Johannes Zellner eda0e34505 Send basic heartbeat to appstore server
Heartbeat is scheduled every 10sec for now.
It only is scheduled if appServerUrl and token is set.
2014-06-05 18:21:42 -07:00
Girish Ramakrishnan 2008b5a8a4 For Mac, forward tcp ports from host to vbox as well 2014-06-05 15:19:26 -07:00
Girish Ramakrishnan f32638c36c Display container id in debug 2014-06-05 14:24:44 -07:00
Girish Ramakrishnan 0f11373118 app: env variables are part of container config
I don't completely grok the difference between container config
and host config.
2014-06-05 13:02:07 -07:00
Girish Ramakrishnan 27cb1bd139 manifest.tcp_ports is optional 2014-06-05 12:28:43 -07:00
Girish Ramakrishnan de3bea03e7 Implement port bindings
Currently, only one the first port is mapped (mostly because of db
setup issues).
2014-06-05 12:28:39 -07:00
Girish Ramakrishnan 2e8a1a3643 webadmin: $http is unused 2014-06-04 15:48:57 -07:00
Girish Ramakrishnan 64a607c9b9 weadmin: Remove spurious log statements 2014-06-04 15:18:36 -07:00
Girish Ramakrishnan 5208047c75 webadmin: Cache applist 2014-06-04 15:09:01 -07:00
Girish Ramakrishnan b500b6b23f webadmin: Create AppStore service 2014-06-04 14:59:09 -07:00
Girish Ramakrishnan bb37705bf8 Capitalize service names
Following johannes' existing naming convention:

module names are camel case
factories and service names are capitalized
2014-06-04 14:44:50 -07:00
Girish Ramakrishnan 5d459b5b44 Define factories and services in YellowTent module 2014-06-04 14:33:29 -07:00
Girish Ramakrishnan 82e9bf79b6 Clean up js directory
Create a directory called views that conatins the controller and
the partials together. These two are tightly tied together anyway.

Can't see any point of grouping things based on programming
patterns (it might make sense to group things based on function
as our code becomes bigger)
2014-06-04 14:21:49 -07:00
Girish Ramakrishnan 6b2aafa699 Pass nginx path using env variable
%(ENV_xxx)s is the magic incantation for supervisor config files.
Sadly this works only on specific fields.
2014-06-04 14:01:07 -07:00
Johannes Zellner f67e235b06 Use supervisor for the box application 2014-06-04 10:27:02 -07:00
Girish Ramakrishnan e222fba2ee Check for Cmd as well along with Entrypoint
ENTRYPOINT is sh -c by default. CMD is the command to be run and
is passed as args to the ENTRYPOINT.
2014-06-03 23:47:39 -07:00
Girish Ramakrishnan 41bc074793 Run nginx through supervisor
One of the motivations for this is to allow the node code to restart
nginx once the nginx config files have been written out. Without
supervisor, the app code needs to be root. With supervisor, we can
just ask supervisor to restart it for us (which helpfully listens
for commands in a tcp port 9001).

The supervisor configs are crude and need to somehow use environment
variables for log file paths and such. %(ENV)s format is supposed to
work but doesn't.

supervisor is not a daemon because it's easy to start/stop it through
run.sh (and Ctrl+C) works nicely during development. We can possibly
run it as a daemon once supervisor configs are more stable.

nginx is not a daemon anymore because it is run through supervisor.

supervisorctl seems to magically connect to supervisor even without
passing it -c <conf> file. Not sure how that works.
2014-06-03 22:23:30 -07:00
Girish Ramakrishnan 9b78afb67c Split config into proper database fields
This is requird to be able to query the list of (used) locations
and ports.
2014-06-03 19:07:49 -07:00
Girish Ramakrishnan c335e05ddd On Mac, add a vbox rule to forward from host to the vbox 2014-06-03 19:07:45 -07:00
Girish Ramakrishnan d13828ce23 Make NOOP_CALLBACK print any error using console.error 2014-06-03 16:07:51 -07:00
Girish Ramakrishnan e9ba2aebef Use json instead of yaml for manifest format 2014-06-02 18:23:27 -07:00
Johannes Zellner 0add24f59e Use provisioned yellowtent.json if it exists 2014-06-02 17:37:40 -07:00
Girish Ramakrishnan 6c501af9d1 Get free port by creating transient server 2014-05-31 16:13:43 -07:00
Girish Ramakrishnan 522e4f862f Generate nginx configs with hostname 2014-05-31 15:06:32 -07:00
Girish Ramakrishnan a566cb28b3 Implement nginx configuration
nginx is configured as the very first step so that we can serve
out a page showing the current app installation status if required.
2014-05-31 14:30:39 -07:00
Girish Ramakrishnan 3cbfe49777 s/config/CONFIG 2014-05-31 13:10:36 -07:00
Girish Ramakrishnan d91751c548 apps: move to running state when health check succeeds 2014-05-29 18:11:36 -07:00
Girish Ramakrishnan 6cfb99d251 apps: Implement health check and uninstall
doesn't completely work yet
2014-05-29 17:31:18 -07:00
Girish Ramakrishnan e87bb4debd Initialize config.appServerUrl to invalid url
This prevents the asserts in apptask code and makes tests
pass.
2014-05-29 10:27:55 -07:00
Girish Ramakrishnan 0f40dadf4d Fix database tests
The apps db schema changed
2014-05-29 08:52:07 -07:00
Girish Ramakrishnan c034606d2c Start implementing app lifecycle
apptask is separate because it is could potentially be run in a separate
process.
2014-05-28 20:12:44 -07:00
Johannes Zellner 3c3dd2e1a8 Add a deployed specific version of server.routes 2014-05-28 17:19:14 -07:00
Johannes Zellner f432bcd29c supervisord.conf is now yellowtent.conf 2014-05-28 16:29:14 -07:00
Girish Ramakrishnan c86822589c Use this.changes and this.lastID to determine insert/update/del errors
The sqlite3 modules sets these variables in the callback function
2014-05-28 09:42:46 -07:00
Johannes Zellner 4c261c8dd9 Enable supervisorctl and run nginx as daemon 2014-05-27 08:11:48 -07:00
Johannes Zellner 5493804b73 For ease of deployment rename nginx.conf 2014-05-26 22:17:38 -07:00
Johannes Zellner dc7084ad7d Update supervisord.conf to reflect box folder structure 2014-05-26 22:15:51 -07:00
Girish Ramakrishnan 43d1e2f2b8 Update safetydance to 0.0.11 2014-05-23 13:49:04 -07:00
Girish Ramakrishnan aa396656d7 Fix jshint errors 2014-05-23 13:08:40 -07:00
Johannes Zellner 5836685ccd Add and disable more tests for appdb
Have to exit train, no time to fix the UPDATE
tests.
2014-05-22 18:00:34 -07:00
Johannes Zellner a80c30aca7 Add unit tests for appdb and fix issues 2014-05-22 17:53:17 -07:00
Johannes Zellner 6764a0255b Add tokendb unit tests 2014-05-22 17:40:46 -07:00
Johannes Zellner 3ae0250dfe Improve authcode unit tests 2014-05-22 17:27:13 -07:00
Johannes Zellner e1102b430c Add initial authcodedb unit tests 2014-05-22 08:44:24 -07:00
Johannes Zellner 3bd12d0f92 Fixup some linter issues in database.js 2014-05-22 08:22:40 -07:00
Girish Ramakrishnan d6e314ebf7 Display message when no apps are present 2014-05-21 22:06:33 -07:00
Girish Ramakrishnan 06aecf6217 Remove ng-controller from partials
Controllers were getting loaded twice - once from ng-controller tag
and again from ng-route configuration.
2014-05-21 21:58:38 -07:00
Girish Ramakrishnan 28ed75d3e0 Show loading status for apps 2014-05-21 18:47:32 -07:00
Girish Ramakrishnan f4610e0e6f Move oauth2views into src 2014-05-21 18:10:28 -07:00
Johannes Zellner 16e1106198 Fix small typo in SQL statement 2014-05-21 17:57:41 -07:00
Girish Ramakrishnan 9f02ab0f79 Store keys as hex-encoded strings
One option is store salt, public and private keys are binary BLOBs.
However, these can be cumbersome to see in database viewers and is
a pain should we ever consider switching databases. String is the
most portable.

So, save all buffers are hex-encoded strings in database.
2014-05-21 16:27:29 -07:00
Girish Ramakrishnan fc48e23553 Explicitly specify the modules size and exponent 2014-05-21 16:27:29 -07:00
Girish Ramakrishnan 20a416b961 sqlite3: move userdb to sqlite3
THis completes sqlite3 migration
2014-05-20 20:48:15 -07:00
Johannes Zellner c2903cd7b4 Merge branch 'johannes' 2014-05-20 16:37:09 -07:00
Johannes Zellner 262e4e4258 Update shrinkwrap file 2014-05-20 15:10:00 -07:00
Girish Ramakrishnan e3410ff4a2 Use database.removePrivates
DatabaseTable will go away
2014-05-20 11:52:25 -07:00
Girish Ramakrishnan 87a0e85975 Remove identity code
This is just dead code and has been moved to the appstore code
2014-05-20 09:04:40 -07:00
Girish Ramakrishnan 49f25b35c9 Add removePrivates to database.js 2014-05-20 09:04:36 -07:00
Girish Ramakrishnan ea1d36512e Allow multiple admins 2014-05-19 16:31:22 -07:00
Girish Ramakrishnan 8c09157d3d s/USERNAME/ADMIN 2014-05-19 15:58:56 -07:00
Girish Ramakrishnan 298c194feb Remove unused config option from User.create 2014-05-19 14:28:21 -07:00
Girish Ramakrishnan 2767faf43b db: mark private fields with _ prefix
This follows the javascript coding convention
2014-05-19 10:13:04 -07:00
Girish Ramakrishnan 8f323c7cd0 sqlite3: move appdb to sqlite 2014-05-19 08:18:33 -07:00
Johannes Zellner 893e727e5d Use supervisor instead of systemd or upstart 2014-05-19 08:08:50 -07:00
Girish Ramakrishnan f4dab61a8f sqlite3: migrate authcodedb and clientdb 2014-05-18 19:12:18 -07:00
Girish Ramakrishnan 821240632d sqlite3: start moving database stuff to sqlite3
tokendb is migrated for the moment

DatabaseError class needs to be fixed to have a nicer API. It's
very error prone to have the reason as the second argument!
2014-05-18 18:24:23 -07:00
Johannes Zellner 3d6ade2088 Make upstart script work with forever 2014-05-18 17:34:30 -07:00
Johannes Zellner 5520b21907 Add initial upstart script 2014-05-18 16:27:18 -07:00
Girish Ramakrishnan 624d0ddb6b Use camel case for database fields
AFAIK, the convention seems to be to follow the language
convention. So, camel case won out in favor of underscores
since we use camel case in our code.
2014-05-18 16:17:28 -07:00
Girish Ramakrishnan 14e95375dd Move db initialization code to database.js 2014-05-17 18:44:12 -07:00
Girish Ramakrishnan 145c24e699 refactor: inline Server._listen 2014-05-17 17:52:37 -07:00
Johannes Zellner 52075d7ec1 Remove 'both' middleware on some routes
The routes which use params handler for volume or
syncerVolume already use the 'both' middleware.
2014-05-17 11:50:47 -07:00
Girish Ramakrishnan 65e7b46581 Code cleanup 2014-05-17 10:16:01 -07:00
Girish Ramakrishnan f33c4da89f Make httpServer property of the server
I don't trust the express team to not use 'cool' js features :) For
all we know, they might just Object.freeze the express() object!
2014-05-17 10:09:42 -07:00
Girish Ramakrishnan 6a53ac36d8 Code cleanup 2014-05-17 09:57:29 -07:00
Girish Ramakrishnan ff8201970d Avoid using express' setting 2014-05-17 09:07:43 -07:00
Girish Ramakrishnan 451b5d28bc express4: fix shrinkwrap file
This completes move to express4
2014-05-16 21:49:56 -07:00
Girish Ramakrishnan 116e86d18b express4: use multiparty middleware for multipart
the middleware parses out multipart data into req.files and req.fields
2014-05-16 21:45:28 -07:00
Girish Ramakrishnan a231f8514b express4: req.params.length is not defined anymore
req.params.length !== 0 ? req.params[0] : '';

Since it was not set anymore, it yielded undefined instead of ''
2014-05-16 21:20:09 -07:00
Girish Ramakrishnan 5bc15a2463 express4: param does not take multiple callbacks anymore
Reading docs of express 3 it appears that it didn't take multiple
callbacks. So we were using a hidden feature.
2014-05-16 21:19:04 -07:00
Girish Ramakrishnan 026c43844a express4: del -> delete 2014-05-16 20:32:50 -07:00
Girish Ramakrishnan 3ea2f55b22 Remove middleware loading code 2014-05-16 20:29:08 -07:00
Girish Ramakrishnan a48505b63d Comment out express.limit for now 2014-05-16 20:22:12 -07:00
Girish Ramakrishnan 1684dad50a express4: json and urlencoded middleware is part of body-parser 2014-05-16 20:21:43 -07:00
Girish Ramakrishnan adb016aeb3 express4: cookieParser is now in cookie-parser 2014-05-16 19:49:59 -07:00
Girish Ramakrishnan d272b047e7 express4: favion is in serve-favicon 2014-05-16 19:47:26 -07:00
Girish Ramakrishnan 03900de8f2 express4: session is now in express-session 2014-05-16 19:45:23 -07:00
Girish Ramakrishnan 2cbd92de6a express4: timeout now resides in connect-timeout 2014-05-16 19:43:59 -07:00
Girish Ramakrishnan 843867a640 express4: logger is gone. use morgan instead 2014-05-16 19:32:20 -07:00
Girish Ramakrishnan 55412be52f express4: app.router has removed
From the docs:
"app.router has been removed and middleware and routes are executed in the
order they are added. Your code should move any calls to app.use that came
after app.use(app.router) after any routes (HTTP verbs)."
2014-05-16 19:27:29 -07:00
Girish Ramakrishnan 511210511f express4: app.configure is no longer available 2014-05-16 19:23:10 -07:00
Girish Ramakrishnan 0e50370378 Update to express 4.2 2014-05-16 19:18:07 -07:00
Johannes Zellner b224e3f8b6 Set nginx user in config
The server currently runs as root, this needs to change.
2014-05-11 11:37:43 -07:00
Johannes Zellner 38c02b8e93 Update shrinkwrap file and restrict module updates 2014-05-08 18:38:39 -07:00
Girish Ramakrishnan 905323a25d Add app configuration page 2014-05-08 18:04:10 -07:00
Girish Ramakrishnan ecad05f048 Remove 'x' bits from files 2014-05-08 16:53:03 -07:00
Girish Ramakrishnan 8e670107b7 apps -> applist 2014-05-08 16:52:29 -07:00
Girish Ramakrishnan 28790999fa Remove 'x' bit from more files 2014-05-08 16:48:57 -07:00
Girish Ramakrishnan 59611d488d Remove 'x' bit from non-executables 2014-05-08 16:47:34 -07:00
Girish Ramakrishnan 1bee1d8ef9 Allow setting the hostname of the app 2014-05-08 14:45:02 -07:00
Girish Ramakrishnan 03174203ec Parse manifest and install docker app 2014-05-08 00:00:28 -07:00
Girish Ramakrishnan 14c47e963d Fix various error because of eaf2ec5a 2014-05-06 15:40:36 -07:00
Girish Ramakrishnan 225035f721 server -> box 2014-05-06 15:15:04 -07:00
Girish Ramakrishnan eaf2ec5a55 Refactor apps code into apps.js 2014-05-06 08:22:43 -07:00
Girish Ramakrishnan 4f69a8b664 app.js -> apps.js 2014-05-05 17:35:12 -07:00
Girish Ramakrishnan b679e9c922 Implement appdb 2014-04-30 23:22:41 -07:00
Girish Ramakrishnan b1da9f68dc pyramid of doom -> async 2014-04-30 22:42:31 -07:00
Girish Ramakrishnan 00655871aa Add app server url to config 2014-04-30 22:03:20 -07:00
Girish Ramakrishnan 098ca9c7fe We require express 3 2014-04-30 20:19:31 -07:00
Girish Ramakrishnan 4fa6aab537 Add route to install an app 2014-04-29 16:58:22 -07:00
Girish Ramakrishnan 1605ae3262 Display app icons 2014-04-29 16:38:59 -07:00
Girish Ramakrishnan 49ac758787 Add config service that provides the appstore url 2014-04-29 16:26:51 -07:00
Girish Ramakrishnan 04a3f88073 Add place holder for App Store tab 2014-04-26 08:36:06 -07:00
Girish Ramakrishnan 7c5725d751 Redirect all http traffic to https 2014-04-25 14:11:03 -07:00
Girish Ramakrishnan ff151e0b00 Specify the port where it the server is started 2014-04-25 14:08:42 -07:00
Johannes Zellner c7a00ea283 Use OAuth login in the webadmin
Currently the webadmin has a fixed built-in
client id, which is added on server startup.
2014-04-16 21:17:16 -07:00
Johannes Zellner 5edae28235 Use postMessage instead of direct object access for OAuth result 2014-04-15 10:20:47 -07:00
Johannes Zellner a7db6023f0 Serve up the OAuth support library from the express app 2014-04-15 08:31:02 -07:00
Johannes Zellner adae88e5b5 Use run.sh only for starting the router
I guess for a real system startup we should rather
manager our processes via systemd only.
2014-04-15 08:17:11 -07:00
Johannes Zellner 616fbca2bd Add signin with Yellowtent button feature 2014-04-14 09:36:34 -07:00
Johannes Zellner 21ed9d6102 Style the OAuth flow sites according to the webadmin style 2014-04-13 21:33:14 -07:00
Johannes Zellner f74f05b9af Make OAuth2 example work
The test page is inside the webadmin for now.
https://localhost/oauth2/
An account needs to be created first.
2014-04-13 20:46:58 -07:00
Johannes Zellner fd4f6fc034 Specify auth strategy for each user related route explicitly 2014-04-11 17:40:09 -07:00
Johannes Zellner 0431a74f6b Add auth middleware explicitly to all routes
Currently most routes still support both bearer and basic.
The public routes (version, firsttime, ..) are now handled
by the app.router
2014-04-11 08:43:16 -07:00
Johannes Zellner beee12925b Replace old handcrafted auth route with passport strategies 2014-04-10 19:00:46 -07:00
Johannes Zellner 3d630dfdfa Use Date.now() instead of (new Date()).getTime() 2014-04-09 18:13:44 -07:00
Johannes Zellner ee9b127762 Remove server test mode
This was used by the file route test and was disabling
the authentication middleware. This is unneccesary, as
the test already passed auth info.
2014-04-09 17:59:05 -07:00
Johannes Zellner 361c42a7a9 Start using passport and some auth route strategies
The auth strategies are still unused so far.
2014-04-09 17:48:32 -07:00
Girish Ramakrishnan 243a022b5d Move server-test into src 2014-04-09 09:15:02 -07:00
Johannes Zellner 35d5c1e53d Fixup linter issues after those merges 2014-04-09 07:48:13 -07:00
Johannes Zellner 8d8cbc16b5 run nginx in the background when using run.sh 2014-04-08 21:57:18 -07:00
Johannes Zellner a0f81a1991 Move auth/ back into src/
This also replaces database.js with distinct
versions of it: userdb.js, tokendb.js and for further
OAuth functions authcodedb.js and clientdb.js
2014-04-08 21:54:28 -07:00
Girish Ramakrishnan aad73ce941 Move middleware to src/ 2014-04-08 19:18:26 -07:00
Girish Ramakrishnan 58625710a8 Make the run script run the app as well 2014-04-08 19:16:52 -07:00
Girish Ramakrishnan 588402548f Move common back to src/ 2014-04-08 19:10:03 -07:00
Girish Ramakrishnan c7e524c153 sync -> src 2014-04-08 19:01:53 -07:00
Girish Ramakrishnan 24aa15812b Remove volumeserver and nginx config 2014-04-08 18:59:45 -07:00
Girish Ramakrishnan a37005d445 Revert the split of volume and syncer code
syncer code is now considered core functionality. There were some
problems with making the syncer code an app.

syncer needs exclusive access to volumes. The volumes have a specific
directory format (repo/) and the syncer cannot know if random
apps write to the volume outside it's REST API. This means that
if syncer were just an app, syncer's volumes cannot be shared
with other apps. This would make simple cases like gallery app
modifying pictures impossible. Additionally, docker was supposed
to be used for mounting all the user's volumes into the app.
However, docker does not have a way to add additional mounts on
running containers (minor issue). It would also require to run
an app instance per user.

The new strategy is to make syncer a filesystem API. All read/write
in the system goes through syncer's REST API. This means that we
need only one app instance for multiple users. Volumes don't need
to be mounted, since the app just uses REST calls.
2014-04-08 18:49:57 -07:00
Girish Ramakrishnan a9af314a62 Volume code does not depend on repo anymore 2014-04-08 15:26:53 -07:00
Johannes Zellner 7cf08d95fb Take public/private key generation and password hashing from old user.js into use 2014-04-08 09:12:50 -07:00
Johannes Zellner 4d5dcc2ae5 Add /users resource methods and tests 2014-04-08 08:40:25 -07:00
Girish Ramakrishnan c0b60b1ef1 sync server does not depend on volume code anymore
The sync server does not call into the volume server at all. It is
assumed that all the volumes that the sync app has access to will
be mounted in the container in the mountRoot.
2014-04-07 22:36:43 -07:00
Girish Ramakrishnan 9ef40b2dcf Rename volume server separately at port 3500
The top level volumeserver file now run the volume server at 3500.
All api calls /api/v1/volume/* are routed to this server by nginx.
2014-04-07 20:16:56 -07:00
Johannes Zellner abef09e6f1 Add some more identity tests and run them on npm test 2014-04-07 08:50:48 -07:00
Johannes Zellner 06b291856f Separate temporary devmode for identity server 2014-04-07 08:45:59 -07:00
Johannes Zellner 380b22c2f4 Add initial identity server test 2014-04-07 08:35:21 -07:00
Girish Ramakrishnan ef16152025 Rename 'api' to 'sync' 2014-04-06 21:35:45 -07:00
Girish Ramakrishnan d755c86084 Move user related code to auth/ 2014-04-06 21:35:37 -07:00
Girish Ramakrishnan 08cdded284 Move volume specific code to volume/ 2014-04-06 21:34:55 -07:00
Johannes Zellner 735e362ec9 Rename auth/ to identity/ 2014-04-06 21:38:20 -07:00
Johannes Zellner a44189d792 Add bearer token grant for normal websites 2014-04-06 21:01:47 -07:00
Johannes Zellner 8d3eabc402 Don't callback twice 2014-04-06 20:29:48 -07:00
Johannes Zellner 1cdf867bb4 Use the json file database for user, token, authCode and client dbs 2014-04-06 20:24:41 -07:00
Johannes Zellner 3d4da8b11b Cater to the route change for the auth server 2014-04-06 20:24:07 -07:00
Johannes Zellner 45c55ed190 Add auth server route to the default router config 2014-04-06 20:23:41 -07:00
Johannes Zellner a7ca7900a3 Consolidate some routes into their corresponding js files 2014-04-06 19:31:23 -07:00
Johannes Zellner 289acc8850 Remove ssl for auth server, handled by nginx 2014-04-06 19:32:21 -07:00
Johannes Zellner 64d45e2285 Merge branch 'oauth'
Conflicts:
	npm-shrinkwrap.json
	package.json
2014-04-06 19:28:41 -07:00
Girish Ramakrishnan 3e5f6a30c9 Generously increase timeout for tests on Mac
After 10.9.2 update, encfs has become a whole lot slower.
2014-04-05 23:27:00 -07:00
Girish Ramakrishnan e815dfe84a Remove upnp-ssdp module since it is unused 2014-04-05 19:50:27 -07:00
Girish Ramakrishnan 6e61fed0c2 webadmin is now served through statically through nginx 2014-04-05 18:48:29 -07:00
Girish Ramakrishnan 72cc084399 Remove http config 2014-04-05 18:45:57 -07:00
Girish Ramakrishnan 417ebb303d Move certs to nginx 2014-04-05 18:43:54 -07:00
Girish Ramakrishnan b7cefd9ff3 Revert "Add https support"
This reverts commit 5d6cd91bee.

Conflicts:
	api/server.js
	server.js
2014-04-05 18:43:21 -07:00
Johannes Zellner fbe7f510f2 Add basic oauth with some test ui in webadmin 2014-04-04 08:40:32 -07:00
Johannes Zellner 6b83066014 Add some authentication means like bearer and basic 2014-04-03 18:01:02 -07:00
Johannes Zellner 51ec3db5ed Make ejs views work 2014-04-03 08:32:51 -07:00
Johannes Zellner 3968f29ce1 Add database wrappers for tokens, codes, users and clients 2014-04-02 21:46:26 -07:00
Johannes Zellner b320a0d614 Initial version for the authserver 2014-04-02 20:46:10 -07:00
Johannes Zellner f2e5cabe81 Remove volume is last user got removed 2014-03-26 23:12:43 -07:00
Johannes Zellner 61cc8d4e54 Add acute.select combobox for user selection 2014-03-26 08:32:37 -07:00
Johannes Zellner dceddc36fa Add cleanup script for developer convenience 2014-03-25 07:51:25 -07:00
Johannes Zellner 8c03302558 Actually remove the user you want to remove
There is still a bug somewhere...have to exit the train now
2014-03-24 18:53:42 -07:00
Johannes Zellner 86424e4d30 Add UI to remove a user from a volume 2014-03-24 18:38:42 -07:00
Johannes Zellner 8587f534a2 Add user add form and user list for each volume 2014-03-23 22:20:56 -07:00
Johannes Zellner 6c73dbe404 List users for volumes when listing volumes
Also includes a unit test for adding users to volumes
2014-03-23 22:07:37 -07:00
Johannes Zellner 0f356585a1 Make tests not interfere wit a currently running yellowtent server
This only changes the ports the test servers will be spawned
2014-03-23 12:01:52 -07:00
Johannes Zellner 2266bbe7c9 If broken out of the layout 0% would get overlayed by the main content 2014-03-23 11:54:01 -07:00
Johannes Zellner fb259a5e7e Make webadmin main menu responsive
fixes #27
2014-03-22 11:36:10 -07:00
Girish Ramakrishnan aea9b81e95 Update required node version to be >= 0.10.0
Otherwise you get issues like
https://github.com/gruntjs/grunt-contrib-imagemin/issues/142
2014-03-22 04:03:31 -07:00
Johannes Zellner b1891833cc Streamline dialogs to not expand too much 2014-03-21 10:41:26 -07:00
Johannes Zellner e09d2e56ae Integrate user and volume creation in the navbar 2014-03-21 09:52:27 -07:00
Johannes Zellner 72be63c971 Make sure side menu is always visible
This however does not work yet in mobile portrait.
2014-03-20 23:15:21 -07:00
Johannes Zellner 830b935d8e Cardify the settings 2014-03-20 18:00:03 -07:00
Johannes Zellner 1f123654a0 Remove theme.css and copy relevant parts into one css file 2014-03-20 17:52:01 -07:00
Johannes Zellner 033f5d3aa0 Get rid of all flexbox related stuff 2014-03-20 17:32:47 -07:00
Johannes Zellner aa71e6d20d Protect against some property access of undefined objects 2014-03-20 17:16:17 -07:00
Johannes Zellner fd1f7e26fe Make background fixed 2014-03-20 17:09:28 -07:00
Johannes Zellner c3b2070f3f Add initial animations on side pane 2014-03-20 16:19:03 -07:00
Johannes Zellner 05b557d0b1 Make links black 2014-03-20 10:34:44 -07:00
Johannes Zellner eb2ce3636f Make volume list show 'cards' per volume 2014-03-20 10:30:18 -07:00
Johannes Zellner 7bc17efd53 Some better bootstrap usage 2014-03-20 08:46:54 -07:00
Johannes Zellner b60edb268a First step away from boring desktop application style 2014-03-20 00:04:40 -07:00
Johannes Zellner 1f4039fa0c Remove the tabview in webadmin 2014-03-19 23:25:22 -07:00
Johannes Zellner 6a4e32591c Fix typo to load Client in password change dialog 2014-03-19 18:55:44 -07:00
Johannes Zellner f917e380d1 Remove unused node module simple-crypt 2014-03-18 08:40:24 -07:00
Johannes Zellner 900eb2105e Implement volume multiuser routes 2014-03-18 08:33:48 -07:00
Girish Ramakrishnan a61c5fa11d Provide size information in response when uploading new file 2014-03-18 15:05:17 +05:30
Girish Ramakrishnan 8b376b921f Set invalid mtime for dirs instead of skipping the property 2014-03-18 14:41:32 +05:30
Johannes Zellner 97e09efd84 Add user get() api 2014-03-17 22:50:39 -07:00
Johannes Zellner e890dedbab Fixup volume rest api test 2014-03-17 22:02:38 -07:00
Johannes Zellner 9718f3a2fe Add users() function to volumes to list the users 2014-03-17 21:58:31 -07:00
Johannes Zellner c146b032fe Add unit test for volume delete API 2014-03-17 19:10:15 -07:00
Johannes Zellner cf8f91c5c5 Adjust webadmin to work with volume IDs 2014-03-17 09:18:41 -07:00
Johannes Zellner ae0441c7e1 Use a proper config file wrapper for volume configs 2014-03-17 09:18:34 -07:00
Johannes Zellner 415f1492ba Add unique volume identifier instead of using name
This adds a new config file to the volume and thus requires
to recreate all existing volumes and possibly clean the servers
configuration
2014-03-17 09:18:26 -07:00
Johannes Zellner 8831a14ec7 Revert "Add unique volume identifier instead of using name"
Pushed too hastly to the wrong branch.

This reverts commit 9514423ab8.
2014-03-17 08:20:34 -07:00
Johannes Zellner d8f05534e8 Revert "Adjust webadmin to work with volume IDs"
Pushed too hastly to the wrong branch.

This reverts commit c2c4818eda.
2014-03-17 08:20:11 -07:00
Johannes Zellner c2c4818eda Adjust webadmin to work with volume IDs 2014-03-17 08:14:11 -07:00
Johannes Zellner 9514423ab8 Add unique volume identifier instead of using name
This adds a new config file to the volume and thus requires
to recreate all existing volumes and possibly clean the servers
configuration
2014-03-14 10:36:48 -07:00
Girish Ramakrishnan 6b83bec13e Make HTTPS the default 2014-03-12 18:48:18 +05:30
Girish Ramakrishnan 60c1a19383 repo: make createDirectory return the dir entry 2014-02-28 12:47:13 -08:00
Girish Ramakrishnan 9a7ede96a0 Add empty dir support
I tried a couple of hacks before the magic file approach.

1. First determine the empty tree
git hash-object -t tree /dev/null gives 4b825dc642
Then,
git update-index --index-info
040000 tree 4b825dc642    path/to/empty-folder

Sadly, git converts the above to a submodule when committing :-(

2. The next idea was to repurpose symlinks to denote empty dir.
While this idea could work, it requires the additional work of removing
the symlink before creating the directory.

The current approach is to use a magic file inside empty dir (like .gitignore).
The magic file is filtered when we read from index and when we read tree from
the object store.
2014-02-27 00:12:00 -08:00
Girish Ramakrishnan 46de76ee4d Increase timeout for some of the volume tests
My Mac needs more than 2seconds :-(
2014-02-23 15:40:32 -08:00
Girish Ramakrishnan 3aee2231b7 Run test server at a different port than default
tests fail because I have my development server running on the
same port
2014-02-23 15:26:10 -08:00
Johannes Zellner 4c7a8f8987 Improve first time flow 2014-02-23 11:06:03 -08:00
Johannes Zellner ee8ee4d01f Remove advancedconnection partials
This is no longer needed, as the website is
delievered via the same server.
2014-02-22 11:59:56 -08:00
Johannes Zellner 624d5653cd Fix issues around user management in webadmin 2014-02-22 11:42:53 -08:00
Johannes Zellner 6c64b045d5 Fix wrong error reporting in volume verification 2014-02-21 23:06:53 -08:00
Johannes Zellner fbac122abc Fix volume creation in webadmin 2014-02-21 22:39:31 -08:00
Johannes Zellner a583f31734 Basic login/logout works again in the webadmin 2014-02-21 21:50:16 -08:00
Johannes Zellner 3f93453101 Add forgotten unit tests for new auth method 2014-02-21 21:49:55 -08:00
Johannes Zellner 29590f22f3 Add new token based authentication
We now support next to Basic auth also Token
auth in the authorization header:
Authorization: Token <token>
2014-02-21 21:41:22 -08:00
Johannes Zellner dea5b1d365 Add autofill polyfill due to missing feature in angular
See: https://github.com/angular/angular.js/issues/1460
2014-02-21 20:25:20 -08:00
Johannes Zellner c14e56151f Add new webadmin
This is merely a copy from the nw-client and
does not yet work in its state atm
2014-02-21 20:04:52 -08:00
Johannes Zellner 1a90b029c2 Remove old webadmin 2014-02-21 20:04:52 -08:00
Girish Ramakrishnan 62c5678ca1 Convert 503 timeout errors to 408
Being optimistic about the quality of our server here :) If a request
timed out, we assume the client is taking too long to complete it's request.

In the future, we can make this more sophisticated, by checking if it's
the server or the client which is taking time.
2014-02-21 13:53:20 -08:00
Girish Ramakrishnan d4a6753c4d Move timeout constants to server.js 2014-02-21 13:53:20 -08:00
Girish Ramakrishnan d32c79afd5 Place all size constants in one place 2014-02-21 13:53:12 -08:00
Girish Ramakrishnan ba96118e53 Make the upload size explicit in server.js
Currently, it's hidden deep inside the route handler and hard to spot
2014-02-21 12:38:47 -08:00
Girish Ramakrishnan 138934f1a5 Ignore nginx pid file 2014-02-21 12:35:05 -08:00
Girish Ramakrishnan c2500cdb82 Set default upload size to unlimited
Default seems to be 1MB or so
2014-02-21 12:32:11 -08:00
Johannes Zellner 74ddb991a6 Add initial nginx configuration
This adds basic configuration for 80 and 443
nginx can be run with:
./run.sh
and requires root access to bind to the ports.

Basic routes are specified in nginx/server.routes
Additional application routes can be put into the
nginx/applications/ subfolder.
2014-02-21 08:38:15 -08:00
Johannes Zellner 42f8f97f2e Take npm shrinkwrap into use
Until npm 1.4.4 please remove your node_modules
subfolder and run npm --production and then npm shrinkwrap.
Or if just adding a new non dev dependency:
npm i foo --save
npm shrinkwrap
2014-02-21 07:47:26 -08:00
Johannes Zellner b6065c73fa check if config.certificateDir is a string, we fail otherwise later 2014-02-17 00:27:56 -08:00
Johannes Zellner 91b0304fee Switch to asymmetric encryption using RSA for volume headers 2014-02-17 00:22:22 -08:00
Girish Ramakrishnan 5d6cd91bee Add https support
To test with our self-signed key:
./server -k test/cert
2014-02-16 18:39:35 -08:00
Girish Ramakrishnan 177eaaa2b5 Ensure filePath is not null 2014-02-16 01:50:29 -08:00
Johannes Zellner e7065c506d Return 401 instead of 400 for wrong login credentials 2014-02-15 11:21:33 -08:00
Johannes Zellner ba1e931947 Add more error response for password change route 2014-02-14 23:47:42 -08:00
Johannes Zellner 5c5e52b12f Return access error for volume mount 2014-02-14 21:36:29 -08:00
Johannes Zellner 3c42052f86 Remove destroyVolume() with volume.destroy() 2014-02-14 21:23:16 -08:00
Johannes Zellner e5d2058065 Abuse the express error handlers for succes handler
For finish a rest route with successs, use:
next(new HttpSuccess(statusCode, object));
2014-02-13 17:56:27 -08:00
Girish Ramakrishnan d7fafc40d8 listVolumes (/api/v1/volumes/list) now returns an object
Returning arrays is considered bad practice. This is because Array
constructor can be overriden and this makes REST api prone to
cross-scripting attacks. For example, someone can put a REST call in
a <script src="someothersite/api/v1/list.js"> tag and the browser
will prompty send cookies. Even though the result is JSON, it's
result can be captured if you overload the array constructor!
2014-02-13 17:30:10 -08:00
Johannes Zellner 24a69b772a Validate new volume password 2014-02-12 22:50:41 -08:00
Johannes Zellner 85af5c7d18 Ensure user create and removal only allowed by admin 2014-02-12 08:38:14 -08:00
Johannes Zellner 6626b1017d Fix the password handling to be able to reset the users password 2014-02-11 09:34:20 -08:00
Johannes Zellner bf43147856 Improve volume management
This adds a load of unit tests around volume user management
and introduces the password changing capabilities. The API is
still a bit ugly but should work now at least.
2014-02-10 19:23:25 -08:00
Johannes Zellner d2874185b2 More argument checking for all functions in volume.js 2014-02-10 08:21:08 -08:00
Johannes Zellner 7e3ad7d490 Send userinfo during token login and add 'admin' flag 2014-02-08 11:11:06 -08:00
Girish Ramakrishnan f3449a8157 Set content-length when getting files
Not setting Content-Length results in chunked encoding and makes
it impossible to show progress indicators on the client.
2014-02-07 23:09:39 -08:00
Girish Ramakrishnan 0f848b96a9 Add documentation for repo._getFileSizes 2014-02-07 22:59:44 -08:00
Johannes Zellner a2a8812371 Make volume.getVolume() async 2014-02-07 09:21:54 -08:00
Johannes Zellner bb515f0f0c Add list user API 2014-02-05 08:08:31 -08:00
Johannes Zellner 5bda071d5b Add option to remove private fields from getAll() 2014-02-05 07:56:31 -08:00
Johannes Zellner e88ce0cadc Add getAll() to database.js 2014-02-03 18:56:57 -08:00
Johannes Zellner a5a26da2f9 Asyncjs added by mistake, we use async 2014-01-28 08:18:55 -08:00
Johannes Zellner eb4bbc2d55 Add isMounted to the list volumes API 2014-01-27 18:17:31 -08:00
Girish Ramakrishnan 6a0f35dbe9 Make _absoluteFilePath more robust 2014-01-26 23:11:27 -08:00
Girish Ramakrishnan b742f1bae8 repo: add lots of docs 2014-01-26 18:35:28 -08:00
Girish Ramakrishnan 2864ac4a92 repo: indexEntries now returns file name 2014-01-26 17:17:37 -08:00
Girish Ramakrishnan 94878bfe82 repo: add doc for what indexEntries returns 2014-01-26 17:11:11 -08:00
Girish Ramakrishnan aff9edc7b9 Add some api docs for repo 2014-01-25 00:36:54 -08:00
Johannes Zellner f3e54e10ab Add more tests to not leak unwanted properties 2014-01-21 00:04:55 -08:00
Girish Ramakrishnan cfb5443816 repo.js: set to_path to . when empty
git mv <from> <to> fails gloriously otherwise
2014-01-19 21:18:56 -08:00
Girish Ramakrishnan 55793d9dcf In javascript, "" evaluates to false
A lesson I have learnt umpteem times but can never remember.
2014-01-19 21:11:25 -08:00
Girish Ramakrishnan 717301ca92 Fix error in error handling code 2014-01-19 18:49:50 -08:00
Girish Ramakrishnan 99306e6209 doc: rev can be set to "*" for move and copy 2014-01-19 18:41:49 -08:00
Girish Ramakrishnan bec3a840e6 fileops: check for path parameter in request 2014-01-19 17:55:58 -08:00
Girish Ramakrishnan edde17299a Fix test to query dir/subdir and not dir 2014-01-18 10:57:49 -08:00
Girish Ramakrishnan e5d9168804 repo: Add listFiles API
listFiles returns the mtime information in the checkout dir.
2014-01-16 12:30:26 -08:00
Girish Ramakrishnan 29208276fb Make tree entries contain the filename
Tree entries now contain the path and name. Commit messages contain
the file name and not the path.
2014-01-16 12:06:36 -08:00
Girish Ramakrishnan bb05224f7e repo.js: Use -rt when listing subtrees 2014-01-15 19:56:41 -08:00
Girish Ramakrishnan cfb31439fd Make volume.listFiles use volume.getTree(). 2014-01-15 19:09:35 -08:00
Johannes Zellner e8b70fdfe3 Add initial systemd service file and some readme 2014-01-14 18:01:39 -08:00
Girish Ramakrishnan 6b1b030f22 Replace polo with upnp-ssdp 2014-01-13 00:56:40 -08:00
Johannes Zellner 579c1b6167 Add explicitly {} to response.send()'s body
This is needed, as we set content type JSON to all responses,
thus we do not want express to add a 'OK' in a res.send(200);
case
2014-01-12 18:40:04 -08:00
Girish Ramakrishnan a434bc44a0 Hot fix for getting webadmin to work again 2014-01-10 12:07:48 -08:00
Johannes Zellner 48f449383f The credentials header always needs to be there for CORS 2014-01-09 18:19:20 -08:00
Girish Ramakrishnan 7083644eb7 Add test for CORS 2014-01-08 23:58:30 -08:00
Girish Ramakrishnan 7df5ee85ce Fix typo when returning new stream 2014-01-08 22:29:38 -08:00
Johannes Zellner 90e1e9e106 return empty readStream 2014-01-08 18:32:06 -08:00
Girish Ramakrishnan 781495e662 Get rid of _ dependancy and use the cors middleware 2014-01-08 18:09:00 -08:00
Girish Ramakrishnan fc8b03a9dc Add CORS middleware 2014-01-08 17:51:50 -08:00
Johannes Zellner 322db20642 Move firsttime route to server.js and complete user documentation 2013-12-01 17:52:51 -08:00
Johannes Zellner 8c82ce82a6 Merge branch 'documentation' 2013-12-01 16:44:30 -08:00
Johannes Zellner cbb80c6b01 Generate random salt for volume headers and check volumes for such header 2013-11-28 21:16:10 -08:00
Johannes Zellner ab2d82e93f Add some more documentation and change the error format a bit 2013-11-18 20:24:41 -08:00
Johannes Zellner da17d14a2c Add infrastructure for REST api documentation 2013-11-18 18:54:34 -08:00
Girish Ramakrishnan d6f2a3ec48 Remove unused requires 2013-11-04 21:54:27 -08:00
Girish Ramakrishnan 8c27178b40 Revert testMode
Using mock objects is a better idea to do syncer testing.
2013-11-01 15:03:14 -07:00
Girish Ramakrishnan 65102425e8 Use null instead of undefined.
The coding style is:
    - Use and test for null for object properties
    - Use 'delete' only for hashes
    - Use 'undefined' only when testing for a key in a hash
2013-11-01 11:25:04 -07:00
Johannes Zellner 158d625cc7 Separate the server code into a main and a server API
the server.js in the api subfolder might not be in the best
place, as its not an API as the others are.
2013-10-31 12:11:05 -07:00
Girish Ramakrishnan b73eb8dabd Instead of X-YT-Authorization header just check for absence of auth. 2013-10-30 12:51:43 -07:00
Girish Ramakrishnan c9164e0865 Add test mode
node server --test.

This will authenticate any request that contains the X-YT-AUTHORIZATION
header.
2013-10-30 05:35:42 -07:00
Girish Ramakrishnan c695af5cd1 Move auth function to top level for readability 2013-10-30 05:13:17 -07:00
Girish Ramakrishnan 5af6ad236f Fix coding style 2013-10-30 04:59:51 -07:00
Johannes Zellner 227645b489 Add more tests around the token and user management 2013-10-29 08:41:54 -07:00
Girish Ramakrishnan 73d61368d1 Remove dead code 2013-10-26 11:21:06 -07:00
Girish Ramakrishnan 1618e42e5d Fix linting errors 2013-10-23 20:56:03 -07:00
Girish Ramakrishnan 20c0ef7d93 Add a TODO in putFile implementation 2013-10-23 09:46:07 -07:00
Girish Ramakrishnan b161a2e68a Removing non-existent file is not an error
We return a 204 now which is possibly incorrect because we set an
entity header content-type as per
http://www.w3.org/Protocols/rfc2616/rfc2616-sec7.html
2013-10-23 04:01:18 -07:00
Girish Ramakrishnan f37ff4c5e6 Have a local copy of aes-helper 2013-10-22 18:30:31 -07:00
Girish Ramakrishnan 0f323b05be Remove superfluous send call 2013-10-22 12:27:36 -07:00
Girish Ramakrishnan 66d798dc61 Return 422 for invalid cursor 2013-10-22 12:20:25 -07:00
Girish Ramakrishnan 3deab4c307 Add content-type middleware
Set all our API responses to be appplication/json.
2013-10-18 23:38:43 -07:00
Girish Ramakrishnan e779d822bb Create scripts dir 2013-10-18 23:26:29 -07:00
Girish Ramakrishnan 3bbe8aa353 Handle Renames and Copies correctly in diff-tree 2013-10-18 15:00:42 -07:00
Girish Ramakrishnan 35db6ab0ed Give descriptive names for positions 2013-10-18 14:31:27 -07:00
Girish Ramakrishnan a4c1cbb86c Fix parsing of index for filenames with newlines 2013-10-18 13:30:03 -07:00
Girish Ramakrishnan 2bf7d64786 Parse commit message correctly for files with trailing spaces 2013-10-18 12:54:11 -07:00
Girish Ramakrishnan c680b2f560 Use verbatim mode for commit messages 2013-10-18 12:48:51 -07:00
Girish Ramakrishnan 5835767d18 Write the message to stdin
-m add \n\n to the commit message in verbatim mode (this is not set
yet, but will be in a future commit).
2013-10-18 12:47:06 -07:00
Girish Ramakrishnan a9352d94a4 Test tabs in filename 2013-10-18 11:22:21 -07:00
Girish Ramakrishnan c166d4b27d database.js: indent the JSON for readabililty 2013-10-18 10:08:28 -07:00
Girish Ramakrishnan 5ed871fdea Fix putFile to handle nullSha1 parent for new files 2013-10-17 22:21:02 -07:00
Girish Ramakrishnan 5d9ccf51b8 Fix db directory creation by database.js 2013-10-17 17:18:09 -07:00
Girish Ramakrishnan c6de2a5668 Make mkdirSync calls via safetydance 2013-10-17 17:02:57 -07:00
Girish Ramakrishnan c884c183c8 Make existsSync calls via safetydance 2013-10-17 12:46:41 -07:00
Girish Ramakrishnan 9400918c3c Use safetydance all over 2013-10-17 12:30:54 -07:00
Girish Ramakrishnan fc5e78384b Use safetydance for exception safety 2013-10-17 12:25:35 -07:00
Girish Ramakrishnan 183b38f645 Test non-ASCII file names 2013-10-17 01:23:57 -07:00
Girish Ramakrishnan 494e52c729 Add tests to check for file with special characters 2013-10-17 01:15:17 -07:00
Girish Ramakrishnan 8e197ce714 Add FIXME in repo.js to convert to Buffer 2013-10-16 23:50:29 -07:00
Girish Ramakrishnan 8aff9f7b9c Remove all usages of trimRight to be consistent with other parts of code 2013-10-16 23:30:25 -07:00
Girish Ramakrishnan 11f5932732 null terminate log output 2013-10-16 23:28:19 -07:00
Girish Ramakrishnan bbe0f2d253 diff-tree and log now uses -z termination 2013-10-16 23:24:25 -07:00
Girish Ramakrishnan 5270735122 refactor parseIndexLines 2013-10-16 22:12:37 -07:00
Girish Ramakrishnan 5da2e7c1c0 Find renames in commits 2013-10-16 22:05:40 -07:00
Girish Ramakrishnan ffdf6cb4f3 ls-files output now uses -z based output 2013-10-16 20:55:11 -07:00
Girish Ramakrishnan 6e364139ee Parse filename as 'rest of line' 2013-10-16 18:59:31 -07:00
Girish Ramakrishnan c5c96aa9eb ls-tree now uses -z
This allows us to work properly with spaces and special characters
in filenames.
2013-10-16 17:31:16 -07:00
Girish Ramakrishnan 1410e50a1e Make sure parser functions are not passed empty strings 2013-10-16 17:14:51 -07:00
Girish Ramakrishnan 6ebe9f1e52 Set the file upload limit to 521mb
My intention was to set it to 512mb but the file I have is 514mb.
So, I chose a prime number above 514.

For some reason, instead of a 413 HTTP Error, the connection gets
reset when uploading large files. Needs investigation.
2013-10-14 23:11:49 -07:00
Girish Ramakrishnan 209270305e Increase upload timeout of file uploads to 3 mins 2013-10-14 22:49:04 -07:00
Girish Ramakrishnan c902373354 Make _absoluteFilePath return null when path is outside repo 2013-10-13 20:53:49 -07:00
Girish Ramakrishnan 9a5e5b8aa3 Standardize on the debug naming convention
Always prefix with server. Provide path to file. Drop file extension.

So,
    server:routes/user

This allows to debug as DEBUG="server:*".
2013-10-12 17:01:21 -07:00
Johannes Zellner 507a5eac1b Graphics assets move to the client 2013-10-12 09:56:21 -07:00
Johannes Zellner f972136fa0 Add some user routes documentation and improve statuscodes 2013-10-08 08:38:58 -07:00
Johannes Zellner afe6a12e80 Use GET not POST 2013-10-07 17:23:23 -07:00
Johannes Zellner be17cbd2d9 Add volume isMounted route 2013-10-07 17:21:24 -07:00
Johannes Zellner 429172e6aa Move requireMountedVolume to volume routes and add two more tests 2013-10-07 00:24:03 -07:00
Johannes Zellner 5dfb2c9b6c Separate file route api tests into its own test file 2013-10-07 00:03:30 -07:00
Johannes Zellner 0d6bf03a40 Separate volume route api tests into its own test file 2013-10-06 23:49:49 -07:00
Johannes Zellner 755edc874a Separate user route api tests into its own test file 2013-10-06 23:36:50 -07:00
Johannes Zellner 58f4bc2a68 Add route step to check if volume is mounted 2013-10-06 11:24:48 -07:00
Johannes Zellner 72a8606cca Add volume.isMounted() to hide away encfs 2013-10-04 08:35:45 -07:00
Johannes Zellner c911153b2f Always handle error event for spawn
In case we cannot execute the process or the cwd
is not existent, the exception would bubble up till
the server crashes.
2013-10-04 08:23:44 -07:00
Girish Ramakrishnan 595b8a5f89 Verify filePath type 2013-10-03 08:27:21 -07:00
Girish Ramakrishnan 79dc24ac5e Compute hash through git instead of multiparty
git hash contains "blob<sp>size\0" prepended to blob data.
2013-10-03 01:12:36 -07:00
Girish Ramakrishnan a74c05807f repo.js: allow putting a file with same contents as the existing one 2013-10-02 23:40:06 -07:00
Girish Ramakrishnan 6aa82c7019 remove unused reference to syncer 2013-10-02 22:47:03 -07:00
Girish Ramakrishnan 1cda149d9d Remove file.update route
putFile and fileops does it's job.
2013-10-02 22:41:28 -07:00
Girish Ramakrishnan 90b6e0d155 Check authorization header before cookie/auth_token.
6503885b21 reversed the order for some unknown reason.
2013-10-01 22:11:57 -07:00
Johannes Zellner 1af3198ef2 Add password verification route for some volume related routes 2013-09-30 21:42:30 -07:00
Johannes Zellner 9002e01b62 Finally fix the repo subfolder in volume
Fixes #2
2013-09-28 21:40:27 -07:00
Girish Ramakrishnan d0fa0131ea Fix linting issues in syncer.js 2013-09-28 21:33:56 -07:00
Girish Ramakrishnan f0758551dd Fix fileops.js linting issues 2013-09-28 21:27:07 -07:00
Girish Ramakrishnan c82fdcced5 Fix linter issues in repo.js 2013-09-28 21:25:03 -07:00
Johannes Zellner 7c14e195eb Do not mix token and auth header extraction 2013-09-28 17:13:17 -07:00
Johannes Zellner 6a8743fd0e Add unmountall.sh to unmount all remaining encfs volumes 2013-09-28 14:01:22 -07:00
Johannes Zellner 242519f52a Do not stringify the object, wrong content type would be set 2013-09-28 01:28:41 -07:00
Johannes Zellner 13e8e7dae0 Init repo in a 'repo' subfolder of the volume
Fixes #2
2013-09-28 00:35:02 -07:00
Johannes Zellner 99eaf65884 Use new polo release and catch any errors from that 2013-09-26 10:18:53 -07:00
Johannes Zellner 6a4885414d Replace the first time handling with an API call
There is now a /v1/firsttime GET call to check in which mode
the device currently is. The convenience redirection to firsttime.html
for the webadmin, which was done for every request is now gone.
2013-09-21 17:18:49 -07:00
Girish Ramakrishnan 5692851d4c Add some API docs 2013-09-19 23:40:28 -07:00
Johannes Zellner 3f88f9bbbf Add some token related test cases 2013-09-19 09:48:41 -07:00
Johannes Zellner 245aa63fc0 Add some user server API tests 2013-09-19 08:42:38 -07:00
Johannes Zellner 538a80e686 Enable the volume already exists test 2013-09-19 08:34:27 -07:00
Johannes Zellner 9f55ca3cea Add some tests for the server 2013-09-19 08:30:17 -07:00
Johannes Zellner 6d2e1141c6 Add a silent option to the server to suppress logging 2013-09-19 08:13:43 -07:00
Johannes Zellner b31fe1371a Let server's start() API take a config object
This object can be used to specify the data folders.
Mainly useful for temporary folders for tests.
2013-09-19 08:00:27 -07:00
Johannes Zellner 53b6a0b871 Also run the toplevel tests 2013-09-18 11:07:54 -07:00
Johannes Zellner 47b59306ab Change server.js to export an API with start/stop
Also add a basic test to verify the server can start and stop.
We still have an issue with api/server/server-test.js to use the
regular ~/.yellowtent/ folders thus test might break if this directory
is used.
2013-09-18 10:58:10 -07:00
Johannes Zellner 763cf46e2e Forgot to callback the server init back 2013-09-18 08:01:11 -07:00
Girish Ramakrishnan 31b1265592 repo.js: Remove usage of exec
This makes sure we can handle files with spaces and funny characters
like brackets without shell-escaping.

Using exec has security implication since a filename could be 'foo && rm -rf /'
2013-09-18 00:44:26 -07:00
Girish Ramakrishnan 9e8177a139 repo.js: remove exec feature of chaining commands
chaining is a shell feature. This is part one of removing
shell usage.
2013-09-18 00:44:26 -07:00
Johannes Zellner a18fe47783 Add server announcement via polo 2013-09-17 10:39:29 -07:00
Johannes Zellner 9821a3e515 Add some additional logging 2013-09-16 08:00:07 -07:00
Girish Ramakrishnan 476c7f8ab7 repo.js: add separate function to add content 2013-09-15 23:22:38 -07:00
Girish Ramakrishnan 56bc1fe9fb s/_op/_operation
Note that the _ signifies that the option is internal and not set
by the user.
2013-09-15 19:56:55 -07:00
Girish Ramakrishnan d3c6ba0345 repo.js: add putFile 2013-09-15 19:52:38 -07:00
Girish Ramakrishnan d4db16c845 refactor: Move code into repo 2013-09-15 19:24:23 -07:00
Girish Ramakrishnan 87f04cd978 Make rev param mandatory for fileops
Specify '*' as rev for don't care.
2013-09-15 19:04:01 -07:00
Johannes Zellner 20aaf3eb01 Increase request size limit for now 2013-09-15 15:18:30 -07:00
Johannes Zellner 2df8dd36af Use volume password header database
This database stores the username and the volume password,
encrypted with the users password.
2013-09-13 23:45:28 -07:00
Girish Ramakrishnan e16b3c91cf repo.js: fileEntry return ENOENT when file not found 2013-09-13 23:07:46 -07:00
Girish Ramakrishnan c3a58b44a4 fix typo 2013-09-13 22:59:59 -07:00
Girish Ramakrishnan dcca98019b Better error handling 2013-09-13 22:35:13 -07:00
Girish Ramakrishnan fa15e13cb1 move metadata to repo 2013-09-13 22:14:56 -07:00
Girish Ramakrishnan 20942f6305 Add more asserts to validate arguments 2013-09-12 22:39:39 -07:00
Girish Ramakrishnan 99664c0323 coding style: Remove options from repo.create
The style is thus:
    - Required arguments are listed as proper arguments
    - Optional arguments are in options
    - Options object is optional and ca be skipped
2013-09-12 22:29:55 -07:00
Girish Ramakrishnan 0e39b7bfbf Sprinkle asserts to validate args 2013-09-12 22:23:53 -07:00
Girish Ramakrishnan 1ab311c6fb s/user/obj 2013-09-12 22:17:23 -07:00
Girish Ramakrishnan 84e1dc32d3 api: implement putFile 2013-09-12 21:03:39 -07:00
Johannes Zellner 2b726e3097 Add better volume error reporting and volume mounting 2013-09-11 10:52:47 -07:00
Johannes Zellner f9c06fedbc Use private property to prevent accidental pushes to npm 2013-09-11 10:52:47 -07:00
Anders Bakken c6b1052173 Add new p2p stuff 2013-09-09 18:28:45 -07:00
Johannes Zellner 07a8dbf1c3 Add initial support for user/password headers for volumes 2013-09-09 09:45:40 -07:00
Johannes Zellner ee8bd13685 Add some more volume related tests 2013-09-08 21:02:36 -07:00
Johannes Zellner 6503885b21 Ask the user for his password to create a volume 2013-09-08 20:24:19 -07:00
Johannes Zellner 51009cae42 make tests cleanup their tmp folders 2013-09-08 14:07:01 -07:00
Johannes Zellner 6326bdd1c3 Minor updates to streamline tests 2013-09-08 13:44:33 -07:00
Johannes Zellner fa6772ea5c Add database.js unit tests 2013-09-08 13:43:47 -07:00
Girish Ramakrishnan 0f7b85f52d repo: implement move and copy 2013-09-08 00:58:14 -07:00
Girish Ramakrishnan e051ded540 make sure paths are outside .git/ 2013-09-08 00:28:39 -07:00
Girish Ramakrishnan c627a1fc07 path.resolve already takes care of path.join 2013-09-07 23:37:17 -07:00
Girish Ramakrishnan 05fe38512d use path.join 2013-09-07 23:37:17 -07:00
Girish Ramakrishnan defaf84532 repo: separate addFileAndCommit from writeFileAndCommit
addFileAndCommit can be used to add files that were modified or created
in place in the checkout (for example, copy operation)
2013-09-07 23:15:29 -07:00
Girish Ramakrishnan 78a4daf08d repo: refactor exec call 2013-09-07 23:12:07 -07:00
Girish Ramakrishnan 925f22d979 api: add delete fileops 2013-09-07 22:23:55 -07:00
Girish Ramakrishnan 7e04452f24 repo: removeFile can now remove directories 2013-09-07 21:43:53 -07:00
Johannes Zellner eee4955f4c Add user remove route 2013-09-06 09:54:07 -07:00
Johannes Zellner 9e84c5d063 Set different default reporter for mocha 2013-09-06 09:52:32 -07:00
Johannes Zellner c05fc3f79c First user created is the admin
The special */createadmin route is to allow non authorized calls.
As soon as there is one entry in the db, no further calls are allowed.
2013-09-06 08:10:19 -07:00
Johannes Zellner 48ba30a0d1 Use user API in user routes 2013-09-05 21:34:49 -07:00
Johannes Zellner b7dfcc8576 Add initial user.js to split up the user route and API 2013-09-05 10:02:32 -07:00
Girish Ramakrishnan 10847404da repo.addFile can now automatically rename a file if it already exists 2013-09-03 01:06:07 -07:00
Girish Ramakrishnan a29778f6cf Get server version from package.json 2013-09-02 15:19:59 -07:00
Johannes Zellner bed03ef56e Do not include .git folder for volume file listing 2013-09-01 11:54:56 -07:00
Girish Ramakrishnan c5becb8480 rename options.dirs to options.listSubtrees 2013-09-01 08:37:26 -07:00
Girish Ramakrishnan 5aabc1f4bf Metadata now returns the tree hash
The hash can be provided in a future call to metadata. If there are
no changes, metadata returns 304.
2013-09-01 01:46:27 -07:00
Girish Ramakrishnan c8795fae1c Use cat-file instead of show
Only to use plumbing as much as possible.
2013-09-01 00:09:36 -07:00
Girish Ramakrishnan 7f31ead9e3 centralize volume error handling 2013-08-31 22:56:52 -07:00
Girish Ramakrishnan 23b41089b4 repo: getTree can now list dirs 2013-08-31 22:46:54 -07:00
Girish Ramakrishnan 2291146416 api: /api/v1/metadata now returns metadata about file or directory 2013-08-31 22:46:54 -07:00
Johannes Zellner 54a8dad1b7 Empty name in package.json to prevent accidental publish 2013-08-31 21:24:34 -07:00
Girish Ramakrishnan 6816e069a1 src -> api 2013-08-31 21:01:21 -07:00
Girish Ramakrishnan 009f819dae Add coverage/ to git ignore 2013-08-31 21:00:58 -07:00
Girish Ramakrishnan d6342d8f26 api: get delta changes using /api/v1/sync/<volume>/delta?clientRevision=rev 2013-08-30 16:58:56 -07:00
Girish Ramakrishnan 83120d1aab repo: implement diffTree 2013-08-30 15:58:01 -07:00
Johannes Zellner 0cfd3b43ee Move webadmin/ and server.js to toplevel folder 2013-08-30 15:00:42 -07:00
Girish Ramakrishnan 0d247de7ee Use standard Basic authentication
This makes the API easier to use with standard rest clients.
2013-08-30 14:55:48 -07:00
Girish Ramakrishnan 55e04644b0 api: revisions api - /api/v1/revisions/<path> 2013-08-30 13:51:17 -07:00
Girish Ramakrishnan db56ddb99d repo: add getRevisions to get file history 2013-08-30 13:27:54 -07:00
Girish Ramakrishnan b7805853b9 repo: refactor out log line parsing 2013-08-30 12:47:21 -07:00
Girish Ramakrishnan 187a78c10e repo: Spawn now returns the spawned process 2013-08-30 12:45:21 -07:00
Johannes Zellner 3812a0ab5f Remove noise from the volume test 2013-08-30 10:17:54 -07:00
Johannes Zellner 9ca7a5aa75 check if volume is still mounted on destroy 2013-08-30 10:17:00 -07:00
Johannes Zellner a528bd4cec Add test case to destroy a volume and actually cleanup the mounted volumes 2013-08-30 10:11:46 -07:00
Johannes Zellner 9eac6e79fd Add istanbul code coverage tool
Can be used via:
$ npm test --coverage

The result are then in the coverage subfolder:
$ chromium coverage/lcov-report/index.html
2013-08-29 14:07:54 -07:00
Johannes Zellner d2f56e2b0b Use volume.js to back the volume routes 2013-08-29 09:55:11 -07:00
Girish Ramakrishnan be2716c039 repo: read specified file revision 2013-08-27 23:51:22 -07:00
Girish Ramakrishnan 0ef5650424 repo: don't ever pipe to pager 2013-08-27 23:07:30 -07:00
Girish Ramakrishnan 38190a9831 Provide the sha1 in changes 2013-08-27 22:46:24 -07:00
Girish Ramakrishnan dd5e34249d Return 404 if file not found 2013-08-27 21:36:17 -07:00
Girish Ramakrishnan dfccd5e1f4 Create RepoError to give more information on the actual error 2013-08-27 21:34:16 -07:00
Girish Ramakrishnan d873b5e9f4 repo: check for valid file path 2013-08-27 21:27:47 -07:00
Girish Ramakrishnan 2bebe59437 Fix failing server-test 2013-08-27 15:35:22 -07:00
Girish Ramakrishnan 3ad917042c Fix path to tests 2013-08-27 15:26:58 -07:00
Girish Ramakrishnan cade29e72d Move package.json and README.md to toplevel 2013-08-27 15:22:23 -07:00
Girish Ramakrishnan 40bd520cf5 rename server/ to src/ 2013-08-27 15:18:18 -07:00
Girish Ramakrishnan 1d2c4eaf0d Remove lib/ and lock.js
lock.js got replaced with lockfile module.
2013-08-27 15:13:21 -07:00
Girish Ramakrishnan d25f424db8 Move client code to new repo
nw-client.git is the new location
2013-08-27 15:10:30 -07:00
Johannes Zellner 4240ae6189 Make client.js executeable 2013-08-27 09:15:54 -07:00
Johannes Zellner d60a4d6681 Add inital volume.js file with tests 2013-08-27 09:14:43 -07:00
Johannes Zellner 2f9e171de4 Clear file listing when a volume gets deleted 2013-08-27 09:14:43 -07:00
Girish Ramakrishnan 4fe5da1048 Say hello to new client, same as old client 2013-08-27 00:39:11 -07:00
Girish Ramakrishnan 37beba7929 clientIndex is the entries 2013-08-27 00:39:11 -07:00
Girish Ramakrishnan 920408cdea Add package.json for lib 2013-08-26 23:40:46 -07:00
Girish Ramakrishnan 5b4f03622d Move package.json to server/ 2013-08-26 23:16:08 -07:00
Anders Bakken b65d15cc5e cleanup 2013-08-26 23:05:29 -07:00
Anders Bakken 87accc011a Write a small test that traverses a directory structure and calculates hashes 2013-08-26 23:01:49 -07:00
Girish Ramakrishnan 417a2d9ece Increase volume create test timeout
On the Mac, creating volumes takes a lot of time on low battery
2013-08-26 22:12:55 -07:00
Girish Ramakrishnan bab57fc464 Use expect.js the right way 2013-08-26 21:31:24 -07:00
Girish Ramakrishnan 3704fd61d9 Store mtime and size into the entry directly 2013-08-26 21:07:39 -07:00
Girish Ramakrishnan ed47471096 Use server index to perform 3-way diff
The diff code requires mtime to resolve conflicts properly. So, just
use the index to get hold of the HEAD tree with the mtime information.
2013-08-26 08:45:44 -07:00
Girish Ramakrishnan 4b5da33d55 Disable logger in testing mode 2013-08-26 00:25:54 -07:00
Johannes Zellner 2914684867 Ignore non directories in the data folder as volumes 2013-08-25 19:00:31 -07:00
Johannes Zellner 3acbed6eb8 Add repo test for email and author 2013-08-25 18:53:28 -07:00
Johannes Zellner 3671d1cf88 disable lib/test and fix test case linting 2013-08-25 18:42:43 -07:00
Johannes Zellner 4dcce36cc2 Add email to the token database 2013-08-25 18:33:15 -07:00
Johannes Zellner f03d8f2a08 replace wrench with rimraf 2013-08-25 18:18:44 -07:00
Johannes Zellner 365f20be60 The encfs module is now in npm, remove from repo 2013-08-25 08:47:32 -07:00
Girish Ramakrishnan 2e73db41fb repo: parse index to get mtime information 2013-08-25 00:50:42 -07:00
Girish Ramakrishnan 8a2efe24bc Test routes.sync.diff 2013-08-25 00:37:40 -07:00
Girish Ramakrishnan 70db966c75 repo: pass tmpDir as config option 2013-08-24 20:55:34 -07:00
Girish Ramakrishnan 2356a673fe file: fix file update and add tests 2013-08-24 20:47:30 -07:00
Girish Ramakrishnan 5a109b462b Create multipart parser on the fly
The parser saves files directly into the volume's tmp.
2013-08-24 19:13:54 -07:00
Girish Ramakrishnan 13d266f373 Create tmp per volume
This allows us to rename files. rename() does not work across file
systems.
2013-08-24 19:13:11 -07:00
Girish Ramakrishnan bc6419ce8a repo: return file's sha1 when creating new commits 2013-08-24 18:02:03 -07:00
Girish Ramakrishnan 0cd4ea32bc repo.js: Allow git() to take multiple commands 2013-08-24 17:38:12 -07:00
Girish Ramakrishnan bff912830b repo: requesting an invalid entry must not error
It should just return a null entry
2013-08-24 17:01:36 -07:00
Girish Ramakrishnan 5b0fddb27e typo: root->rootDir 2013-08-24 17:01:02 -07:00
Girish Ramakrishnan 8ab9bd7d22 file: fix file.read and add tests
This commit also changes the initial file in volume from README to README.md.

Side note: By default, superagent only buffers response for text/* and form data.
So when sending across README, the file is just an octet-stream and the response
in not received in res.text. This can be fixed by calling buffer(false) in superagent
request. Renaming the file to README.md side steps this problem because .md files
have the mime type text/x-markdown.
2013-08-24 15:34:48 -07:00
Girish Ramakrishnan 8586420137 add test for attachVolume with bad repo param 2013-08-24 08:41:07 -07:00
Girish Ramakrishnan 9fd90d417d volume: create repos in initialize
needs test :)
2013-08-23 23:38:16 -07:00
Girish Ramakrishnan fed4c584e6 repo: remove initialize
It was present primarily for caching HEAD. It's not really required.
2013-08-23 23:36:35 -07:00
Girish Ramakrishnan eb6da4d79a Initialize repo when volume is created.
Get started with the volume tests while we are at it.
2013-08-23 23:22:46 -07:00
Girish Ramakrishnan 8fc9504dd7 tests: create admin user and get userInfo 2013-08-23 22:23:16 -07:00
Girish Ramakrishnan 8448310b10 Make server.js a module and add tests 2013-08-23 22:03:53 -07:00
Girish Ramakrishnan 7e8980d5bc file: implement update 2013-08-22 00:21:27 -07:00
Girish Ramakrishnan 5f33ac29c9 repo: make fileEntry work with deleted files 2013-08-22 00:21:22 -07:00
Girish Ramakrishnan 1c06045a01 file: implement file.read 2013-08-21 23:17:49 -07:00
Girish Ramakrishnan ca706de69d Change default base dir to ~/.yellowtent
It pollutes the source directory with stuff and git clean -dxf nuked
all my old setup :( Don't want that to happen again.

Also create the paths synchronously, otherwise this ends up with a
race with the db.initialize() code.
2013-08-21 22:47:24 -07:00
Girish Ramakrishnan 6f1bcf1250 Use app.param to attach repo to volume 2013-08-21 22:34:45 -07:00
Girish Ramakrishnan a2cca15a34 Use named params instead of wild cards 2013-08-19 23:17:11 -07:00
Girish Ramakrishnan 58d1a245ee Implement sync.diff 2013-08-19 22:46:24 -07:00
Girish Ramakrishnan c06f67965e repo.js: make getCommit public and set commit.sha1 2013-08-19 22:46:24 -07:00
Girish Ramakrishnan b642b65524 syncer: Add syncer code and test. 2013-08-19 20:40:22 -07:00
Johannes Zellner a7f857ad8c Style tinkering for volume.js 2013-08-19 10:10:27 -07:00
Johannes Zellner 0c987ed58c Add npm test script for server/ and lib/ 2013-08-19 10:01:25 -07:00
Girish Ramakrishnan 9573889ee9 repo.js: refactor 2013-08-19 02:27:46 -07:00
Girish Ramakrishnan 826f9be0e2 repo.js: remove fileChangeTime and add extra arg to fileEntry 2013-08-19 02:19:10 -07:00
Girish Ramakrishnan d2119d367c repo.js: Implement fileEntry 2013-08-19 02:07:54 -07:00
Girish Ramakrishnan 6fa3ca2697 repo.js: make head a commit object 2013-08-19 01:31:40 -07:00
Girish Ramakrishnan 69536118cc repo.js: Make Repo a class and add tests 2013-08-19 01:21:19 -07:00
Girish Ramakrishnan 4916be2a02 Implement lock.js
This will be used for locking shared variables like the index.
If we decided to make things multi-process, this implementation can
become file based.
2013-08-18 23:05:21 -07:00
Johannes Zellner b15b385a9e Move server routes from volume.js to server.js 2013-08-18 21:17:33 -07:00
Johannes Zellner 924bd03912 Also redirect to firsttime if req is / 2013-08-18 21:16:45 -07:00
Johannes Zellner d25e48bfe2 Add mocha based autotest for encfs module 2013-08-18 21:03:04 -07:00
Johannes Zellner 5c59a2f651 Change server comandline args and change firsttime
- server now takes has a configRoot, dataRoot, mountRoot with
  defaults so no startup argument is needed

  * configRoot: for server config like user db
  * dataRoot: actual encrypted container storage
  * mountRoot: mount point folder for mounted encfs volumes

- First time use is now alwasy detected and the browser gets
  redirected by the server
2013-08-18 11:23:21 -07:00
Johannes Zellner 5f356da1c6 Add bootstrap theme css files 2013-08-18 11:23:04 -07:00
Johannes Zellner da3a9b2c24 Update to current bootstrap version and adjust new volume creation 2013-08-18 10:04:47 -07:00
Girish Ramakrishnan 2282940259 repo: implement commit(), addFile(), updateFile(), removeFile(), createReadStream() 2013-08-17 11:52:07 -07:00
Johannes Zellner ee96bab60b Add 'new volume' button and make volume controls smaller 2013-08-17 09:49:30 -07:00
Girish Ramakrishnan e52b23931d repo: add mtime() and isTracked() 2013-08-17 01:33:33 -07:00
Girish Ramakrishnan 216df68578 repo: prune empty lines 2013-08-17 01:00:28 -07:00
Girish Ramakrishnan 7f2c11250b repo: empty commit is a special case for null tree 2013-08-17 01:00:28 -07:00
Girish Ramakrishnan b830bace54 repo: add commit() 2013-08-16 22:05:33 -07:00
Girish Ramakrishnan c52094290d Remove console.log 2013-08-16 21:53:20 -07:00
Girish Ramakrishnan 9f379b1106 repo: add hasFileChanged 2013-08-16 21:22:20 -07:00
Johannes Zellner 5af5910840 Temporarily disable repo per default until volume.js initializes the git repo 2013-08-16 20:47:00 -07:00
Girish Ramakrishnan d36f36e346 Add repo.js
This is our git wrapper. I tried using gift but it's painful.
2013-08-16 20:33:29 -07:00
Johannes Zellner 56c9e5b7a9 Use glyphicons for volume list delegates 2013-08-16 16:27:26 -07:00
Johannes Zellner 676067b92d Add bootstrap-glyphicons 2013-08-16 16:27:15 -07:00
Johannes Zellner 4edfc67563 Add volume deletion 2013-08-16 09:34:27 -07:00
Johannes Zellner c9ee8db8e4 Add volume delete button 2013-08-15 10:07:35 -07:00
Johannes Zellner 4e6a3deb62 Add volume creating interface 2013-08-15 08:39:11 -07:00
Johannes Zellner 3973d320b1 Add initial version of node-enc
Currently in toplevel as I dont know where to put
2013-08-14 10:50:55 -07:00
Johannes Zellner 029adee031 Add basic volume selection api 2013-08-13 21:32:17 -07:00
Johannes Zellner d09988e324 Add bare file listing to display the dirIndex content 2013-08-13 09:22:47 -07:00
Johannes Zellner 2b2f4a1f0a Add favicon.ico, 404s in terminal are annoying 2013-08-12 08:29:56 -07:00
Johannes Zellner 920bdacfef Go to index.html after firsttime setup 2013-08-12 08:28:55 -07:00
Johannes Zellner 172b2dabe2 Add some stub for dashboard pages and invalidate token on logout 2013-08-11 20:19:30 -07:00
Johannes Zellner 8bd68f994f Replace basic auth with simple post login based auth to get token 2013-08-11 14:02:37 -07:00
Johannes Zellner 8c114a5296 Merge branch 'webadmin' 2013-08-11 10:08:30 -07:00
Johannes Zellner dbb62374e8 Update icon 2013-08-10 18:56:01 -07:00
Johannes Zellner 583654e98f Add basic icon assets 2013-08-10 15:42:29 -07:00
Girish Ramakrishnan 3fad7c2eb9 webadmin: add dashboard 2013-08-03 16:51:29 -07:00
Girish Ramakrishnan 2d6e533973 webadmin: implement authentication 2013-08-03 00:23:04 -07:00
Girish Ramakrishnan b00139fff6 webadmin: Show okButton by default 2013-08-02 23:43:06 -07:00
Girish Ramakrishnan 7c36ac6336 reorg: move around code 2013-08-02 22:08:53 -07:00
Girish Ramakrishnan 5e1f81cfb6 Remove unused 'i' cmd line option 2013-08-02 18:41:57 -07:00
Girish Ramakrishnan 0a7efad0da refactor: move routes to separate directory 2013-08-02 18:00:33 -07:00
Girish Ramakrishnan 38d6d86148 webadmin: redirect to firsttime in index.html 2013-08-02 17:27:14 -07:00
Girish Ramakrishnan cb689c11d2 webadmin: rename login.html to index.html 2013-08-02 17:11:28 -07:00
Girish Ramakrishnan 7029012927 webadmin: add API to query if this is the first time 2013-08-02 17:08:59 -07:00
Girish Ramakrishnan 5b51a34ba9 webadmin: make the ui post to /api/v1/createadmin 2013-08-02 16:41:52 -07:00
Girish Ramakrishnan d611fe4e31 webadmin: implement /api/v1/createadmin 2013-08-02 14:39:03 -07:00
Girish Ramakrishnan 89c1d784da webadmin: redirect initial access to firsttime.html 2013-08-02 11:48:01 -07:00
Girish Ramakrishnan ee3209c0f5 webadmin: serve pages from /webadmin 2013-08-02 10:47:26 -07:00
Girish Ramakrishnan d49709d50a webadmin: add first time user form 2013-08-01 23:10:06 -07:00
Girish Ramakrishnan 71edfee67b webadmin: Add login page 2013-08-01 22:40:41 -07:00
Johannes Zellner 9054904d10 Fix bug, which made the transaction processing stuck 2013-07-23 22:34:42 -07:00
Johannes Zellner 4fc742d144 Create folders recoursively when adding files to the backup 2013-07-23 22:27:46 -07:00
Johannes Zellner 79ce036d22 Add --initial step for initial sync with remote to cmd client 2013-07-23 22:19:25 -07:00
Johannes Zellner 1b8bdbd8cd Add initial node-webkit, bungee based client 2013-07-23 10:20:01 -07:00
Johannes Zellner bf5be43c51 Add initial .gitignore file to ignore node_modules 2013-07-23 10:18:54 -07:00
Johannes Zellner 53ec8767ab Implement basic file download for sync purpose 2013-07-22 09:11:49 -07:00
Johannes Zellner 106ba22d69 Some improvements to transactions and the client 2013-07-13 10:22:05 -07:00
Johannes Zellner 34ef5921f3 Compare timestamps instead of strings 2013-07-13 10:21:35 -07:00
Johannes Zellner f646b08a8e Add basic transactions to the client 2013-07-01 09:47:59 -07:00
Girish Ramakrishnan 5af9b305ad server: implement missing DirIndex functions 2013-06-30 01:23:23 -07:00
Girish Ramakrishnan 07da5c310b server: check entry existence correctly 2013-06-30 00:41:38 -07:00
Johannes Zellner 9d66010b1b add mtime to request object 2013-06-30 00:36:03 -07:00
Johannes Zellner 39c66bc26f do not expect a file in the remove case 2013-06-30 00:27:16 -07:00
Girish Ramakrishnan 836662ab30 dirIndex: store ctime and mtime as integers and not Date objects 2013-06-30 00:26:11 -07:00
Johannes Zellner 783118d4f0 Use superagent 2013-06-30 00:19:51 -07:00
Girish Ramakrishnan 02c695fb2c dirIndex: actually update the sha1 2013-06-30 00:18:47 -07:00
Girish Ramakrishnan 68bcb3611b server: add README.md 2013-06-30 00:16:24 -07:00
Girish Ramakrishnan 5ab1562d02 dirIndex: add root argument to update 2013-06-30 00:15:00 -07:00
Girish Ramakrishnan 8b9ce15907 server: update index on startup 2013-06-30 00:10:14 -07:00
Girish Ramakrishnan b3996d11fc server: make add work 2013-06-30 00:07:55 -07:00
Girish Ramakrishnan 3244be448a server: implement processing of post request 2013-06-30 00:01:43 -07:00
Johannes Zellner df036de726 Get rid of some indentation 2013-06-29 21:42:58 -07:00
Girish Ramakrishnan 52912d7186 server: Add /dirIndex endpoint to receive the dirIndex 2013-06-29 21:43:20 -07:00
Girish Ramakrishnan fc50a5e9ba Add empty server stub 2013-06-29 19:56:04 -07:00
Johannes Zellner 7f7200841f Rebuild index on filesystem changes 2013-06-29 19:35:15 -07:00
Girish Ramakrishnan 956ffe73ba Remove check for callback
It's a programming error if a callback is not provided. So,
let it throw an error at compile time.
2013-06-29 19:31:18 -07:00
Girish Ramakrishnan 2e05db9bbc Make Index.update smart
Index.update now uses the previous stat and size information to
determine whether it's worth rehashing contents.
2013-06-29 19:24:09 -07:00
Girish Ramakrishnan 2de0f331e2 Save the ctime and mtime information in entry. 2013-06-29 18:03:53 -07:00
Johannes Zellner 2a9679fe59 Add initial client.js 2013-06-29 18:01:00 -07:00
Girish Ramakrishnan a72a789381 Refactor sha1 computation to private function 2013-06-29 18:01:00 -07:00
Girish Ramakrishnan 8e0e51b80c Make DirIndex take path as constructor argument 2013-06-29 18:01:00 -07:00
Girish Ramakrishnan 6679556d76 Fix package.json 2013-06-29 18:00:59 -07:00
Johannes Zellner a89c96bf29 Create directory structure 2013-06-29 18:00:50 -07:00
Girish Ramakrishnan 58775fae9a Initial version 2013-06-29 16:56:04 -07:00
718 changed files with 187698 additions and 59273 deletions
-29
View File
@@ -1,29 +0,0 @@
{
"env": {
"node": true,
"es6": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 8
},
"rules": {
"indent": [
"error",
4
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"no-console": "off"
}
}
+7 -4
View File
@@ -1,7 +1,10 @@
# following files are skipped when exporting using git archive
test export-ignore
.jshintrc export-ignore
.gitlab export-ignore
# Skip files when using git archive
.gitattributes export-ignore
.gitignore export-ignore
/release export-ignore
/scripts export-ignore
test export-ignore
/webadmin/src export-ignore
/webadmin/deploymentConfig.json export-ignore
/gulpfile.json export-ignore
+15 -3
View File
@@ -1,8 +1,20 @@
node_modules/
coverage/
webadmin/dist/
installer/src/certs/server.key
docs/
# vim swap files
# vim swam files
*.swp
# supervisor
supervisord.pid
supervisord.log
# nginx
nginx/*.log
nginx/*.pid
nginx/naked_domain.conf
nginx/applications/
# release files
release/versions-dev.json
-6
View File
@@ -1,6 +0,0 @@
Please do not use this issue tracker for support requests and bug reports.
This issue tracker is used by the Cloudron development team to track actual
bugs in the code.
Please use the forum at https://forum.cloudron.io to report bugs. For
confidential issues, please email us at support@cloudron.io.
-7
View File
@@ -1,7 +0,0 @@
Please do not use this issue tracker for support requests and feature reports.
This issue tracker is used by the Cloudron development team to track issues in
the code.
Please use the forum at https://forum.cloudron.io to report bugs. For
confidential issues, please email us at support@cloudron.io.
+7
View File
@@ -0,0 +1,7 @@
{
"node": true,
"browser": true,
"unused": true,
"globalstrict": true,
"predef": [ "angular", "$" ]
}
-1954
View File
File diff suppressed because it is too large Load Diff
-35
View File
@@ -1,35 +0,0 @@
The Cloudron Subscription license
Copyright (c) 2020 Cloudron UG
With regard to the Cloudron Software:
This software and associated documentation files (the "Software") may only be
used in production, if you (and any entity that you represent) have agreed to,
and are in compliance with, the Cloudron Subscription Terms of Service, available
at https://cloudron.io/legal/terms.html (the “Subscription Terms”), or other
agreement governing the use of the Software, as agreed by you and Cloudron,
and otherwise have a valid Cloudron Subscription. Subject to the foregoing sentence,
you are free to modify this Software and publish patches to the Software. You agree
that Subscription and/or its licensors (as applicable) retain all right, title and
interest in and to all such modifications and/or patches, and all such modifications
and/or patches may only be used, copied, modified, displayed, distributed, or otherwise
exploited with a valid Cloudron subscription. Notwithstanding the foregoing, you may copy
and modify the Software for development and testing purposes, without requiring a
subscription. You agree that Cloudron and/or its licensors (as applicable) retain
all right, title and interest in and to all such modifications. You are not
granted any other rights beyond what is expressly stated herein. Subject to the
foregoing, it is forbidden to copy, merge, publish, distribute, sublicense,
and/or sell the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
For all third party components incorporated into the Cloudron Software, those
components are licensed under the original license provided by the owner of the
applicable component.
+14 -52
View File
@@ -1,55 +1,17 @@
# Cloudron
The Box
=======
[Cloudron](https://cloudron.io) is the best way to run apps on your server.
Development setup
-----------------
* sudo useradd -m yellowtent
** This dummy user is required for supervisor 'box' configs
** Add admin-localhost as 127.0.0.1 in /etc/hosts
** All apps will be installed as hypened-subdomains of localhost. You should add
hyphened-subdomains of your apps into /etc/hosts
Web applications like email, contacts, blog, chat are the backbone of the modern
internet. Yet, we live in a world where hosting these essential applications is
a complex task.
We are building the ultimate platform for self-hosting web apps. The Cloudron allows
anyone to effortlessly host web applications on their server on their own terms.
## Features
* Single click install for apps. Check out the [App Store](https://cloudron.io/appstore.html).
* Per-app encrypted backups and restores.
* App updates delivered via the App Store.
* Secure - Cloudron manages the firewall. All apps are secured with HTTPS. Certificates are
installed and renewed automatically.
* Centralized User & Group management. Control who can access which app.
* Single Sign On. Use same credentials across all apps.
* Automatic updates for the Cloudron platform.
* Trivially migrate to another server keeping your apps and data (for example, switch your
infrastructure provider or move to a bigger server).
* Comprehensive [REST API](https://cloudron.io/documentation/developer/api/).
* [CLI](https://cloudron.io/documentation/cli/) to configure apps.
* Alerts, audit logs, graphs, dns management ... and much more
## Demo
Try our demo at https://my.demo.cloudron.io (username: cloudron password: cloudron).
## Installing
[Install script](https://cloudron.io/documentation/installation/) - [Pricing](https://cloudron.io/pricing.html)
**Note:** This repo is a small part of what gets installed on your server - there is
the dashboard, database addons, graph container, base image etc. Cloudron also relies
on external services such as the App Store for apps to be installed. As such, don't
clone this repo and npm install and expect something to work.
## Support
* [Documentation](https://cloudron.io/documentation/)
* [Forum](https://forum.cloudron.io/)
Running
-------
* `./run.sh` - this starts up nginx to serve up the webadmin
* `DEBUG=box:* ./app.js` - this the main box code.
* Navigate to https://admin-localhost
-1
View File
@@ -1 +0,0 @@
# release version. do not edit manually
Executable
+35
View File
@@ -0,0 +1,35 @@
#!/usr/bin/env node
'use strict';
require('supererror')({ splatchError: true });
var server = require('./src/server.js'),
config = require('./config.js');
console.log();
console.log('==========================================');
console.log(' Cloudron will use the following settings ');
console.log('==========================================');
console.log();
console.log(' Environment: ', config.CLOUDRON ? 'CLOUDRON' : (config.LOCAL ? 'LOCAL' : 'TEST'));
console.log(' Admin Origin: ', config.adminOrigin());
console.log(' Appstore token: ', config.token());
console.log(' Appstore server origin: ', config.appServerUrl());
console.log();
console.log('==========================================');
console.log();
server.start(function (err) {
if (err) {
console.error('Error starting server', err);
process.exit(1);
}
console.log('Server listening on port ' + config.get('port'));
});
var NOOP_CALLBACK = function () { };
process.on('SIGINT', function () { server.stop(NOOP_CALLBACK); });
process.on('SIGTERM', function () { server.stop(NOOP_CALLBACK); });
+135
View File
@@ -0,0 +1,135 @@
#!/usr/bin/env node
'use strict';
require('supererror')({ splatchError: true });
var appdb = require('./src/appdb.js'),
assert = require('assert'),
async = require('async'),
database = require('./src/database.js'),
DatabaseError = require('./src/databaseerror.js'),
debug = require('debug')('box:apphealthtask'),
docker = require('./src/docker.js'),
mailer = require('./src/mailer.js'),
os = require('os'),
superagent = require('superagent');
exports = module.exports = {
initialize: initialize,
run: run
};
var FATAL_CALLBACK = function (error) {
if (!error) return;
console.error(error);
process.exit(2);
};
var HEALTHCHECK_INTERVAL = 30000;
var gLastSeen = { }; // { time, emailSent }
function initialize(callback) {
async.series([
database.initialize,
mailer.initialize
], callback);
}
function setHealth(app, alive, runState, callback) {
assert(typeof app === 'object');
assert(typeof alive === 'boolean');
assert(typeof runState === 'string');
assert(typeof callback === 'function');
var healthy = true; // app is unhealthy if not alive for 2 mins
var now = new Date();
if (alive || !(app.id in gLastSeen)) { // give never seen apps 2 mins to come up
gLastSeen[app.id] = { time: now, emailSent: false };
} else if (Math.abs(now - gLastSeen[app.id].time) > 120 * 1000) { // not seen for 2 mins
debug('app %s not seen for more than 2 mins, marking as unhealthy', app.id);
healthy = false;
}
if (!healthy && !gLastSeen[app.id].emailSent) {
gLastSeen[app.id].emailSent = true;
mailer.appDied(app);
}
appdb.setHealth(app.id, healthy, runState, function (error) {
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(null); // app uninstalled?
if (error) return callback(error);
app.healthy = healthy;
app.runState = runState;
callback(null);
});
}
// # TODO should probably poll from the outside network instead of the docker network?
// callback is called with error for fatal errors and not if health check failed
function checkAppHealth(app, callback) {
// only check status of installed apps. we could possibly optimize more by checking runState as well
if (app.installationState !== appdb.ISTATE_INSTALLED) return callback(null);
var container = docker.getContainer(app.containerId),
manifest = app.manifest;
container.inspect(function (err, data) {
if (err || !data || !data.State) {
debug('Error inspecting container');
return setHealth(app, false, appdb.RSTATE_ERROR, callback);
}
if (data.State.Running !== true) {
debug('app %s has exited', app.id);
return setHealth(app, false, appdb.RSTATE_DEAD, callback);
}
var healthCheckUrl = 'http://127.0.0.1:' + app.httpPort + manifest.healthCheckPath;
superagent
.get(healthCheckUrl)
.timeout(HEALTHCHECK_INTERVAL)
.end(function (error, res) {
if (error || res.status !== 200) {
debug('app %s is not alive ', app.id);
setHealth(app, false, appdb.RSTATE_RUNNING, callback);
} else {
debug('app %s is alive', app.id);
setHealth(app, true, appdb.RSTATE_RUNNING, callback);
}
});
});
}
function processApps(callback) {
appdb.getAll(function (error, apps) {
if (error) return callback(error);
async.each(apps, checkAppHealth, function (error) {
if (error) console.error(error);
callback(null);
});
});
}
function run(callback) {
processApps(function (error) {
if (error) return callback(error);
setTimeout(run.bind(null, callback), HEALTHCHECK_INTERVAL);
});
}
if (require.main === module) {
initialize();
run(function (error) {
console.error('apphealth task exiting with error.', error);
process.exit(error ? 1 : 0);
});
}
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

-193
View File
@@ -1,193 +0,0 @@
#!/bin/bash
set -eu -o pipefail
assertNotEmpty() {
: "${!1:? "$1 is not set."}"
}
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)"
export JSON="${SOURCE_DIR}/node_modules/.bin/json"
INSTANCE_TYPE="t2.micro"
BLOCK_DEVICE="DeviceName=/dev/sda1,Ebs={VolumeSize=20,DeleteOnTermination=true,VolumeType=gp2}"
SSH_KEY_NAME="id_rsa_yellowtent"
revision=$(git rev-parse HEAD)
ami_name=""
server_id=""
server_ip=""
destroy_server="yes"
deploy_env="prod"
image_id=""
args=$(getopt -o "" -l "revision:,name:,no-destroy,env:,region:" -n "$0" -- "$@")
eval set -- "${args}"
while true; do
case "$1" in
--env) deploy_env="$2"; shift 2;;
--revision) revision="$2"; shift 2;;
--name) ami_name="$2"; shift 2;;
--no-destroy) destroy_server="no"; shift 2;;
--region)
case "$2" in
"us-east-1")
image_id="ami-6edd3078"
security_group="sg-a5e17fd9"
subnet_id="subnet-b8fbc0f1"
;;
"eu-central-1")
image_id="ami-5aee2235"
security_group="sg-19f5a770" # everything open on eu-central-1
subnet_id=""
;;
*)
echo "Unknown aws region $2"
exit 1
;;
esac
export AWS_DEFAULT_REGION="$2" # used by the aws cli tool
shift 2
;;
--) break;;
*) echo "Unknown option $1"; exit 1;;
esac
done
# TODO fix this
export AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY}"
export AWS_SECRET_ACCESS_KEY="${AWS_ACCESS_SECRET}"
readonly ssh_keys="${HOME}/.ssh/id_rsa_yellowtent"
readonly SSH="ssh -o IdentitiesOnly=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ${ssh_keys}"
if [[ ! -f "${ssh_keys}" ]]; then
echo "caas ssh key is missing at ${ssh_keys} (pick it up from secrets repo)"
exit 1
fi
if [[ -z "${image_id}" ]]; then
echo "--region is required (us-east-1 or eu-central-1)"
exit 1
fi
function get_pretty_revision() {
local git_rev="$1"
local sha1=$(git rev-parse --short "${git_rev}" 2>/dev/null)
echo "${sha1}"
}
function wait_for_ssh() {
echo "=> Waiting for ssh connection"
while true; do
echo -n "."
if $SSH ubuntu@${server_ip} echo "hello"; then
echo ""
break
fi
sleep 5
done
}
now=$(date "+%Y-%m-%d-%H%M%S")
pretty_revision=$(get_pretty_revision "${revision}")
if [[ -z "${ami_name}" ]]; then
ami_name="box-${deploy_env}-${pretty_revision}-${now}"
fi
echo "=> Create EC2 instance"
id=$(aws ec2 run-instances --image-id "${image_id}" --instance-type "${INSTANCE_TYPE}" --security-group-ids "${security_group}" --block-device-mappings "${BLOCK_DEVICE}" --key-name "${SSH_KEY_NAME}" --subnet-id "${subnet_id}" --associate-public-ip-address \
| $JSON Instances \
| $JSON 0.InstanceId)
[[ -z "$id" ]] && exit 1
echo "Instance created ID $id"
echo "=> Waiting for instance to get a public IP"
while true; do
server_ip=$(aws ec2 describe-instances --instance-ids ${id} \
| $JSON Reservations.0.Instances \
| $JSON 0.PublicIpAddress)
if [[ ! -z "${server_ip}" ]]; then
echo ""
break
fi
echo -n "."
sleep 1
done
echo "Got public IP ${server_ip}"
wait_for_ssh
echo "=> Fetching cloudron-setup"
while true; do
if $SSH ubuntu@${server_ip} wget "https://cloudron.io/cloudron-setup" -O "cloudron-setup"; then
echo ""
break
fi
echo -n "."
sleep 5
done
echo "=> Running cloudron-setup"
$SSH ubuntu@${server_ip} sudo /bin/bash "cloudron-setup" --env "${deploy_env}" --provider "ami" --skip-reboot
wait_for_ssh
echo "=> Removing ssh key"
$SSH ubuntu@${server_ip} sudo rm /home/ubuntu/.ssh/authorized_keys /root/.ssh/authorized_keys
echo "=> Creating AMI"
image_id=$(aws ec2 create-image --instance-id "${id}" --name "${ami_name}" | $JSON ImageId)
[[ -z "$id" ]] && exit 1
echo "Creating AMI with Id ${image_id}"
echo "=> Waiting for AMI to be created"
while true; do
state=$(aws ec2 describe-images --image-ids ${image_id} \
| $JSON Images \
| $JSON 0.State)
if [[ "${state}" == "available" ]]; then
echo ""
break
fi
echo -n "."
sleep 5
done
if [[ "${destroy_server}" == "yes" ]]; then
echo "=> Deleting EC2 instance"
while true; do
state=$(aws ec2 terminate-instances --instance-id "${id}" \
| $JSON TerminatingInstances \
| $JSON 0.CurrentState.Name)
if [[ "${state}" == "shutting-down" ]]; then
echo ""
break
fi
echo -n "."
sleep 5
done
fi
echo ""
echo "Done."
echo ""
echo "New AMI is: ${image_id}"
echo ""
-261
View File
@@ -1,261 +0,0 @@
#!/bin/bash
if [[ -z "${DIGITAL_OCEAN_TOKEN}" ]]; then
echo "Script requires DIGITAL_OCEAN_TOKEN env to be set"
exit 1
fi
if [[ -z "${JSON}" ]]; then
echo "Script requires JSON env to be set to path of JSON binary"
exit 1
fi
readonly CURL="curl --retry 5 -s -u ${DIGITAL_OCEAN_TOKEN}:"
function debug() {
echo "$@" >&2
}
function get_ssh_key_id() {
id=$($CURL "https://api.digitalocean.com/v2/account/keys" \
| $JSON ssh_keys \
| $JSON -c "this.name === \"$1\"" \
| $JSON 0.id)
[[ -z "$id" ]] && exit 1
echo "$id"
}
function create_droplet() {
local ssh_key_id="$1"
local box_name="$2"
local image_region="sfo2"
local ubuntu_image_slug="ubuntu-16-04-x64"
local box_size="1gb"
local data="{\"name\":\"${box_name}\",\"size\":\"${box_size}\",\"region\":\"${image_region}\",\"image\":\"${ubuntu_image_slug}\",\"ssh_keys\":[ \"${ssh_key_id}\" ],\"backups\":false}"
id=$($CURL -X POST -H 'Content-Type: application/json' -d "${data}" "https://api.digitalocean.com/v2/droplets" | $JSON droplet.id)
[[ -z "$id" ]] && exit 1
echo "$id"
}
function get_droplet_ip() {
local droplet_id="$1"
ip=$($CURL "https://api.digitalocean.com/v2/droplets/${droplet_id}" | $JSON "droplet.networks.v4[0].ip_address")
[[ -z "$ip" ]] && exit 1
echo "$ip"
}
function get_droplet_id() {
local droplet_name="$1"
id=$($CURL "https://api.digitalocean.com/v2/droplets?per_page=200" | $JSON "droplets" | $JSON -c "this.name === '${droplet_name}'" | $JSON "[0].id")
[[ -z "$id" ]] && exit 1
echo "$id"
}
function power_off_droplet() {
local droplet_id="$1"
local data='{"type":"power_off"}'
local response=$($CURL -X POST -H 'Content-Type: application/json' -d "${data}" "https://api.digitalocean.com/v2/droplets/${droplet_id}/actions")
local event_id=`echo "${response}" | $JSON action.id`
if [[ -z "${event_id}" ]]; then
debug "Got no event id, assuming already powered off."
debug "Response: ${response}"
return
fi
debug "Powered off droplet. Event id: ${event_id}"
debug -n "Waiting for droplet to power off"
while true; do
local event_status=`$CURL "https://api.digitalocean.com/v2/droplets/${droplet_id}/actions/${event_id}" | $JSON action.status`
if [[ "${event_status}" == "completed" ]]; then
break
fi
debug -n "."
sleep 10
done
debug ""
}
function power_on_droplet() {
local droplet_id="$1"
local data='{"type":"power_on"}'
local event_id=`$CURL -X POST -H 'Content-Type: application/json' -d "${data}" "https://api.digitalocean.com/v2/droplets/${droplet_id}/actions" | $JSON action.id`
debug "Powered on droplet. Event id: ${event_id}"
if [[ -z "${event_id}" ]]; then
debug "Got no event id, assuming already powered on"
return
fi
debug -n "Waiting for droplet to power on"
while true; do
local event_status=`$CURL "https://api.digitalocean.com/v2/droplets/${droplet_id}/actions/${event_id}" | $JSON action.status`
if [[ "${event_status}" == "completed" ]]; then
break
fi
debug -n "."
sleep 10
done
debug ""
}
function get_image_id() {
local snapshot_name="$1"
local image_id=""
if ! response=$($CURL "https://api.digitalocean.com/v2/images?per_page=200"); then
echo "Failed to get image listing. ${response}"
return 1
fi
if ! image_id=$(echo "$response" \
| $JSON images \
| $JSON -c "this.name === \"${snapshot_name}\"" 0.id); then
echo "Failed to parse curl response: ${response}"
return 1
fi
if [[ -z "${image_id}" ]]; then
echo "Failed to get image id of ${snapshot_name}. reponse: ${response}"
return 1
fi
echo "${image_id}"
}
function snapshot_droplet() {
local droplet_id="$1"
local snapshot_name="$2"
local data="{\"type\":\"snapshot\",\"name\":\"${snapshot_name}\"}"
local event_id=`$CURL -X POST -H 'Content-Type: application/json' -d "${data}" "https://api.digitalocean.com/v2/droplets/${droplet_id}/actions" | $JSON action.id`
debug "Droplet snapshotted as ${snapshot_name}. Event id: ${event_id}"
debug -n "Waiting for snapshot to complete"
while true; do
if ! response=$($CURL "https://api.digitalocean.com/v2/droplets/${droplet_id}/actions/${event_id}"); then
echo "Could not get action status. ${response}"
continue
fi
if ! event_status=$(echo "${response}" | $JSON action.status); then
echo "Could not parse action.status from response. ${response}"
continue
fi
if [[ "${event_status}" == "completed" ]]; then
break
fi
debug -n "."
sleep 10
done
debug "! done"
if ! image_id=$(get_image_id "${snapshot_name}"); then
return 1
fi
echo "${image_id}"
}
function destroy_droplet() {
local droplet_id="$1"
# TODO: check for 204 status
$CURL -X DELETE "https://api.digitalocean.com/v2/droplets/${droplet_id}"
debug "Droplet destroyed"
debug ""
}
function transfer_image() {
local image_id="$1"
local region_slug="$2"
local data="{\"type\":\"transfer\",\"region\":\"${region_slug}\"}"
local event_id=`$CURL -X POST -H 'Content-Type: application/json' -d "${data}" "https://api.digitalocean.com/v2/images/${image_id}/actions" | $JSON action.id`
echo "${event_id}"
}
function wait_for_image_event() {
local image_id="$1"
local event_id="$2"
debug -n "Waiting for ${event_id}"
while true; do
local event_status=`$CURL "https://api.digitalocean.com/v2/images/${image_id}/actions/${event_id}" | $JSON action.status`
if [[ "${event_status}" == "completed" ]]; then
break
fi
debug -n "."
sleep 10
done
debug ""
}
function transfer_image_to_all_regions() {
local image_id="$1"
xfer_events=()
image_regions=(ams2) ## sfo1 is where the image is created
for image_region in ${image_regions[@]}; do
xfer_event=$(transfer_image ${image_id} ${image_region})
echo "Image transfer to ${image_region} initiated. Event id: ${xfer_event}"
xfer_events+=("${xfer_event}")
sleep 1
done
echo "Image transfer initiated, but they will take some time to get transferred."
for xfer_event in ${xfer_events[@]}; do
$vps wait_for_image_event "${image_id}" "${xfer_event}"
done
}
if [[ $# -lt 1 ]]; then
debug "<command> <params...>"
exit 1
fi
case $1 in
get_ssh_key_id)
get_ssh_key_id "${@:2}"
;;
create)
create_droplet "${@:2}"
;;
get_id)
get_droplet_id "${@:2}"
;;
get_ip)
get_droplet_ip "${@:2}"
;;
power_on)
power_on_droplet "${@:2}"
;;
power_off)
power_off_droplet "${@:2}"
;;
snapshot)
snapshot_droplet "${@:2}"
;;
destroy)
destroy_droplet "${@:2}"
;;
transfer_image_to_all_regions)
transfer_image_to_all_regions "${@:2}"
;;
*)
echo "Unknown command $1"
exit 1
esac
-164
View File
@@ -1,164 +0,0 @@
#!/bin/bash
set -euv -o pipefail
readonly SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly arg_provider="${1:-generic}"
readonly arg_infraversionpath="${SOURCE_DIR}/${2:-}"
function die {
echo $1
exit 1
}
export DEBIAN_FRONTEND=noninteractive
# hold grub since updating it breaks on some VPS providers. also, dist-upgrade will trigger it
apt-mark hold grub* >/dev/null
apt-get -o Dpkg::Options::="--force-confdef" update -y
apt-get -o Dpkg::Options::="--force-confdef" upgrade -y
apt-mark unhold grub* >/dev/null
echo "==> Installing required packages"
debconf-set-selections <<< 'mysql-server mysql-server/root_password password password'
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password password'
# this enables automatic security upgrades (https://help.ubuntu.com/community/AutomaticSecurityUpdates)
# resolvconf is needed for unbound to work property after disabling systemd-resolved in 18.04
ubuntu_version=$(lsb_release -rs)
ubuntu_codename=$(lsb_release -cs)
gpg_package=$([[ "${ubuntu_version}" == "16.04" ]] && echo "gnupg" || echo "gpg")
apt-get -y install \
acl \
build-essential \
cifs-utils \
cron \
curl \
debconf-utils \
dmsetup \
$gpg_package \
iptables \
libpython2.7 \
linux-generic \
logrotate \
mysql-server-5.7 \
openssh-server \
pwgen \
resolvconf \
swaks \
tzdata \
unattended-upgrades \
unbound \
xfsprogs
if [[ "${ubuntu_version}" == "16.04" ]]; then
echo "==> installing nginx for xenial for TLSv3 support"
curl -sL http://nginx.org/packages/ubuntu/pool/nginx/n/nginx/nginx_1.14.0-1~xenial_amd64.deb -o /tmp/nginx.deb
# apt install with install deps (as opposed to dpkg -i)
apt install -y /tmp/nginx.deb
rm /tmp/nginx.deb
else
apt install -y nginx-full
fi
# on some providers like scaleway the sudo file is changed and we want to keep the old one
apt-get -o Dpkg::Options::="--force-confold" install -y sudo
# this ensures that unattended upgades are enabled, if it was disabled during ubuntu install time (see #346)
# debconf-set-selection of unattended-upgrades/enable_auto_updates + dpkg-reconfigure does not work
cp /usr/share/unattended-upgrades/20auto-upgrades /etc/apt/apt.conf.d/20auto-upgrades
echo "==> Installing node.js"
mkdir -p /usr/local/node-10.18.1
curl -sL https://nodejs.org/dist/v10.18.1/node-v10.18.1-linux-x64.tar.gz | tar zxvf - --strip-components=1 -C /usr/local/node-10.18.1
ln -sf /usr/local/node-10.18.1/bin/node /usr/bin/node
ln -sf /usr/local/node-10.18.1/bin/npm /usr/bin/npm
apt-get install -y python # Install python which is required for npm rebuild
[[ "$(python --version 2>&1)" == "Python 2.7."* ]] || die "Expecting python version to be 2.7.x"
# https://docs.docker.com/engine/installation/linux/ubuntulinux/
echo "==> Installing Docker"
# create systemd drop-in file. if you channge options here, be sure to fixup installer.sh as well
mkdir -p /etc/systemd/system/docker.service.d
echo -e "[Service]\nExecStart=\nExecStart=/usr/bin/dockerd -H fd:// --log-driver=journald --exec-opt native.cgroupdriver=cgroupfs --storage-driver=overlay2" > /etc/systemd/system/docker.service.d/cloudron.conf
# there are 3 packages for docker - containerd, CLI and the daemon
curl -sL "https://download.docker.com/linux/ubuntu/dists/${ubuntu_codename}/pool/stable/amd64/containerd.io_1.2.2-3_amd64.deb" -o /tmp/containerd.deb
curl -sL "https://download.docker.com/linux/ubuntu/dists/${ubuntu_codename}/pool/stable/amd64/docker-ce-cli_18.09.2~3-0~ubuntu-${ubuntu_codename}_amd64.deb" -o /tmp/docker-ce-cli.deb
curl -sL "https://download.docker.com/linux/ubuntu/dists/${ubuntu_codename}/pool/stable/amd64/docker-ce_18.09.2~3-0~ubuntu-${ubuntu_codename}_amd64.deb" -o /tmp/docker.deb
# apt install with install deps (as opposed to dpkg -i)
apt install -y /tmp/containerd.deb /tmp/docker-ce-cli.deb /tmp/docker.deb
rm /tmp/containerd.deb /tmp/docker-ce-cli.deb /tmp/docker.deb
storage_driver=$(docker info | grep "Storage Driver" | sed 's/.*: //')
if [[ "${storage_driver}" != "overlay2" ]]; then
echo "Docker is using "${storage_driver}" instead of overlay2"
exit 1
fi
# do not upgrade grub because it might prompt user and break this script
echo "==> Enable memory accounting"
apt-get -y --no-upgrade install grub2-common
sed -e 's/^GRUB_CMDLINE_LINUX="\(.*\)"$/GRUB_CMDLINE_LINUX="\1 cgroup_enable=memory swapaccount=1 panic_on_oops=1 panic=5"/' -i /etc/default/grub
update-grub
echo "==> Downloading docker images"
if [ ! -f "${arg_infraversionpath}/infra_version.js" ]; then
echo "No infra_versions.js found"
exit 1
fi
images=$(node -e "var i = require('${arg_infraversionpath}/infra_version.js'); console.log(i.baseImages.map(function (x) { return x.tag; }).join(' '), Object.keys(i.images).map(function (x) { return i.images[x].tag; }).join(' '));")
echo -e "\tPulling docker images: ${images}"
for image in ${images}; do
docker pull "${image}"
docker pull "${image%@sha256:*}" # this will tag the image for readability
done
echo "==> Install collectd"
if ! apt-get install -y libcurl3-gnutls collectd collectd-utils; then
# FQDNLookup is true in default debian config. The box code has a custom collectd.conf that fixes this
echo "Failed to install collectd. Presumably because of http://mailman.verplant.org/pipermail/collectd/2015-March/006491.html"
sed -e 's/^FQDNLookup true/FQDNLookup false/' -i /etc/collectd/collectd.conf
fi
echo "==> Configuring host"
sed -e 's/^#NTP=/NTP=0.ubuntu.pool.ntp.org 1.ubuntu.pool.ntp.org 2.ubuntu.pool.ntp.org 3.ubuntu.pool.ntp.org/' -i /etc/systemd/timesyncd.conf
timedatectl set-ntp 1
# mysql follows the system timezone
timedatectl set-timezone UTC
echo "==> Adding sshd configuration warning"
sed -e '/Port 22/ i # NOTE: Cloudron only supports moving SSH to port 202. See https://cloudron.io/documentation/security/#securing-ssh-access' -i /etc/ssh/sshd_config
# https://bugs.launchpad.net/ubuntu/+source/base-files/+bug/1701068
echo "==> Disabling motd news"
sed -i 's/^ENABLED=.*/ENABLED=0/' /etc/default/motd-news
# Disable bind for good measure (on online.net, kimsufi servers these are pre-installed and conflicts with unbound)
systemctl stop bind9 || true
systemctl disable bind9 || true
# on ovh images dnsmasq seems to run by default
systemctl stop dnsmasq || true
systemctl disable dnsmasq || true
# on ssdnodes postfix seems to run by default
systemctl stop postfix || true
systemctl disable postfix || true
# on ubuntu 18.04, this is the default. this requires resolvconf for DNS to work further after the disable
systemctl stop systemd-resolved || true
systemctl disable systemd-resolved || true
# ubuntu's default config for unbound does not work if ipv6 is disabled. this config is overwritten in start.sh
# we need unbound to work as this is required for installer.sh to do any DNS requests
ip6=$([[ -s /proc/net/if_inet6 ]] && echo "yes" || echo "no")
echo -e "server:\n\tinterface: 127.0.0.1\n\tdo-ip6: ${ip6}" > /etc/unbound/unbound.conf.d/cloudron-network.conf
systemctl restart unbound
-58
View File
@@ -1,58 +0,0 @@
#!/usr/bin/env node
'use strict';
// prefix all output with a timestamp
// debug() already prefixes and uses process.stderr NOT console.*
['log', 'info', 'warn', 'debug', 'error'].forEach(function (log) {
var orig = console[log];
console[log] = function () {
orig.apply(console, [new Date().toISOString()].concat(Array.prototype.slice.call(arguments)));
};
});
require('supererror')({ splatchError: true });
let async = require('async'),
constants = require('./src/constants.js'),
dockerProxy = require('./src/dockerproxy.js'),
ldap = require('./src/ldap.js'),
server = require('./src/server.js');
console.log();
console.log('==========================================');
console.log(` Cloudron ${constants.VERSION} `);
console.log('==========================================');
console.log();
async.series([
server.start,
ldap.start,
dockerProxy.start
], function (error) {
if (error) {
console.error('Error starting server', error);
process.exit(1);
}
console.log('Cloudron is up and running');
});
var NOOP_CALLBACK = function () { };
process.on('SIGINT', function () {
console.log('Received SIGINT. Shutting down.');
server.stop(NOOP_CALLBACK);
ldap.stop(NOOP_CALLBACK);
dockerProxy.stop(NOOP_CALLBACK);
setTimeout(process.exit.bind(process), 3000);
});
process.on('SIGTERM', function () {
console.log('Received SIGTERM. Shutting down.');
server.stop(NOOP_CALLBACK);
ldap.stop(NOOP_CALLBACK);
dockerProxy.stop(NOOP_CALLBACK);
setTimeout(process.exit.bind(process), 3000);
});
+143
View File
@@ -0,0 +1,143 @@
/* jslint node: true */
'use strict';
var path = require('path'),
fs = require('fs'),
safe = require('safetydance'),
assert = require('assert'),
_ = require('underscore'),
path = require('path'),
mkdirp = require('mkdirp');
exports = module.exports = {
baseDir: baseDir,
get: get,
set: set,
// ifdefs to check environment
CLOUDRON: process.env.NODE_ENV === 'cloudron',
TEST: process.env.NODE_ENV === 'test',
LOCAL: process.env.NODE_ENV === 'local' || !process.env.NODE_ENV,
// convenience getters
appServerUrl: appServerUrl,
fqdn: fqdn,
token: token,
version: version,
isCustomDomain: isCustomDomain,
// these values are derived
adminOrigin: adminOrigin,
appFqdn: appFqdn,
zoneName: zoneName
};
var homeDir = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
var data = { };
function baseDir() {
if (exports.CLOUDRON) return homeDir;
if (exports.TEST) return path.join(homeDir, '.yellowtenttest');
if (exports.LOCAL) return path.join(homeDir, '.yellowtent');
}
var cloudronConfigFileName = path.join(baseDir(), 'configs/cloudron.conf');
function saveSync() {
fs.writeFileSync(cloudronConfigFileName, JSON.stringify(data, null, 4)); // functions are ignored by JSON.stringify
}
(function initConfig() {
// setup defaults
if (exports.CLOUDRON) {
data.port = 3000;
data.appServerUrl = process.env.APP_SERVER_URL || null; // APP_SERVER_URL is set during bootstrap in the box's supervisor manifest
} else if (exports.TEST) {
data.port = 5454;
data.appServerUrl = 'http://localhost:6060'; // hock doesn't support https
} else if (exports.LOCAL) {
data.port = 3000;
data.appServerUrl = 'http://localhost:5050';
} else {
assert(false, 'Unknown environment. This should not happen!');
}
data.fqdn = 'localhost';
data.token = null;
data.mailServer = null;
data.mailUsername = null;
data.mailDnsRecordIds = [ ];
data.boxVersionsUrl = null;
data.version = null;
data.isCustomDomain = false;
if (safe.fs.existsSync(cloudronConfigFileName)) {
var existingData = safe.JSON.parse(safe.fs.readFileSync(cloudronConfigFileName, 'utf8'));
_.extend(data, existingData); // overwrite defaults with saved config
return;
}
mkdirp.sync(path.dirname(cloudronConfigFileName));
saveSync();
})();
// set(obj) or set(key, value)
function set(key, value) {
if (typeof key === 'object') {
var obj = key;
for (var k in obj) {
assert(k in data, 'config.js is missing key "' + k + '"');
data[k] = obj[k];
}
} else {
assert(key in data, 'config.js is missing key "' + key + '"');
data[key] = value;
}
saveSync();
}
function get(key) {
assert(typeof key === 'string');
return safe.query(data, key);
}
function appServerUrl() {
return get('appServerUrl');
}
function fqdn() {
return get('fqdn');
}
function appFqdn(location) {
assert(typeof location === 'string');
return isCustomDomain() ? location + '.' + fqdn() : location + '-' + fqdn();
}
function adminOrigin() {
return 'https://' + appFqdn('admin');
}
function token() {
return get('token');
}
function version() {
return get('version');
}
function isCustomDomain() {
return get('isCustomDomain');
}
function zoneName() {
if (isCustomDomain()) return fqdn(); // the appstore sets up the custom domain as a zone
// for shared domain name, strip out the hostname
return fqdn().substr(fqdn().indexOf('.') + 1);
}
-28
View File
@@ -1,28 +0,0 @@
#!/usr/bin/env node
'use strict';
var database = require('./src/database.js');
var crashNotifier = require('./src/crashnotifier.js');
// This is triggered by systemd with the crashed unit name as argument
function main() {
if (process.argv.length !== 3) return console.error('Usage: crashnotifier.js <unitName>');
var unitName = process.argv[2];
console.log('Started crash notifier for', unitName);
// eventlog api needs the db
database.initialize(function (error) {
if (error) return console.error('Cannot connect to database. Unable to send crash log.', error);
crashNotifier.sendFailureLogs(unitName, function (error) {
if (error) console.error(error);
process.exit();
});
});
}
main();
+74
View File
@@ -0,0 +1,74 @@
/* jslint node:true */
'use strict';
var _ejs = require('ejs'),
ejs = require('gulp-ejs'),
gulp = require('gulp'),
del = require('del'),
path = require('path'),
concat = require('gulp-concat'),
sourcemaps = require('gulp-sourcemaps'),
fs = require('fs');
_ejs.filters.basename = function (obj) {
return path.basename(obj);
};
gulp.task('3rdparty', function () {
return gulp.src([
'webadmin/src/3rdparty/**/*.js',
'webadmin/src/3rdparty/**/*.css',
'webadmin/src/3rdparty/**/*.otf',
'webadmin/src/3rdparty/**/*.eot',
'webadmin/src/3rdparty/**/*.svg',
'webadmin/src/3rdparty/**/*.ttf',
'webadmin/src/3rdparty/**/*.woff',
'webadmin/src/3rdparty/**/*.js'
])
.pipe(gulp.dest('webadmin/dist/3rdparty/'));
});
gulp.task('js-index', function () {
return gulp.src(['webadmin/src/js/index.js', 'webadmin/src/js/client.js', 'webadmin/src/js/appstore.js', 'webadmin/src/js/main.js', 'webadmin/src/views/*.js'])
.pipe(sourcemaps.init())
.pipe(concat('index.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('webadmin/dist/js'));
});
gulp.task('js-setup', function () {
return gulp.src(['webadmin/src/js/setup.js', 'webadmin/src/js/client.js'])
.pipe(sourcemaps.init())
.pipe(concat('setup.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('webadmin/dist/js'));
});
gulp.task('js', ['js-index', 'js-setup'], function () {});
gulp.task('htmlViews', function () {
return gulp.src('webadmin/src/views/*.html')
.pipe(gulp.dest('webadmin/dist/views'));
});
gulp.task('html_templates', function () {
var config = JSON.parse(fs.readFileSync('./webadmin/deploymentConfig.json'));
return gulp.src('webadmin/src/*.ejs')
.pipe(ejs(config, { ext: '.html' }))
.pipe(gulp.dest('webadmin/dist'));
});
gulp.task('html', ['html_templates', 'htmlViews'], function () {
return gulp.src('webadmin/src/*.html')
.pipe(gulp.dest('webadmin/dist'));
});
gulp.task('clean', function (callback) {
del(['webadmin/dist'], callback);
});
gulp.task('default', ['clean'], function () {
gulp.start('html', 'js', '3rdparty');
});
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

+3 -7
View File
@@ -1,12 +1,8 @@
'use strict';
var url = require('url');
var dbm = require('db-migrate');
var type = dbm.dataType;
exports.up = function(db, callback) {
var dbName = url.parse(process.env.DATABASE_URL).path.substr(1); // remove slash
// by default, mysql collates case insensitively. 'utf8_general_cs' is not available
db.runSql('ALTER DATABASE ' + dbName + ' DEFAULT CHARACTER SET=utf8 DEFAULT COLLATE utf8_bin', callback);
callback();
};
exports.down = function(db, callback) {
+2 -1
View File
@@ -1,4 +1,5 @@
'use strict';
var dbm = require('db-migrate');
var type = dbm.dataType;
var fs = require('fs'),
async = require('async'),
@@ -0,0 +1,21 @@
var dbm = require('db-migrate');
var type = dbm.dataType;
var uuid = require('node-uuid');
exports.up = function(db, callback) {
var scopes = 'root,profile,users,apps,settings,roleAdmin';
var adminOrigin = 'https://admin-localhost';
// postinstall.sh creates the webadmin entry in production mode
if (process.env.NODE_ENV !== 'test') return callback(null);
db.runSql('INSERT INTO clients (id, appId, clientId, clientSecret, name, redirectURI, scope) ' +
'VALUES (?, ?, ?, ?, ?, ?, ?)', [ uuid.v4(), 'webadmin', 'cid-webadmin', 'unused', 'WebAdmin', adminOrigin, scopes ],
callback);
};
exports.down = function(db, callback) {
// not sure what is meaningful here
callback(null);
};
@@ -0,0 +1,10 @@
var dbm = require('db-migrate');
var type = dbm.dataType;
exports.up = function(db, callback) {
db.runSql('INSERT INTO settings (key, value) VALUES (?, ?)', [ 'naked_domain', null ], callback);
};
exports.down = function(db, callback) {
db.runSql('DELETE FROM settings WHERE key=?', [ 'naked_domain' ], callback);
};
@@ -0,0 +1,15 @@
var dbm = require('db-migrate');
var type = dbm.dataType;
exports.up = function(db, callback) {
db.runSql('CREATE TABLE appAddonConfigs(' +
' appId VARCHAR(512) NOT NULL,' +
' addonId VARCHAR(32) NOT NULL,' +
' value VARCHAR(512) NOT NULL,' +
' FOREIGN KEY(appId) REFERENCES apps(id))', callback);
};
exports.down = function(db, callback) {
db.runSql('DROP TABLE appAddonConfigs', callback);
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE users ADD COLUMN resetToken VARCHAR(128) DEFAULT ""', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE users DROP COLUMN resetToken', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,19 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('DELETE FROM tokens', [], function (error) {
if (error) console.error(error);
db.runSql('ALTER TABLE tokens MODIFY expires BIGINT', [], function (error) {
if (error) console.error(error);
callback(error);
});
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE tokens MODIFY expires VARCHAR(512)', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE authcodes ADD COLUMN expiresAt BIGINT NOT NULL', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE authcodes DROP COLUMN expiresAt', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE appPortBindings ADD COLUMN environmentVariable VARCHAR(128) NOT NULL', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE appPortBindings DROP COLUMN environmentVariable', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE appPortBindings DROP COLUMN containerPort', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE appPortBindings ADD COLUMN containerPort VARCHAR(5) NOT NULL', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,19 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('DELETE FROM tokens', [], function (error) {
if (error) console.error(error);
db.runSql('ALTER TABLE tokens CHANGE userId identifier VARCHAR(128) NOT NULL', [], function (error) {
if (error) console.error(error);
callback(error);
});
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE tokens CHANGE identifier userId VARCHAR(128) NOT NULL', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps DROP COLUMN version', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN version VARCHAR(32)', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps DROP COLUMN healthy, ADD COLUMN health VARCHAR(128)', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps DROP COLUMN health, ADD COLUMN healthy INTEGER', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN lastBackupId VARCHAR(128)', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps DROP COLUMN lastBackupId', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN createdAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps DROP COLUMN createdAt', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,10 +0,0 @@
'use strict';
exports.up = function(db, callback) {
// everyday at 1am
db.runSql('INSERT settings (name, value) VALUES("autoupdate_pattern", ?)', [ '00 00 1 * * *' ], callback);
};
exports.down = function(db, callback) {
db.runSql('DELETE * FROM settings WHERE name="autoupdate_pattern"', [ ], callback);
};
@@ -1,14 +0,0 @@
'use strict';
var safe = require('safetydance');
exports.up = function(db, callback) {
var tz = safe.fs.readFileSync('/etc/timezone', 'utf8');
tz = tz ? tz.trim() : 'America/Los_Angeles';
db.runSql('INSERT settings (name, value) VALUES("time_zone", ?)', [ tz ], callback);
};
exports.down = function(db, callback) {
db.runSql('DELETE * FROM settings WHERE name="time_zone"', [ ], callback);
};
@@ -1,24 +0,0 @@
'use strict';
var async = require('async');
exports.up = function(db, callback) {
// http://stackoverflow.com/questions/386294/what-is-the-maximum-length-of-a-valid-email-address
async.series([
db.runSql.bind(db, 'ALTER TABLE users MODIFY username VARCHAR(254)'),
db.runSql.bind(db, 'ALTER TABLE users ADD CONSTRAINT users_username UNIQUE (username)'),
db.runSql.bind(db, 'ALTER TABLE users MODIFY email VARCHAR(254)'),
db.runSql.bind(db, 'ALTER TABLE users ADD CONSTRAINT users_email UNIQUE (email)'),
], callback);
};
exports.down = function(db, callback) {
async.series([
db.runSql.bind(db, 'ALTER TABLE users DROP INDEX users_username'),
db.runSql.bind(db, 'ALTER TABLE users MODIFY username VARCHAR(512)'),
db.runSql.bind(db, 'ALTER TABLE users DROP INDEX users_email'),
db.runSql.bind(db, 'ALTER TABLE users MODIFY email VARCHAR(512)'),
], callback);
};
@@ -1,17 +0,0 @@
'use strict';
var async = require('async');
exports.up = function(db, callback) {
async.series([
db.runSql.bind(db, 'ALTER TABLE users MODIFY username VARCHAR(254) NOT NULL'),
db.runSql.bind(db, 'ALTER TABLE users MODIFY email VARCHAR(254) NOT NULL'),
], callback);
};
exports.down = function(db, callback) {
async.series([
db.runSql.bind(db, 'ALTER TABLE users MODIFY username VARCHAR(254)'),
db.runSql.bind(db, 'ALTER TABLE users MODIFY email VARCHAR(254)'),
], callback);
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN lastManifestJson VARCHAR(2048)', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps DROP COLUMN lastManifestJson', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps CHANGE lastManifestJson lastBackupConfigJson VARCHAR(2048)', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps CHANGE lastBackupConfigJson lastManifestJson VARCHAR(2048)', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN oldConfigJson VARCHAR(2048)', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps DROP COLUMN oldConfigJson', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,9 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('DELETE FROM settings', [ ], callback);
};
exports.down = function(db, callback) {
callback();
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN oauthProxy BOOLEAN DEFAULT 0', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps DROP COLUMN oauthProxy', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,17 +0,0 @@
'use strict';
var async = require('async');
exports.up = function(db, callback) {
async.series([
db.runSql.bind(db, 'DELETE FROM clients'),
db.runSql.bind(db, 'ALTER TABLE clients ADD COLUMN type VARCHAR(16) NOT NULL'),
], callback);
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE clients DROP COLUMN type', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps CHANGE accessRestriction accessRestrictionJson VARCHAR(2048)', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps CHANGE accessRestrictionJson accessRestriction VARCHAR(2048)', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps MODIFY manifestJson TEXT', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps MODIFY manifestJson VARCHAR(2048)', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,19 +0,0 @@
'use strict';
var async = require('async');
exports.up = function(db, callback) {
async.series([
db.runSql.bind(db, 'ALTER TABLE apps MODIFY accessRestrictionJson TEXT'),
db.runSql.bind(db, 'ALTER TABLE apps MODIFY lastBackupConfigJson TEXT'),
db.runSql.bind(db, 'ALTER TABLE apps MODIFY oldConfigJson TEXT')
], callback);
};
exports.down = function(db, callback) {
async.series([
db.runSql.bind(db, 'ALTER TABLE apps MODIFY accessRestrictionJson VARCHAR(2048)'),
db.runSql.bind(db, 'ALTER TABLE apps MODIFY lastBackupConfigJson VARCHAR(2048)'),
db.runSql.bind(db, 'ALTER TABLE apps MODIFY oldConfigJson VARCHAR(2048)')
], callback);
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE users ADD COLUMN displayName VARCHAR(512) DEFAULT ""', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE users DROP COLUMN displayName', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN memoryLimit BIGINT DEFAULT 0', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps DROP COLUMN memoryLimit', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,20 +0,0 @@
'use strict';
exports.up = function(db, callback) {
var cmd = "CREATE TABLE userGroups(" +
"id VARCHAR(128) NOT NULL UNIQUE," +
"name VARCHAR(128) NOT NULL UNIQUE," +
"PRIMARY KEY(id))";
db.runSql(cmd, function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('DROP TABLE userGroups', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,21 +0,0 @@
'use strict';
exports.up = function(db, callback) {
var cmd = "CREATE TABLE IF NOT EXISTS groupMembers(" +
"groupId VARCHAR(128) NOT NULL," +
"userId VARCHAR(128) NOT NULL," +
"FOREIGN KEY(groupId) REFERENCES userGroups(id)," +
"FOREIGN KEY(userId) REFERENCES users(id));";
db.runSql(cmd, function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('DROP TABLE groupMembers', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,29 +0,0 @@
'use strict';
var async = require('async');
var ADMIN_GROUP_ID = 'admin'; // see constants.js
exports.up = function(db, callback) {
async.series([
db.runSql.bind(db, 'START TRANSACTION;'),
db.runSql.bind(db, 'INSERT INTO userGroups (id, name) VALUES (?, ?)', [ ADMIN_GROUP_ID, 'admin' ]),
function migrateAdminFlag(done) {
db.all('SELECT * FROM users WHERE admin=1', function (error, results) {
if (error) return done(error);
console.dir(results);
async.eachSeries(results, function (r, next) {
db.runSql('INSERT INTO groupMembers (groupId, userId) VALUES (?, ?)', [ ADMIN_GROUP_ID, r.id ], next);
}, done);
});
},
db.runSql.bind(db, 'ALTER TABLE users DROP COLUMN admin'),
db.runSql.bind(db, 'COMMIT')
], callback);
};
exports.down = function(db, callback) {
callback();
};
@@ -1,24 +0,0 @@
'use strict';
exports.up = function(db, callback) {
var cmd = "CREATE TABLE backups(" +
"filename VARCHAR(128) NOT NULL," +
"creationTime TIMESTAMP," +
"version VARCHAR(128) NOT NULL," +
"type VARCHAR(16) NOT NULL," +
"dependsOn VARCHAR(4096)," +
"state VARCHAR(16) NOT NULL," +
"PRIMARY KEY (filename))";
db.runSql(cmd, function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('DROP TABLE backups', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE backups ADD COLUMN configJson TEXT', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE backups DROP COLUMN configJson', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE backups DROP COLUMN configJson', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE backups ADD COLUMN configJson TEXT', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE backups CHANGE filename id VARCHAR(128)', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE backups CHANGE id filename VARCHAR(128)', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE users MODIFY username VARCHAR(254) UNIQUE', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE users MODIFY username VARCHAR(254) NOT NULL UNIQUE', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN altDomain VARCHAR(256)', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps DROP COLUMN altDomain', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,23 +0,0 @@
'use strict';
exports.up = function(db, callback) {
var cmd = "CREATE TABLE eventlog(" +
"id VARCHAR(128) NOT NULL," +
"source TEXT," +
"creationTime TIMESTAMP," +
"action VARCHAR(128) NOT NULL," +
"data TEXT," +
"PRIMARY KEY (id))";
db.runSql(cmd, function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('DROP TABLE eventlog', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE users ADD COLUMN showTutorial BOOLEAN DEFAULT 0', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE users DROP COLUMN showTutorial', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,21 +0,0 @@
'use strict';
exports.up = function(db, callback) {
var cmd = 'CREATE TABLE mailboxes(' +
'name VARCHAR(128) NOT NULL,' +
'aliasTarget VARCHAR(128),' +
'creationTime TIMESTAMP,' +
'PRIMARY KEY (name))';
db.runSql(cmd, function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('DROP TABLE mailboxes', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,26 +0,0 @@
'use strict';
var async = require('async');
// imports mailbox entries for existing users
exports.up = function(db, callback) {
async.series([
db.runSql.bind(db, 'START TRANSACTION;'),
function addUserMailboxes(done) {
db.all('SELECT username FROM users', function (error, results) {
if (error) return done(error);
async.eachSeries(results, function (r, next) {
if (!r.username) return next();
db.runSql('INSERT INTO mailboxes (name) VALUES (?)', [ r.username ], next);
}, done);
});
},
db.runSql.bind(db, 'COMMIT')
], callback);
};
exports.down = function(db, callback) {
callback();
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps DROP COLUMN lastBackupConfigJson', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN lastBackupConfigJson TEXT', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps MODIFY installationProgress TEXT', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps MODIFY installationProgress VARCHAR(512)', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN xFrameOptions VARCHAR(512)', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps DROP COLUMN xFrameOptions', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.all('SELECT id FROM users', function (error, results) {
if (error) return callback(error);
// existing cloudrons have email enabled by default. future cloudrons will have it disabled by default
var enable = results.length !== 0;
db.runSql('INSERT settings (name, value) VALUES("mail_config", ?)', [ JSON.stringify({ enabled: enable }) ], callback);
});
};
exports.down = function(db, callback) {
db.runSql('DELETE * FROM settings WHERE name="mail_config"', [ ], callback);
};
@@ -1,73 +0,0 @@
'use strict';
var async = require('async');
exports.up = function(db, callback) {
async.series([
db.runSql.bind(db, 'ALTER TABLE mailboxes ADD COLUMN ownerId VARCHAR(128)'),
db.runSql.bind(db, 'ALTER TABLE mailboxes ADD COLUMN ownerType VARCHAR(16)'),
db.runSql.bind(db, 'START TRANSACTION;'),
function addGroupMailboxes(done) {
console.log('Importing group mailboxes');
db.all('SELECT id, name FROM userGroups', function (error, results) {
if (error) return done(error);
async.eachSeries(results, function (g, next) {
db.runSql('INSERT INTO mailboxes (ownerId, ownerType, name) VALUES (?, ?, ?)', [ g.id, 'group', g.name ], function (error) {
if (error) console.error('Error importing group ' + JSON.stringify(g) + error);
next();
});
}, done);
});
},
function addAppMailboxes(done) {
console.log('Importing app mail boxes');
db.all('SELECT id, location, manifestJson FROM apps', function (error, results) {
if (error) return done(error);
async.eachSeries(results, function (a, next) {
var manifest = JSON.parse(a.manifestJson);
if (!manifest.addons['sendmail'] && !manifest.addons['recvmail']) return next();
var mailboxName = (a.location ? a.location : manifest.title.replace(/[^a-zA-Z0-9]/g, '')) + '.app';
db.runSql('INSERT INTO mailboxes (ownerId, ownerType, name) VALUES (?, ?, ?)', [ a.id, 'app', mailboxName ], function (error) {
if (error) console.error('Error importing app ' + JSON.stringify(a) + error);
next();
});
}, done);
});
},
function setUserMailboxOwnerIds(done) {
console.log('Setting owner id of user mailboxes and aliases');
db.all('SELECT id, username FROM users', function (error, results) {
if (error) return done(error);
async.eachSeries(results, function (u, next) {
if (!u.username) return next();
db.runSql('UPDATE mailboxes SET ownerId = ?, ownerType = ? WHERE name = ? OR aliasTarget = ?', [ u.id, 'user', u.username, u.username ], function (error) {
if (error) console.error('Error setting ownerid ' + JSON.stringify(u) + error);
next();
});
}, done);
});
},
db.runSql.bind(db, 'COMMIT'),
db.runSql.bind(db, 'ALTER TABLE mailboxes MODIFY ownerId VARCHAR(128) NOT NULL'),
db.runSql.bind(db, 'ALTER TABLE mailboxes MODIFY ownerType VARCHAR(128) NOT NULL'),
], callback);
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE mailboxes DROP COLUMN ownerId', function (error) {
if (error) console.error(error);
db.runSql('ALTER TABLE mailboxes DROP COLUMN ownerType', function (error) {
if (error) console.error(error);
callback(error);
});
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN sso BOOLEAN DEFAULT 1', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps DROP COLUMN sso', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps DROP COLUMN oauthProxy', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN oauthProxy BOOLEAN DEFAULT 0', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE users DROP COLUMN showTutorial', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE users ADD COLUMN showTutorial BOOLEAN DEFAULT 0', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN debugModeJson TEXT', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps DROP COLUMN debugModeJson ', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE backups MODIFY dependsOn TEXT', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE backups MODIFY dependsOn VARCHAR(4096)', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,16 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE appAddonConfigs ADD COLUMN name VARCHAR(128)', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE appAddonConfigs DROP COLUMN name', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,14 +0,0 @@
'use strict';
var url = require('url');
exports.up = function(db, callback) {
var dbName = url.parse(process.env.DATABASE_URL).path.substr(1); // remove slash
// by default, mysql collates case insensitively. 'utf8_general_cs' is not available
db.runSql('ALTER DATABASE ' + dbName + ' DEFAULT CHARACTER SET=utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci', callback);
};
exports.down = function(db, callback) {
callback();
};
@@ -1,95 +0,0 @@
'use strict';
var async = require('async');
// from apps.js DO NOT UPDATE WHEN apps.js changes, as this is part of db migration!!
function postProcess(result) {
try {
result.manifest = JSON.parse(result.manifestJson);
delete result.manifestJson;
result.oldConfig = JSON.parse(result.oldConfigJson);
delete result.oldConfigJson;
result.portBindings = { };
var hostPorts = result.hostPorts === null ? [ ] : result.hostPorts.split(',');
var environmentVariables = result.environmentVariables === null ? [ ] : result.environmentVariables.split(',');
delete result.hostPorts;
delete result.environmentVariables;
for (var i = 0; i < environmentVariables.length; i++) {
result.portBindings[environmentVariables[i]] = parseInt(hostPorts[i], 10);
}
result.accessRestriction = JSON.parse(result.accessRestrictionJson);
if (result.accessRestriction && !result.accessRestriction.users) result.accessRestriction.users = [];
delete result.accessRestrictionJson;
// TODO remove later once all apps have this attribute
result.xFrameOptions = result.xFrameOptions || 'SAMEORIGIN';
result.sso = !!result.sso; // make it bool
result.debugMode = JSON.parse(result.debugModeJson);
delete result.debugModeJson;
} catch (e) {
console.error('Failed to get restoreConfig for app.', e);
console.error('Falling back to empty values to make the update succeed.');
result.manifest = null;
}
}
// from apps.js DO NOT UPDATE WHEN apps.js changes, as this is part of db migration!!
var APPS_FIELDS_PREFIXED = [ 'apps.id', 'apps.appStoreId', 'apps.installationState', 'apps.installationProgress', 'apps.runState',
'apps.health', 'apps.containerId', 'apps.manifestJson', 'apps.httpPort', 'apps.location', 'apps.dnsRecordId',
'apps.accessRestrictionJson', 'apps.lastBackupId', 'apps.oldConfigJson', 'apps.memoryLimit', 'apps.altDomain',
'apps.xFrameOptions', 'apps.sso', 'apps.debugModeJson' ].join(',');
exports.up = function(db, callback) {
async.series([
db.runSql.bind(db, 'ALTER TABLE backups ADD COLUMN restoreConfigJson TEXT'),
// fill all the backups with restoreConfigs from current apps
function addRestoreConfigs(callback) {
console.log('Importing restoreConfigs');
var appQuery = 'SELECT ' + APPS_FIELDS_PREFIXED + ',' +
'GROUP_CONCAT(CAST(appPortBindings.hostPort AS CHAR(6))) AS hostPorts, GROUP_CONCAT(appPortBindings.environmentVariable) AS environmentVariables' +
' FROM apps LEFT OUTER JOIN appPortBindings ON apps.id = appPortBindings.appId' +
' GROUP BY apps.id ORDER BY apps.id';
db.all(appQuery, function (error, apps) {
if (error) return callback(error);
apps.forEach(postProcess);
async.eachSeries(apps, function (app, next) {
if (app.manifest === null) return next();
db.all('SELECT * FROM backups WHERE type="app" AND id LIKE "%app%\\_' + app.id + '\\_%"', function (error, backups) {
if (error) return next(error);
// from apps.js:getAppConfig()
var restoreConfig = {
manifest: app.manifest,
location: app.location,
accessRestriction: app.accessRestriction,
portBindings: app.portBindings,
memoryLimit: app.memoryLimit,
xFrameOptions: app.xFrameOptions || 'SAMEORIGIN',
altDomain: app.altDomain
};
async.eachSeries(backups, function (backup, next) {
db.runSql('UPDATE backups SET restoreConfigJson=?,creationTime=creationTime WHERE id=?', [ JSON.stringify(restoreConfig), backup.id ], next);
}, next);
});
}, callback);
});
}
], callback);
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE backups DROP COLUMN restoreConfigJson', callback);
};
@@ -1,22 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.all('SELECT value FROM settings WHERE name="backup_config"', function (error, results) {
if (error || results.length === 0) return callback(error);
var backupConfig = JSON.parse(results[0].value);
if (backupConfig.provider === 'filesystem') {
backupConfig.retentionSecs = 2 * 24 * 60 * 60; // 2 days
} else if (backupConfig.provider === 's3') { // S3
backupConfig.retentionSecs = -1;
} else if (backupConfig.provider === 'caas') {
backupConfig.retentionSecs = 10 * 24 * 60 * 60; // 10 days
}
db.runSql('UPDATE settings SET value=? WHERE name="backup_config"', [ JSON.stringify(backupConfig) ], callback);
});
};
exports.down = function(db, callback) {
callback();
};
@@ -1,9 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('INSERT settings (name, value) VALUES("mail_relay", ?)', [ JSON.stringify({ provider: 'cloudron-smtp' }) ], callback);
};
exports.down = function(db, callback) {
db.runSql('DELETE * FROM settings WHERE name="mail_relay"', [ ], callback);
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN robotsTxt TEXT', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps DROP COLUMN robotsTxt', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,29 +0,0 @@
'use strict';
// we used to have JSON as the db type for those two, however mariadb does not support it
// and we never used any JSON related features, but have the TEXT pattern everywhere
// This ensures all old cloudrons will have the columns altered
exports.up = function(db, callback) {
db.runSql('ALTER TABLE eventlog MODIFY data TEXT', [], function (error) {
if (error) console.error(error);
db.runSql('ALTER TABLE eventlog MODIFY source TEXT', [], function (error) {
if (error) console.error(error);
callback(error);
});
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE eventlog MODIFY data TEXT', [], function (error) {
if (error) console.error(error);
db.runSql('ALTER TABLE eventlog MODIFY source TEXT', [], function (error) {
if (error) console.error(error);
callback(error);
});
});
};
@@ -1,16 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN enableBackup BOOLEAN DEFAULT 1', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps DROP COLUMN enableBackup', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE settings MODIFY value TEXT', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE settings MODIFY value VARCHAR(512)', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,25 +0,0 @@
'use strict';
// ensure backupFolder and format are not empty
exports.up = function(db, callback) {
db.all('SELECT * FROM settings WHERE name=?', [ 'backup_config' ], function (error, result) {
if (error || result.length === 0) return callback(error);
var value = JSON.parse(result[0].value);
value.format = 'tgz'; // set the format
if (value.provider === 'filesystem' && !value.backupFolder) {
value.backupFolder = '/var/backups'; // set the backupFolder
}
db.runSql('UPDATE settings SET value = ? WHERE name = ?', [ JSON.stringify(value), 'backup_config' ], function (error) {
if (error) console.error('Error setting ownerid ' + JSON.stringify(u) + error);
callback();
});
});
};
exports.down = function(db, callback) {
callback();
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE backups ADD COLUMN format VARCHAR(16) DEFAULT "tgz"', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE backups DROP COLUMN format', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN newConfigJson TEXT', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps DROP COLUMN newConfigJson', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,40 +0,0 @@
'use strict';
var async = require('async');
exports.up = function(db, callback) {
async.series([
db.runSql.bind(db, 'ALTER TABLE backups ADD COLUMN manifestJson TEXT'),
db.runSql.bind(db, 'START TRANSACTION;'),
// fill all the backups with restoreConfigs from current apps
function addManifests(callback) {
console.log('Importing manifests');
db.all('SELECT * FROM backups WHERE type="app"', function (error, backups) {
if (error) return callback(error);
async.eachSeries(backups, function (backup, next) {
var m = backup.restoreConfigJson ? JSON.parse(backup.restoreConfigJson) : null;
if (m) m = JSON.stringify(m.manifest);
db.runSql('UPDATE backups SET manifestJson=? WHERE id=?', [ m, backup.id ], next);
}, callback);
});
},
db.runSql.bind(db, 'COMMIT'),
// remove the restoreConfig
db.runSql.bind(db, 'ALTER TABLE backups DROP COLUMN restoreConfigJson')
], callback);
};
exports.down = function(db, callback) {
async.series([
db.runSql.bind(db, 'ALTER TABLE backups DROP COLUMN manifestJson'),
db.runSql.bind(db, 'ALTER TABLE backups ADD COLUMN restoreConfigJson TEXT'),
], callback);
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps CHANGE newConfigJson updateConfigJson TEXT', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps CHANGE updateConfigJson newConfigJson TEXT', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps CHANGE lastBackupId restoreConfigJson TEXT', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps CHANGE restoreConfigJson lastBackupId TEXT', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,31 +0,0 @@
'use strict';
// WARNING!!
// At this point the default db collation is utf8mb4_unicode_ci however we already have foreign key constraits
// already with tables on utf8_bin charset, so we cannot convert all tables here to utf8mb4 collation without
// a reimport from a sql dump, as foreign keys across different collations are not supported
var async = require('async');
exports.up = function(db, callback) {
async.series([
db.runSql.bind(db, 'ALTER TABLE appPortBindings CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin'),
db.runSql.bind(db, 'ALTER TABLE apps CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin'),
db.runSql.bind(db, 'ALTER TABLE authcodes CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin'),
db.runSql.bind(db, 'ALTER TABLE backups CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin'),
db.runSql.bind(db, 'ALTER TABLE clients CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin'),
db.runSql.bind(db, 'ALTER TABLE eventlog CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin'),
db.runSql.bind(db, 'ALTER TABLE groupMembers CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin'),
db.runSql.bind(db, 'ALTER TABLE userGroups CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin'),
db.runSql.bind(db, 'ALTER TABLE mailboxes CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin'),
db.runSql.bind(db, 'ALTER TABLE migrations CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin'),
db.runSql.bind(db, 'ALTER TABLE settings CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin'),
db.runSql.bind(db, 'ALTER TABLE tokens CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin'),
db.runSql.bind(db, 'ALTER TABLE users CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin')
], callback);
};
exports.down = function(db, callback) {
// nothing to be done here
callback();
};
@@ -1,70 +0,0 @@
'use strict';
var async = require('async'),
safe = require('safetydance');
exports.up = function(db, callback) {
// first check precondtion of domain entry in settings
db.all('SELECT * FROM settings WHERE name = ?', [ 'domain' ], function (error, result) {
if (error) return callback(error);
var domain = {};
if (result[0]) domain = safe.JSON.parse(result[0].value) || {};
async.series([
db.runSql.bind(db, 'START TRANSACTION;'),
function addAppsDomainColumn(done) {
db.runSql('ALTER TABLE apps ADD COLUMN domain VARCHAR(128)', [], done);
},
function setAppDomain(done) {
if (!domain.fqdn) return done(); // skip for new cloudrons without a domain
db.runSql('UPDATE apps SET domain = ?', [ domain.fqdn ], done);
},
function addAppsLocationDomainUniqueConstraint(done) {
db.runSql('ALTER TABLE apps ADD UNIQUE location_domain_unique_index (location, domain)', [], done);
},
function removePresetupAdminGroupIfNew(done) {
// do not delete on update, will update the record in setMailboxesDomain()
if (domain.fqdn) return done();
// this will be finally created once we have a domain when we create the owner in user.js
const ADMIN_GROUP_ID = 'admin'; // see constants.js
db.runSql('DELETE FROM userGroups WHERE id = ?', [ ADMIN_GROUP_ID ], function (error) {
if (error) return done(error);
db.runSql('DELETE FROM mailboxes WHERE ownerId = ?', [ ADMIN_GROUP_ID ], done);
});
},
function addMailboxesDomainColumn(done) {
db.runSql('ALTER TABLE mailboxes ADD COLUMN domain VARCHAR(128)', [], done);
},
function setMailboxesDomain(done) {
if (!domain.fqdn) return done(); // skip for new cloudrons without a domain
db.runSql('UPDATE mailboxes SET domain = ?', [ domain.fqdn ], done);
},
function dropAppsLocationUniqueConstraint(done) {
db.runSql('ALTER TABLE apps DROP INDEX location', [], done);
},
db.runSql.bind(db, 'COMMIT')
], callback);
});
};
exports.down = function(db, callback) {
async.series([
db.runSql.bind(db, 'START TRANSACTION;'),
function dropMailboxesDomainColumn(done) {
db.runSql('ALTER TABLE mailboxes DROP COLUMN domain', [], done);
},
function dropLocationDomainUniqueConstraint(done) {
db.runSql('ALTER TABLE apps DROP INDEX location_domain_unique_index', [], done);
},
function dropAppsDomainColumn(done) {
db.runSql('ALTER TABLE apps DROP COLUMN domain', [], done);
},
function addAppsLocationUniqueConstraint(done) {
db.runSql('ALTER TABLE apps ADD UNIQUE location (location)', [], done);
},
db.runSql.bind(db, 'COMMIT')
], callback);
};
@@ -1,61 +0,0 @@
'use strict';
var async = require('async'),
safe = require('safetydance'),
tld = require('tldjs');
exports.up = function(db, callback) {
var fqdn, zoneName, configJson;
async.series([
function gatherDomain(done) {
db.all('SELECT * FROM settings WHERE name = ?', [ 'domain' ], function (error, result) {
if (error) return done(error);
var domain = {};
if (result[0]) domain = safe.JSON.parse(result[0].value) || {};
fqdn = domain.fqdn || ''; // will be null pre-setup
zoneName = domain.zoneName || tld.getDomain(fqdn) || fqdn;
done();
});
},
function gatherDNSConfig(done) {
db.all('SELECT * FROM settings WHERE name = ?', [ 'dns_config' ], function (error, result) {
if (error) return done(error);
configJson = (result[0] && result[0].value) ? result[0].value : JSON.stringify({ provider: 'manual'});
// caas dns config needs an fqdn
var config = JSON.parse(configJson);
if (config.provider === 'caas') config.fqdn = fqdn;
configJson = JSON.stringify(config);
done();
});
},
db.runSql.bind(db, 'START TRANSACTION;'),
function createDomainsTable(done) {
var cmd = `
CREATE TABLE domains(
domain VARCHAR(128) NOT NULL UNIQUE,
zoneName VARCHAR(128) NOT NULL,
configJson TEXT,
PRIMARY KEY (domain)) CHARACTER SET utf8 COLLATE utf8_bin
`;
db.runSql(cmd, [], done);
},
function addInitialDomain(done) {
if (!fqdn) return done();
db.runSql('INSERT INTO domains (domain, zoneName, configJson) VALUES (?, ?, ?)', [ fqdn, zoneName, configJson ], done);
},
db.runSql.bind(db, 'COMMIT')
], callback);
};
exports.down = function(db, callback) {
db.runSql('DROP TABLE domains', callback);
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD CONSTRAINT apps_domain_constraint FOREIGN KEY(domain) REFERENCES domains(domain)', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps DROP FOREIGN KEY apps_domain_constraint', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE mailboxes ADD CONSTRAINT mailboxes_domain_constraint FOREIGN KEY(domain) REFERENCES domains(domain)', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE mailboxes DROP FOREIGN KEY mailboxes_domain_constraint', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE mailboxes DROP PRIMARY KEY', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE mailboxes ADD PRIMARY KEY(name)', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE mailboxes ADD UNIQUE mailboxes_name_domain_unique_index (name, domain)', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE mailboxes DROP INDEX mailboxes_name_domain_unique_index', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN updateTime TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP', function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps DROP COLUMN updateTime', function (error) {
if (error) console.error(error);
callback(error);
});
};
@@ -1,15 +0,0 @@
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps CHANGE createdAt creationTime TIMESTAMP(2) NOT NULL', [], function (error) {
if (error) console.error(error);
callback(error);
});
};
exports.down = function(db, callback) {
db.runSql('ALTER TABLE apps CHANGE creationTime createdAt TIMESTAMP(2) NOT NULL', [], function (error) {
if (error) console.error(error);
callback(error);
});
};

Some files were not shown because too many files have changed in this diff Show More