Compare commits

..

699 Commits

Author SHA1 Message Date
Johannes Zellner a50409bdca Also show errors above input fields for password reset 2017-03-20 16:50:31 +01:00
Johannes Zellner 60a722e6cc Remove superflous quote in html 2017-03-20 16:43:36 +01:00
Johannes Zellner 4d6cafa589 Show form errors on the top during user activation 2017-03-20 15:57:02 +01:00
Johannes Zellner 63e557430b ng-href takes a template string 2017-03-20 15:26:31 +01:00
Johannes Zellner 04acb4423d Add open registration rest api tests 2017-03-20 14:27:47 +01:00
Johannes Zellner ea813acf4c Add open registration default value and test 2017-03-20 14:27:39 +01:00
Johannes Zellner b1198dfdbf Add settingsdb tests for open registration 2017-03-20 14:22:11 +01:00
Johannes Zellner 4342de3747 Show error response on signup 2017-03-20 14:19:52 +01:00
Johannes Zellner ef8bc7e7e9 username must be null or non-empty string 2017-03-20 14:01:12 +01:00
Johannes Zellner e18e401f6b Improve signup form 2017-03-20 14:00:56 +01:00
Johannes Zellner ab998c47e8 Show user signup link if registration is open 2017-03-20 13:52:31 +01:00
Johannes Zellner 9fb830b2e1 add section to toggle open registration in settings view 2017-03-20 12:55:48 +01:00
Johannes Zellner 415c3f90a1 Always send an object with properties 2017-03-20 12:53:21 +01:00
Johannes Zellner 60c8ff7fb1 Add open_registration settings routes 2017-03-20 12:31:53 +01:00
Johannes Zellner 037816313c Remove newline 2017-03-20 12:29:15 +01:00
Johannes Zellner 3d285d1ac6 Better signup styling 2017-03-20 12:04:23 +01:00
Johannes Zellner 135338786f Protect user creation if open registration is not allowed 2017-03-20 12:00:58 +01:00
Johannes Zellner 661f1fce31 Angular uses double curly brackets 2017-03-20 11:58:01 +01:00
Johannes Zellner 03664ef784 Add open registration setting 2017-03-20 11:56:58 +01:00
Johannes Zellner d2111ef2b6 Add user signup ui 2017-03-20 11:52:11 +01:00
Johannes Zellner e0df19c888 Remove unused api wrapper for getAppLogStream() 2017-03-20 10:46:27 +01:00
Girish Ramakrishnan 6a523606ca Revert "Bump version to Nginx IPv6 support."
This reverts commit 5555321cf5.
This reverts commit f087ebbee0.
This reverts commit d04f64d3d4.

Part of #264
2017-03-19 14:25:30 -07:00
Girish Ramakrishnan b6cd40e63c Use latest manifestformat 2017-03-19 14:20:00 -07:00
Girish Ramakrishnan b421866bf5 Remove simpleauth
Simple Auth used to provide auth over HTTP. The original motivation
behind this was this was a simple way to add Cloudron Auth integration.
Back in the day, Cloudron Auth was a requirement for apps but this is
not the case anymore.

This is currently not used by any app and having this might encourage
people to make Cloudron specific un-upstreamable changes.
2017-03-19 01:31:38 -07:00
Girish Ramakrishnan fe06075816 more CHANGES 2017-03-17 13:49:47 -07:00
Girish Ramakrishnan 2b73eb90ec Merge branch 'ipv6' into 'master'
Add IPv6 Support

See merge request !3
2017-03-17 19:55:30 +00:00
Jonah Aragon 5555321cf5 Bump version to Nginx IPv6 support. 2017-03-17 19:43:54 +00:00
Jonah Aragon f087ebbee0 Add listen [::]:80; for IPv6 redirects. 2017-03-17 19:13:18 +00:00
Jonah Aragon d04f64d3d4 Add IPv6 listen directives 2017-03-17 19:12:25 +00:00
Girish Ramakrishnan 777a5a0929 Add 0.106.0 changes 2017-03-17 10:23:17 -07:00
Girish Ramakrishnan 6c297f890e Bump mail container 2017-03-17 10:23:17 -07:00
Johannes Zellner 3c8d0b1b37 Never hide the busy state on setup when it suceeded
In that case the whole page gets redirected and to avoid page flickering
we keep it at busy until the browser tears the whole page apart.
2017-03-16 09:58:21 +01:00
Johannes Zellner 74f2cd156f Only send setupToken on admin creation if it was actually specified 2017-03-16 09:37:28 +01:00
Girish Ramakrishnan a9fdffa9af 0.105.1 changes 2017-03-15 21:15:15 -07:00
Girish Ramakrishnan e6f8e8eb94 ami field is only required if shown 2017-03-15 21:10:22 -07:00
Girish Ramakrishnan 1bd89ca055 Wait for platform ready after box restarts
This is required for the case where the box restarts apptasks.
For example, the server can reboot mid-way when apptask is running
(as in cloudron-setup + appBundle case) and then when it comes back
up it doesn't wait for the platform to be ready. And the apps fail
to install (mysql takes a bit to startup)
2017-03-15 20:35:44 -07:00
Girish Ramakrishnan 0e226d0314 Download icon (for repair case) 2017-03-15 20:35:44 -07:00
Girish Ramakrishnan e8d4e2c792 send more logs 2017-03-15 19:35:42 -07:00
Girish Ramakrishnan 4cfbed8273 Use inline docker pgp key
The one from keyserver keeps failing sporadically

https://github.com/docker/docker/issues/13555
https://github.com/docker/docker/issues/20022
http://askubuntu.com/questions/720517/key-server-times-out-while-installing-docker-on-ubuntu-14-04
2017-03-15 18:04:44 -07:00
Girish Ramakrishnan 0410ac9780 doc: activate api 2017-03-15 16:14:25 -07:00
Girish Ramakrishnan 82fcf6a770 setupToken is not required in activate 2017-03-15 15:55:31 -07:00
Girish Ramakrishnan a1332865c0 Fix wording (should be prove otherwise) 2017-03-15 15:42:06 -07:00
Girish Ramakrishnan ae0e4de93e No semicolons in bash code 2017-03-15 15:40:43 -07:00
Johannes Zellner 02a6525558 Add changes for 0.105.0 2017-03-15 14:56:35 +01:00
Girish Ramakrishnan 5afef14760 Actually send emails for responsive apps 2017-03-14 13:42:28 -07:00
Johannes Zellner 890d589a36 Do not show Route53 in dns setup for AMIs 2017-03-14 16:54:46 +01:00
Johannes Zellner 89a50c4b83 Use ami provider in ami creation script 2017-03-14 13:48:11 +01:00
Johannes Zellner da5cd2b62c Show instance id input on cloudron setup for amis 2017-03-14 13:45:18 +01:00
Johannes Zellner 57321624aa Add ami setupToken verification in auth route 2017-03-14 13:45:04 +01:00
Johannes Zellner 876ae822b2 Skip splash setup if cloudron domain was not yet setup
This is based on the existence of admin.conf nginx file.
The splash would create/overwrite that file, but it will depend on the
host.cert to be already created, which is only the case after domain
setup.
2017-03-14 10:58:24 +01:00
Johannes Zellner 1ceb75868b Remove last remainder of apidocs 2017-03-14 10:12:17 +01:00
Johannes Zellner 98ad16f943 Remove unused requires 2017-03-14 10:10:59 +01:00
Johannes Zellner 9363746c1a Use ec2 sysinfo for ami provider 2017-03-14 09:34:39 +01:00
Johannes Zellner 7a1b9ab94c Support ami provider for ssh authorized_keys api 2017-03-14 09:34:11 +01:00
Johannes Zellner 46d6b5b81f Add hidden 'ami' provider for pre-built amis 2017-03-14 09:32:51 +01:00
Girish Ramakrishnan 7e8757a78c grep quietly 2017-03-13 13:52:16 -07:00
Girish Ramakrishnan e508b25ecd Lower memory expectations 2017-03-13 13:05:59 -07:00
Girish Ramakrishnan 3fdc10c523 Parse free and fdisk output with C locale
some vps providers seem to set a different locale by default.
Settings LC_ALL overrides all the other LC_*
2017-03-13 10:36:05 -07:00
Johannes Zellner 717953c162 Half the backup progress polling 2017-03-13 13:28:14 +01:00
Johannes Zellner daa34c3b4d add some asserts in the ldap code 2017-03-13 11:10:08 +01:00
Johannes Zellner bf5c78d819 Refactor ldap user listing code to avoid pyramids 2017-03-13 11:09:12 +01:00
Johannes Zellner 1763144278 Only list users in ldap groups who have access to the app
Fixes #215
2017-03-13 11:06:29 +01:00
Johannes Zellner 2f598529fc Only list users who have access to the app in an ldap search
Part of #215
2017-03-13 11:02:45 +01:00
Girish Ramakrishnan 8264e69e2f remove unused require 2017-03-10 14:52:31 -08:00
Johannes Zellner b0638df94e Only show the remote support for admins 2017-03-10 17:21:01 +01:00
Johannes Zellner bb61eee557 Add missing quote in support view 2017-03-10 17:17:51 +01:00
Johannes Zellner 39c39b861d Require admins for authorized_keys route 2017-03-10 17:16:45 +01:00
Girish Ramakrishnan e3deda4ef3 Always show port 25 status 2017-03-09 16:21:47 -08:00
Girish Ramakrishnan 7e44e7de82 Check outbound port 25
Fixes #243
2017-03-09 16:20:53 -08:00
Girish Ramakrishnan 9dd0518c00 Show email settings for non-caas
This is because people can use route53/DO now and we can show them
the RDNS settings as well.
2017-03-09 15:21:43 -08:00
Girish Ramakrishnan 81313d1c40 reduce nxdomain caching timeout
the other option is to use "/usr/sbin/unbound-control flush_negative"
on demand
2017-03-09 15:03:14 -08:00
Girish Ramakrishnan 2ceccc4557 Add note for caas users about enabling email 2017-03-09 14:25:03 -08:00
Girish Ramakrishnan 1c36918e92 Done -> Almost done 2017-03-09 10:21:52 -08:00
Girish Ramakrishnan 8d93df23c1 doc: cnameTarget 2017-03-09 10:00:42 -08:00
Johannes Zellner 0c06b34a2c Add more changes for 0.104.0 2017-03-09 15:38:09 +01:00
Johannes Zellner fe980eab7f Show either cnameTarget or fqdn for CNAME setup hint
Fixes #101
2017-03-09 15:23:17 +01:00
Johannes Zellner 979b903bf2 Add cnameTarget for apps using an external domain
We have 4 properties related to the domain:
1) location, is the subdomain location without information how to craft
a fqdn on the client
2) fqdn, the intended domain to reach the app
3) altDomain, just the value for the external domain, merely a db record
value
4) cnameTarget, mostly for display purpose on the client, which
otherwise has no way to build the original cloudron local fqdn
2017-03-09 15:11:27 +01:00
Johannes Zellner 4b8ee0934a Add Cloudron cancel link to the settings view
Fixes #251
2017-03-09 13:36:29 +01:00
Girish Ramakrishnan 0439725790 Bump infra version 2017-03-08 22:27:41 -08:00
Girish Ramakrishnan 4b3ef33989 Add some basic secure headers
Part of #249
2017-03-08 22:14:44 -08:00
Girish Ramakrishnan 9e99d51853 do not remote support for caas 2017-03-08 16:15:13 -08:00
Girish Ramakrishnan 00a9fa8f34 fix wording a bit 2017-03-08 16:11:45 -08:00
Girish Ramakrishnan 84a35343d1 Display <sso> and <nosso> contents based on SSO 2017-03-08 15:16:15 -08:00
Girish Ramakrishnan 397bd17c55 update showdown to 1.6.4 2017-03-08 15:01:07 -08:00
Girish Ramakrishnan c8e377a9bd doc: scaleway may need reboot for security group to take effect 2017-03-08 10:34:12 -08:00
Johannes Zellner 90e3138bae Show the correct postInstall message after app installation
Fixes #255
2017-03-08 15:42:29 +01:00
Girish Ramakrishnan 24b32a763b Add comments for CLI tool 2017-03-07 12:44:17 -08:00
Johannes Zellner 69a12d36ef Also give lightsail the special user treatment 2017-03-07 16:51:58 +01:00
Johannes Zellner 1485718fa6 Special treatment for ec2 and authorized_key user 2017-03-07 16:44:04 +01:00
Johannes Zellner 750f03d9de Add the public key of our support ssh key 2017-03-07 16:13:48 +01:00
Johannes Zellner b5ddf1d24d Add ssh support toggle button in the support view 2017-03-07 16:12:00 +01:00
Johannes Zellner 043a35111d Remove unused requires in ssh test 2017-03-07 16:11:21 +01:00
Johannes Zellner 676457b589 Add authorized_key wrappers to client.js 2017-03-07 16:07:25 +01:00
Johannes Zellner e61f11be81 Since we need root to save the authorized_key file we do it via sudo script 2017-03-07 15:16:41 +01:00
Johannes Zellner 101a44affd Add authorized_keys.sh 2017-03-07 15:16:18 +01:00
Johannes Zellner 7995c664ed Add shell.sudoSync() 2017-03-07 15:14:37 +01:00
Johannes Zellner 6023c0e5dc Ensure the authorized_file permissions are correct 2017-03-07 14:39:14 +01:00
Johannes Zellner d49d76c1ee add ssh route tests and fixup the code accordingly 2017-03-07 14:12:25 +01:00
Johannes Zellner 77ef212daa Add SSH authorized_keys routes 2017-03-07 13:16:28 +01:00
Johannes Zellner 7aa80193c0 Add more changes 2017-03-06 10:47:36 +01:00
Johannes Zellner 5632c74556 Add isadmin ldap attribute
Fixes #241
2017-03-06 10:45:50 +01:00
Girish Ramakrishnan 7a08745af1 doc: add the 20gb requirement 2017-03-05 18:31:31 -08:00
Girish Ramakrishnan d9ba0858c7 Add 0.103.1 changes 2017-03-03 09:42:31 -08:00
Johannes Zellner 617e51d294 Adjust the oom notification email 2017-03-03 11:04:48 +01:00
Johannes Zellner c07d322fff Do not send ldap records for users without a username set
If an app relies on the attribute to be set, apps like owncloud would
fail internally.
2017-03-03 10:18:38 +01:00
Girish Ramakrishnan 9b8fa8a772 doc: sso 2017-03-02 15:15:15 -08:00
Girish Ramakrishnan c351242af7 lie about the time if it is ahead of us
Fixes #247
2017-03-02 14:34:18 -08:00
Johannes Zellner 55245557f5 Use the new app login event in the webadmin
Part of #247
2017-03-02 17:15:01 +01:00
Johannes Zellner ee1cef3ee8 Add new event type for app mailbox ldap login 2017-03-02 17:13:19 +01:00
Girish Ramakrishnan 5d51a7178f domain migrate: Add text that subdomains are not supported 2017-03-01 15:45:37 -08:00
Girish Ramakrishnan 9d52397bcc Move dhparam creation
Now that all cloudrons have the dhparams file, we can generate this
*after* restoring from backup and if required.
2017-03-01 15:25:20 -08:00
Girish Ramakrishnan 5098fbe061 Version 0.103.0 changes 2017-03-01 13:08:49 -08:00
Girish Ramakrishnan 7062aa4ac7 use test image 19.0.1 2017-02-28 20:21:02 -08:00
Girish Ramakrishnan d6fec4f2b9 alertsTo must be an array 2017-02-28 18:17:17 -08:00
Girish Ramakrishnan 86ef462c76 doc: add email/recvmail to allowed addon keys 2017-02-27 06:51:54 -08:00
Girish Ramakrishnan c76e7a3f63 randomize the cn in ip based cert
Fixes #224
2017-02-25 15:38:15 -08:00
Girish Ramakrishnan 2516a08659 remove reference to npm-demo from manifest 2017-02-25 13:36:27 -08:00
Girish Ramakrishnan 562fe30333 Update cloudron-manifestformat
adds the upcoming tls addon
2017-02-24 22:13:28 -08:00
Girish Ramakrishnan 4e0eed4bb2 make tests pass 2017-02-24 21:48:38 -08:00
Girish Ramakrishnan b604caec72 Get rid of x509 module
This is the last of the "native" modules. These modules take forever
to rebuild in low memory machines
2017-02-24 21:01:48 -08:00
Girish Ramakrishnan 6b409e9089 Do not send crash logs to support in self-hosted case
Fixes #242
2017-02-24 10:40:51 -08:00
Girish Ramakrishnan 015d434358 remove unused require 2017-02-24 10:39:03 -08:00
Girish Ramakrishnan c8e448cb84 Remove support@cloudron.io in app died mails
part of #242
2017-02-24 10:36:48 -08:00
Girish Ramakrishnan 03924be491 self-hosted: do not cc support for bounce mails from apps
part of #242
2017-02-24 10:34:07 -08:00
Girish Ramakrishnan 2729cecf4a self-hosting: remove support@cloudron.io frmo oom mails, cert renewal and backup failure mails
Part of #242
2017-02-24 10:25:20 -08:00
Girish Ramakrishnan 32e2377828 sysinfo: getIp -> getPublicIp 2017-02-23 22:03:48 -08:00
Girish Ramakrishnan fdb8139b03 createAMI: better help text 2017-02-23 15:44:56 -08:00
Girish Ramakrishnan 4b25c8a5ad Add 0.102.1 changes 2017-02-23 11:08:15 -08:00
Girish Ramakrishnan ae930a7fe8 dns setup: fix wording a bit 2017-02-23 10:57:05 -08:00
Johannes Zellner 3b9144ba4d Alter the backups.dependsOn field to store as TEXT
Fixes #239
2017-02-23 17:56:34 +01:00
Johannes Zellner be6ea3d4c1 Add rosehosting to selfhosting docs 2017-02-22 16:02:03 +01:00
Girish Ramakrishnan a2983e58b5 doc: typo 2017-02-21 11:24:25 -08:00
Girish Ramakrishnan a99e86a5df doc: fix wording on base image a bit 2017-02-21 11:16:10 -08:00
Girish Ramakrishnan 906ad80069 Add terms link 2017-02-20 15:59:40 -08:00
Girish Ramakrishnan ac65f765e5 doc: emphasize the traffic mgmt bit 2017-02-20 14:58:27 -08:00
Girish Ramakrishnan c5bfe82315 more 0.102.0 changes 2017-02-20 14:13:53 -08:00
Girish Ramakrishnan 7035b3c18a Fix issue where redis is unable to write on re-configure
The configure code path now ensures the volume which ends up
changing the ownership of the data directory. This means that the
redis container which is still running cannot write anymore
when it is re-created as part of setupAddons().

Just change ownership of top level directory. The subdirectores
like data/ redis/ are owned by containers which will chown
accordingly.
2017-02-20 13:32:05 -08:00
Girish Ramakrishnan 2108c61d97 Send machine info as part of alive status 2017-02-20 13:13:25 -08:00
Johannes Zellner 2bdbb47286 Fix crash when a user does not yet have an username 2017-02-20 21:59:16 +01:00
Johannes Zellner 333b8970b8 Add rosehosting afiliate link 2017-02-20 14:42:22 +01:00
Girish Ramakrishnan 5673cfe2be bump version 2017-02-19 21:48:33 -08:00
Girish Ramakrishnan 4429239dbc Fix debug 2017-02-19 20:30:35 -08:00
Girish Ramakrishnan b6ab9aa9f5 Add 0.102.0 changes 2017-02-19 17:22:52 -08:00
Girish Ramakrishnan 84bde6327f graphs: Better disk name matching
For some reason, docker devices are collected in collectd stats (despite
us collecting only ext4 and btrfs devices). They have the patter *docker*.

Fixes #222
2017-02-19 15:53:18 -08:00
Girish Ramakrishnan d6f49eb54f Remove _docker addon
this was a highly experimental code path from the past
2017-02-19 13:44:55 -08:00
Johannes Zellner 3c8c5e158b Send cloudron time zone with the backendSettings 2017-02-19 22:47:36 +01:00
Girish Ramakrishnan b3045b796f Configure dialog becomes 'repair' in errored state
Fixes #228
2017-02-18 13:17:46 -08:00
Girish Ramakrishnan c0febacc30 Remove configureLink
postInstallMessage already has this information
2017-02-18 12:52:47 -08:00
Johannes Zellner f8ada91dc5 Add rosehosting provider 2017-02-18 12:01:49 +01:00
Johannes Zellner d0e2ce9a9e Support Linode 1GB instance with cloudron-setup 2017-02-18 12:00:26 +01:00
Girish Ramakrishnan e157608992 doc: add note on memory limit 2017-02-17 13:47:19 -08:00
Girish Ramakrishnan 8dbe0ddaf3 doc: add note about incoming email 2017-02-17 13:01:23 -08:00
Girish Ramakrishnan b0cb18539c doc: add note to keep all ports open 2017-02-17 12:58:08 -08:00
Girish Ramakrishnan 97b6d76694 Explain certificate renewal error a bit more
Fixes #225
2017-02-17 10:41:33 -08:00
Girish Ramakrishnan 9de6c8ee2b doc: expand provider argument 2017-02-17 10:29:40 -08:00
Johannes Zellner cd28b1106b Only create app subvolume if it does not exist
Fixes #227
2017-02-17 15:15:50 +01:00
Johannes Zellner b3a5dafee0 Ensure we download docker images and have an app data volume on configure
Part of #227
2017-02-17 15:00:58 +01:00
Johannes Zellner eb4ab8defd Change cert CN from 'localhost' to 'cloudron'
Apparently localhost is special and triggerd a strange behavior in
firefox. Fixes #224
2017-02-17 14:05:21 +01:00
Girish Ramakrishnan 639744e9cb async.every usage has changed 2017-02-16 20:20:46 -08:00
Girish Ramakrishnan 6a942ab27a Use latest async for Inifinity retry to work 2017-02-16 19:22:07 -08:00
Girish Ramakrishnan 278f1d6d24 use curl with reconnect 2017-02-16 17:32:44 -08:00
Girish Ramakrishnan 563eeca1a9 Use the capture match length 2017-02-16 15:32:46 -08:00
Girish Ramakrishnan 7a9c954646 use ec2 sysinfo backend for lightsail 2017-02-16 14:47:16 -08:00
Johannes Zellner d768c36afb use generic sysinfo backend as fallback 2017-02-16 23:20:15 +01:00
Johannes Zellner 36ae3b267d Use better vultr referral link 2017-02-16 22:52:08 +01:00
Girish Ramakrishnan cd60f394d3 Use 1gb droplet (else docker ooms) 2017-02-16 11:52:25 -08:00
Johannes Zellner 9aba90a6f7 Show error message if subdomain was entered in setupdns view 2017-02-16 20:08:13 +01:00
Girish Ramakrishnan 68a8155f49 skip redis addon incremental update
Part of #223
2017-02-16 10:31:02 -08:00
Girish Ramakrishnan 16695fd4ec remove 0.9.0 2017-02-16 09:25:17 -08:00
Girish Ramakrishnan 9b6c6dc709 doc: base image 0.10.0 2017-02-16 09:20:27 -08:00
Girish Ramakrishnan 7923ed4f0d 0.101.0 changes 2017-02-15 23:31:28 -08:00
Girish Ramakrishnan 0b3d1c855c get the user before updating it
updating a non-existent user ends up creating a new mailbox
2017-02-15 23:19:56 -08:00
Girish Ramakrishnan d8273719d2 more robust detection and injection of SPF record
Fixes #210
2017-02-15 23:03:56 -08:00
Girish Ramakrishnan c6d2c39ff7 add azure 2017-02-15 20:10:33 -08:00
Girish Ramakrishnan 6960afdf0b Add more providers for stats 2017-02-15 15:49:00 -08:00
Girish Ramakrishnan 3a5000ab1d Detect loop support on linode correctly
We don't need any of the loop logic since it seems scaleway
also supports automatically this now
2017-02-15 15:40:19 -08:00
Girish Ramakrishnan 98951bab9e Store data args in file just in case installer fails 2017-02-15 14:27:51 -08:00
Girish Ramakrishnan 96fc3b8612 doc: pass --domain for old upgades to work 2017-02-15 11:59:55 -08:00
Girish Ramakrishnan 2b345b6c2d doc: Add note on <= 0.94.0 upgrades 2017-02-15 11:43:56 -08:00
Girish Ramakrishnan 504662b466 acme: link url is absolute in le-staging
Part of #217
2017-02-15 10:40:05 -08:00
Girish Ramakrishnan f56e6edbe4 use subdomains.waitForDns in mailer 2017-02-15 10:16:26 -08:00
Girish Ramakrishnan 191b84d389 Make value a regexp 2017-02-15 10:16:23 -08:00
Girish Ramakrishnan 8a4350d22e upsert already returns a SubdomainError 2017-02-14 22:29:33 -08:00
Girish Ramakrishnan cc6dae0f9e check if ns is set to DO nameservers 2017-02-14 22:27:27 -08:00
Girish Ramakrishnan 58528450e2 dns: Handle 422 errors in DO backend
Fixes #214
2017-02-14 20:51:44 -08:00
Girish Ramakrishnan ebf3559e60 Assume mailbox already exists 2017-02-14 15:42:38 -08:00
Girish Ramakrishnan 57d20b2b32 Assume mailbox already exists 2017-02-14 15:32:56 -08:00
Girish Ramakrishnan fd27240b26 delete user's old mailbox
we don't really support username change. this is only done for
completness.
2017-02-14 15:16:08 -08:00
Girish Ramakrishnan cad69d335c Fix result offset 2017-02-14 14:37:58 -08:00
Girish Ramakrishnan 1f08cca355 Add some newlines 2017-02-14 14:30:54 -08:00
Girish Ramakrishnan 7f4f525551 dhparams.pem must be part of backup 2017-02-14 14:12:03 -08:00
Girish Ramakrishnan b0037b6141 Update infra images to use latest base image 2017-02-14 12:23:17 -08:00
Girish Ramakrishnan 7956c8f58d use latest mysql 2017-02-14 11:27:48 -08:00
Girish Ramakrishnan 330c9054b4 add/del/update user mailbox as part of transaction 2017-02-14 10:42:32 -08:00
Girish Ramakrishnan d444d8552e add/del group mailbox as part of transaction 2017-02-14 09:54:52 -08:00
Girish Ramakrishnan 595bf583c7 delete mailbox as part of transaction 2017-02-13 15:19:17 -08:00
Girish Ramakrishnan 3386b99a29 fromEmail -> mailboxName 2017-02-13 15:15:07 -08:00
Girish Ramakrishnan 5fd667cdaf manual is not recommended 2017-02-13 11:20:07 -08:00
Johannes Zellner 4217db9e18 Ensure we don't crash if domain is not a string
Fixes #219
2017-02-13 13:21:25 +01:00
Johannes Zellner b4717e2edb Generating the dhparams.pem does not only apply to updates 2017-02-13 10:53:08 +01:00
Johannes Zellner 1d5465f21e Update the ssl ciphers and add dhparams.pem
Fixes #218
2017-02-13 00:28:22 +01:00
Johannes Zellner 2f1998fa67 Fix typo in cloudron-setup 2017-02-12 20:48:36 +01:00
Girish Ramakrishnan a7e998c030 Add new base image 2017-02-10 09:15:47 -08:00
Johannes Zellner 8cc15726ec Prevent the domain input from accepting trailing dots 2017-02-10 11:18:44 +01:00
Johannes Zellner 62e59868b4 Use the whole fontawesome package including fonts
The css file sources fonts relative to itself, so we need to include the
font files in our distribution as well.

Fixes #209
2017-02-10 10:53:32 +01:00
Girish Ramakrishnan a64027f4af Add PTR verification link 2017-02-09 19:17:24 -08:00
Girish Ramakrishnan f5a02930ec Use local bootstrap 3.3.7
We have 2 copies of bootstrap now. Just keeping both to be safe.
2017-02-09 14:37:44 -08:00
Girish Ramakrishnan 530ca20ee2 Use local font-awesome.min.css
Fixes #209
2017-02-09 14:37:44 -08:00
Girish Ramakrishnan f3b84ece3d doc: say what Encryption key is 2017-02-09 13:21:52 -08:00
Girish Ramakrishnan ca2d5957e4 Add canada and london to backup regions
Fixes #208
2017-02-09 12:59:13 -08:00
Girish Ramakrishnan 7837214276 Second Level -> Subdomain of public suffix list 2017-02-09 09:04:24 -08:00
Johannes Zellner 994202ca94 Use angular-tldjs for domain validation in certs view 2017-02-09 17:28:48 +01:00
Johannes Zellner ff7ceb1442 remove domain-validator directive
we will replace with angular-tldjs
2017-02-09 17:27:20 +01:00
Johannes Zellner 56545b7f41 Use check-tld directive for domain validation 2017-02-09 17:25:57 +01:00
Johannes Zellner 586e78dfea Apply manual fixes to angular-tld.js to support our use-case 2017-02-09 17:25:37 +01:00
Johannes Zellner 92ede4c242 Make the tld angular directive available in the main view and setupdns 2017-02-09 16:56:32 +01:00
Johannes Zellner 5ca2c2d564 Add angular-tld and its dependencies 2017-02-09 16:56:15 +01:00
Girish Ramakrishnan 9692aa3c08 Better error handling of unpurchase errors 2017-02-08 18:55:41 -08:00
Girish Ramakrishnan 10ad1028ae 0.100.1 changes 2017-02-08 15:14:14 -08:00
Johannes Zellner 7155856b08 Allocate the mailbox db record for apps in a transaction with appdb.add() 2017-02-08 23:52:14 +01:00
Girish Ramakrishnan 69aa771d44 Fix dkim dns crash
Fixes #207
2017-02-08 14:02:30 -08:00
Girish Ramakrishnan d164b5ae3a docs: add ptr links 2017-02-08 11:04:00 -08:00
Girish Ramakrishnan b34d09f547 ldap: Fix crash if displayName is empty and username is null 2017-02-08 10:13:50 -08:00
Girish Ramakrishnan 9e2850ffad setup: do not restart mysql unnecessarily 2017-02-08 07:53:55 -08:00
Johannes Zellner 480cface63 Do not crash if we did not receive a dmarc txt record 2017-02-08 16:55:08 +01:00
Girish Ramakrishnan 85aba589b8 Add hack to send heartbeat only after a minute of server running 2017-02-07 20:25:30 -08:00
Girish Ramakrishnan e890140aa9 Hold off sending heartbeat until the server is ready 2017-02-07 16:14:51 -08:00
Girish Ramakrishnan 53d56ef3a0 console.error -> debug 2017-02-07 10:48:51 -08:00
Girish Ramakrishnan b91674799b Create/destroy event listeners
mocha loads all the tests in same process. This means that when
we start a new test, the old state still persists. For event
listeners, this means that they get multiple duplicate event handlers.
2017-02-07 10:30:52 -08:00
Girish Ramakrishnan 4bb864e2ac use debug() instead
the tests are spewing out logs like crazy
2017-02-07 09:18:45 -08:00
Johannes Zellner 7db091525e Do not reboot the server on AMI creation
This will anyways happen once a new EC2 instance is created from the ami
and this ensures we do not encounter an SSH disconnect error when
running the cloudron-setup script during image creation
2017-02-07 12:49:28 +01:00
Johannes Zellner 695923ed75 cloudron-setup: support --skip-reboot for image creation 2017-02-07 12:49:28 +01:00
Johannes Zellner 1b43ccca6f Use new db-migrate which allows to specify the db backend
We use only mysql, so updating this means a lot of unused db backends
like sqlite do not need to be built with gyp anymore.
Note that this version is not yet released as stable, but works fine for
us. The outstanding issues are not related to our use-case from what I
can tell.

Fixes #82
2017-02-07 12:49:28 +01:00
Girish Ramakrishnan 96a0bad149 generate dkim keys in tests
move out dkim creation code that the tests require
2017-02-07 01:32:50 -08:00
Girish Ramakrishnan 243ade15e1 tests: restore aws.route53 mock 2017-02-07 01:32:34 -08:00
Girish Ramakrishnan 9d3cf990d1 Fix app test 2017-02-07 00:45:24 -08:00
Girish Ramakrishnan 02bcff2223 set isCustomDomain to true by default
CaaS is an exception and not the norm
2017-02-06 23:58:06 -08:00
Girish Ramakrishnan 8f388c86a6 do not unlink config file in test mode
this was incredibly hard to debug
2017-02-06 22:39:22 -08:00
Girish Ramakrishnan 8dc929f0ff Fix update checker test 2017-02-06 16:33:55 -08:00
Girish Ramakrishnan 509bd7e79b Make settings-test pass 2017-02-06 16:02:30 -08:00
Girish Ramakrishnan 19c665d747 docker daemon is deprecated 2017-02-06 11:33:10 -08:00
Girish Ramakrishnan cb09086ae8 Add dmsetup required by docker 2017-02-06 11:32:08 -08:00
Johannes Zellner fa915d0b23 Check for activated instead of fqdn to redirect to setup screens 2017-02-03 16:28:11 -08:00
Girish Ramakrishnan a383f01406 ami: wait for ssh as cloudron-setup reboots server 2017-02-03 11:26:56 -08:00
Girish Ramakrishnan 1a46e80403 remove .sh extension 2017-02-03 10:50:32 -08:00
Girish Ramakrishnan e8cd230c12 ami: remove ssh keys and fix subnet 2017-02-03 10:32:22 -08:00
Girish Ramakrishnan 0711dc2c5a createAMIImage: Add --region 2017-02-02 23:37:24 -08:00
Girish Ramakrishnan 486e72457d remove minlength for username 2017-02-02 16:09:07 -08:00
Girish Ramakrishnan 450e017bdb 0.100.0 changes 2017-02-02 15:43:16 -08:00
Girish Ramakrishnan c6d9cfc0d7 Passing IP never worked 2017-02-02 15:33:19 -08:00
Girish Ramakrishnan a0b073d881 Show DNS warning for manual/noop only 2017-02-02 14:43:34 -08:00
Girish Ramakrishnan 4dde16f987 Fix wording 2017-02-02 14:28:23 -08:00
Girish Ramakrishnan f7d2e262f4 Always fill spf record 2017-02-02 14:20:25 -08:00
Girish Ramakrishnan 34fedb5835 check spf and dkim all the time 2017-02-02 14:00:13 -08:00
Girish Ramakrishnan ff491be976 Display SPF/DKIM/PTR records for manual and noop backends 2017-02-02 13:58:49 -08:00
Girish Ramakrishnan 7635482191 Query via unbound
The timeout applies to each server. This resulted in us frequently
getting timeout out when we have more than one name server.
2017-02-02 13:58:49 -08:00
Girish Ramakrishnan b23001e43f better error log 2017-02-02 13:58:49 -08:00
Girish Ramakrishnan 06c8e8f0cb Query dns in parallel 2017-02-02 13:58:49 -08:00
Girish Ramakrishnan ce2cd00fbf Fix crash when no MX record is found 2017-02-02 13:58:49 -08:00
Johannes Zellner 651af185c8 Restart the droplet after installation for good measure
This is then in sync with selfhosting and ensures the init startup
sequence is in order, since the setup on its own creates unit files
which should run prior to services already running.

This hopefully fixes the mysql disconnect issues.
2017-02-02 11:24:49 -08:00
Girish Ramakrishnan 6951383ae0 Remove text-danger class in setupdns 2017-02-02 11:07:26 -08:00
Girish Ramakrishnan 37596e89b4 Fix display of info text in dns dialog 2017-02-02 11:05:56 -08:00
Girish Ramakrishnan 711fe37dad Add note on dnsRecordId 2017-02-02 10:43:04 -08:00
Girish Ramakrishnan 7fee3d0da0 Do not rely on dnsRecordId 2017-02-02 10:40:10 -08:00
Girish Ramakrishnan 45a61e9541 refreshDNS must always overwrite dns entries
dnsRecordId is mostly obsolete
2017-02-02 10:32:25 -08:00
Girish Ramakrishnan bd0be2affc No username implies no aliases 2017-02-02 01:22:44 -08:00
Girish Ramakrishnan 7812c0e5c2 Fix username and groupname min length 2017-02-02 01:16:32 -08:00
Girish Ramakrishnan 7efb6d60bc Allow usernames and groupnames of length 1
Fixes #204
2017-02-02 01:02:51 -08:00
Girish Ramakrishnan cd31e12bec Do not includeSubdomains in HSTS
This prevents one from redirecting to some http-only subdomain.
For example, surfer in naked domain redirects to www subdomain
(which is on github pages...)
2017-02-02 00:05:56 -08:00
Girish Ramakrishnan 87755c6097 ignore errors and continue 2017-02-01 23:38:06 -08:00
Girish Ramakrishnan 73f56efe2c Fix typo 2017-02-01 23:25:13 -08:00
Girish Ramakrishnan 20eaa60a97 clear timeout 2017-02-01 23:20:11 -08:00
Girish Ramakrishnan b80f0082e9 subdomain -> domain 2017-02-01 23:06:41 -08:00
Girish Ramakrishnan 1ff800a842 Display mx, dmarc, ptr status
Fixes #169
2017-02-01 22:59:06 -08:00
Girish Ramakrishnan 5b0abb1b17 re-setup DNS when the dns config changes 2017-02-01 14:34:57 -08:00
Girish Ramakrishnan 178aa4794a cloudron-setup: Add source-url 2017-02-01 14:11:50 -08:00
Girish Ramakrishnan 76583cb2fa createReleaseTarball: remove no-upload argument
We will put the upload in the release script
2017-02-01 13:41:27 -08:00
Girish Ramakrishnan aa484dc5b4 Add 0.99.1 changelog 2017-01-31 18:09:07 -08:00
Girish Ramakrishnan 19a098d34b remove obsolete nginx config file 2017-01-31 18:05:26 -08:00
Johannes Zellner db452d9bc0 Also send the autoupdatePattern with the stats route 2017-01-31 17:37:55 -08:00
Johannes Zellner 90efb96635 parse mailConfig blob 2017-01-31 16:36:09 -08:00
Girish Ramakrishnan 0cee6de476 Check if cloudron.conf file exists 2017-01-31 01:53:06 -08:00
Girish Ramakrishnan 854d29330c Fix email display logic again 2017-01-30 22:55:20 -08:00
Girish Ramakrishnan 34a3dd6d46 Always generate default nginx config
If we don't, https://ip won't work (caas relies on this for
health checks)
2017-01-30 16:17:07 -08:00
Girish Ramakrishnan 4787ee3301 Fix email note display logic 2017-01-30 15:49:50 -08:00
Girish Ramakrishnan 7b547e7ae9 Revert scaleway specific overlay2 support
This reverts commit 16d65d3665.

Rainloop app breaks with overlay2
2017-01-30 15:43:42 -08:00
Girish Ramakrishnan fe5e31e528 Save update json in /root
/tmp is not very secure. But the real reason is so that we can
re-run the setup script again should things fail.

/home/yellowtent/box/scripts/installer.sh --data-file /root/cloudron-update-data.json
2017-01-30 15:21:04 -08:00
Girish Ramakrishnan 841a838910 Fix text 2017-01-30 15:08:51 -08:00
Girish Ramakrishnan 4f27fe4f1e Fix email text 2017-01-30 14:24:08 -08:00
Girish Ramakrishnan 96eab86341 Applications -> Apps 2017-01-30 14:20:11 -08:00
Girish Ramakrishnan 95d7a991dc install grub2 2017-01-30 14:01:33 -08:00
Girish Ramakrishnan dc309afbbd Add --allow-downgrades
The following packages will be DOWNGRADED:
  docker-engine
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 0 not upgraded.
E: Packages were downgraded and -y was used without --allow-downgrades.
2017-01-30 14:01:32 -08:00
Girish Ramakrishnan 16d65d3665 Use overlay2 for scaleway
https://github.com/scaleway/image-ubuntu/issues/68
2017-01-30 14:01:29 -08:00
Girish Ramakrishnan ccb340cf80 Use systemd drop in to configure docker
The built-in service files get overwritten by updates

Fixes #203
2017-01-30 12:41:07 -08:00
Girish Ramakrishnan 56b0f57e11 Move unbound systemd config to separate file 2017-01-30 12:39:19 -08:00
Girish Ramakrishnan 7c1e056152 Add 0.99.0 changes 2017-01-30 10:25:11 -08:00
Girish Ramakrishnan 08ffa99c78 Use %s instead of %d
awk's %d behaves differently with mawk (scaleway) and gawk (do)

Fixes #200
2017-01-30 10:24:26 -08:00
Johannes Zellner cdede5a009 Add dns provider information on change dialog 2017-01-29 15:00:30 -08:00
Johannes Zellner 4cadffa6ea Remove automatic appstore account signup in setup view 2017-01-29 14:39:54 -08:00
Johannes Zellner 04e13eac55 Improve appstore signup 2017-01-29 14:38:38 -08:00
Johannes Zellner 2b3ae69f63 Selectivly show the correct labels when email is enabled in users view 2017-01-29 14:27:05 -08:00
Johannes Zellner 8f4813f691 Fix text for emails 2017-01-29 14:23:27 -08:00
Johannes Zellner 5b05baeced Make oauth view navbar entries links 2017-01-29 13:33:34 -08:00
Johannes Zellner 3d60e36c98 Fix top margin in oauth views 2017-01-29 13:33:34 -08:00
Johannes Zellner 40c7bd114a Add footer to oauth views 2017-01-29 13:33:34 -08:00
Johannes Zellner e0033b31f2 Fix text on settings and support views 2017-01-29 13:33:34 -08:00
Girish Ramakrishnan 2d3bdda1c8 Make tests pass 2017-01-29 13:01:09 -08:00
Girish Ramakrishnan fd40940ef5 Reserve ports <= 1023
Just being conservative here

Fixes #202
2017-01-29 12:43:24 -08:00
Girish Ramakrishnan 6d58f65a1a Reserve ssh ports 2017-01-29 12:38:58 -08:00
Johannes Zellner 44775e1791 Cleanup the graphs ui 2017-01-29 11:39:28 -08:00
Johannes Zellner 4be1f4dd73 Remove developerMode toggle in token ui 2017-01-29 10:26:14 -08:00
Johannes Zellner 93bab552c9 Fix text in certs, tokens and settings views 2017-01-29 02:50:26 -08:00
Johannes Zellner 023c03ddcd Use the same busy indicator everywhere 2017-01-29 02:01:01 -08:00
Johannes Zellner a5bffad556 Improve text on users page and remove username validation on delete 2017-01-29 01:40:33 -08:00
Johannes Zellner 836348cbc0 Improve text for app installation and configuration 2017-01-29 01:00:15 -08:00
Johannes Zellner 1ac7570cfb Autofocus appstore search field 2017-01-28 20:26:38 -08:00
Johannes Zellner 0dceba8a1c Do not reload all apps when search is empty 2017-01-28 19:57:32 -08:00
Johannes Zellner 599b070779 Remove appstore view title 2017-01-28 19:52:42 -08:00
Johannes Zellner c581e0ad09 webadmin: only show backup settings notification in settings view 2017-01-28 19:22:56 -08:00
Johannes Zellner e14b59af5d Append random query to ensure the avatar is refetched 2017-01-28 19:10:55 -08:00
Johannes Zellner eff9de3ded Adjust dns wait text 2017-01-28 18:33:37 -08:00
Johannes Zellner 4f128c6503 setup: improve text on dnssetup page 2017-01-28 18:27:22 -08:00
Johannes Zellner 8dc9d4c083 webadmin: Give better feedback on update schedule saving 2017-01-28 14:50:30 -08:00
Girish Ramakrishnan 21e3300396 tutorial: fix node version 2017-01-28 14:44:13 -08:00
Girish Ramakrishnan d136895598 Generate cert with cloudron.self CN instead of ip 2017-01-28 09:10:53 -08:00
Girish Ramakrishnan dac3eef57c Skip generating self-signed cert if we have a domain 2017-01-28 09:10:53 -08:00
Girish Ramakrishnan 2fac7dd736 delete old nginx configs on infra update
we changed the cert location and reloading nginx fails...
2017-01-28 09:10:49 -08:00
Girish Ramakrishnan 74e2415308 Make this an infra update
This has to be an infra update since the nginx configuration has
to be rewritten for the new data layout
2017-01-28 01:01:24 -08:00
Girish Ramakrishnan 41fae04b69 more 0.98.0 changes 2017-01-27 10:14:10 -08:00
Johannes Zellner 32a88a342c Add update notification mail tests 2017-01-27 09:51:26 -08:00
Johannes Zellner b5bcde5093 Fix update email tests 2017-01-27 09:51:26 -08:00
Johannes Zellner 68c36e8a18 Only send update notification mails if autoupdate is disabled 2017-01-27 09:51:26 -08:00
Johannes Zellner f6a9e1f4d8 Revert "Fix tests: we do not send mails anymore"
This reverts commit 7c72cd4399.
2017-01-27 09:51:26 -08:00
Johannes Zellner 2abd42096e Add showdown node module for update mails 2017-01-27 09:51:26 -08:00
Johannes Zellner 922e214c52 Revert "Remove now unused mailer.boxUpdateAvailable()"
This reverts commit 558093eab1.
2017-01-27 09:51:26 -08:00
Johannes Zellner 6ce8899231 Revert "Do not send box update emails to admins"
This reverts commit 865b041474.
2017-01-27 09:51:26 -08:00
Girish Ramakrishnan cbfad632c2 Handle 401 in app purchase 2017-01-27 07:47:56 -08:00
Johannes Zellner 7804aed5d7 Query graphite for 10 apps at a time at most
If many apps are installed, we may reach graphite's query string
size limit, so we get the app details now 10 at a time
2017-01-26 22:53:52 -08:00
Johannes Zellner b90b1dbbbe Show graph labels on the side 2017-01-26 22:38:00 -08:00
Johannes Zellner 020ec54264 Allow changing the autoupdate pattern in the settings view 2017-01-26 21:31:05 -08:00
Johannes Zellner 0568093a2a Add rest wrapper for autoupdate pattern route 2017-01-26 21:31:05 -08:00
Johannes Zellner c9281bf863 docs: Remove oauth proxy from the authentication docs 2017-01-26 16:17:21 -08:00
Johannes Zellner de451b2fe8 Redirect to the webadmin if update progress is 100 2017-01-26 15:52:57 -08:00
Girish Ramakrishnan ddf5c51737 Make it 90 instead 2017-01-26 15:45:07 -08:00
Johannes Zellner a33ccb32d2 Use autoupdate pattern constant in tests 2017-01-26 15:38:29 -08:00
Johannes Zellner 0b03018a7b Add constant for special 'never' autoupdate pattern 2017-01-26 15:36:24 -08:00
Johannes Zellner 1b688410e7 Add more changes 2017-01-26 15:27:29 -08:00
Johannes Zellner 6d031af012 Allow changing domain on caas always 2017-01-26 15:22:02 -08:00
Johannes Zellner 67a5151070 Also pick the token when migrating a caas cloudron to a different domain 2017-01-26 15:22:02 -08:00
Johannes Zellner a4b299bf6e Use domain validation for dns setup dialog 2017-01-26 15:22:02 -08:00
Johannes Zellner 383d1eb406 Add angular directive for domain validation input fields 2017-01-26 15:22:02 -08:00
Johannes Zellner 3901144eae Do not use the caas token as a do token 2017-01-26 15:22:02 -08:00
Johannes Zellner 317c6db1d5 Show all DNS providers also for caas 2017-01-26 15:22:02 -08:00
Johannes Zellner 1e14f8e2b9 Update and sync the footer in all webadmin pages 2017-01-26 15:22:02 -08:00
Girish Ramakrishnan 88fc7ca915 move the files and not the directory
... because box is a btrfs subvolume
2017-01-26 14:16:27 -08:00
Girish Ramakrishnan b983e205d2 Add more changes 2017-01-26 13:24:59 -08:00
Girish Ramakrishnan 9cdbc6ba36 capitalize 2017-01-26 13:08:56 -08:00
Girish Ramakrishnan 895f5f7398 Expand backup error in the mail 2017-01-26 13:03:36 -08:00
Girish Ramakrishnan f41b08d573 Add timestamp to emails 2017-01-26 12:47:23 -08:00
Girish Ramakrishnan 3e21b6cad3 Add ensureBackup log 2017-01-26 12:47:23 -08:00
Johannes Zellner 1a32482f66 Remove unused code in ami creation script 2017-01-26 11:11:07 -08:00
Johannes Zellner ee1e083f32 Add initial version of the AMI creation script 2017-01-25 14:06:26 -08:00
Girish Ramakrishnan ebd3a15140 always restart nginx 2017-01-25 12:04:52 -08:00
Girish Ramakrishnan d93edc6375 box.service: start after nginx 2017-01-25 11:28:31 -08:00
Girish Ramakrishnan 3ed17f3a2a doc: restore-url -> encryption-key 2017-01-25 09:47:25 -08:00
Girish Ramakrishnan 8d9cfbd3de Add 0.98.0 changes 2017-01-24 19:20:47 -08:00
Girish Ramakrishnan f142d34f83 Move box data out of appdata volume
This lets us restore the box if the app volume becomes full

Fixes #186
2017-01-24 13:48:09 -08:00
Girish Ramakrishnan 357ca55dec remove unused var 2017-01-24 10:41:58 -08:00
Girish Ramakrishnan d7a8731027 remove unused var 2017-01-24 10:41:38 -08:00
Girish Ramakrishnan 9117c7d141 Use $USER 2017-01-24 10:32:32 -08:00
Girish Ramakrishnan 472020f90c APPICONS_DIR -> APP_ICONS_DIR 2017-01-24 10:13:25 -08:00
Girish Ramakrishnan 2256a0dd3a group paths together 2017-01-24 10:12:05 -08:00
Girish Ramakrishnan 458b5d1e32 bump mail container 2017-01-23 16:26:44 -08:00
Girish Ramakrishnan 1e6abed4aa tests: create mail directory 2017-01-23 15:09:08 -08:00
Girish Ramakrishnan cdd4b426d5 use elif 2017-01-23 14:03:36 -08:00
Girish Ramakrishnan 75b60a2949 Make restore work without a domain
Fixes #195
2017-01-23 13:04:08 -08:00
Girish Ramakrishnan 9ab34ee43a Check for ubuntu version 2017-01-23 12:58:08 -08:00
Johannes Zellner 3c9d7706de Let the api call fail instead of explictily checking the token 2017-01-23 21:40:06 +01:00
Johannes Zellner 8b5b954cbb Only ever send heartbeats for caas cloudrons 2017-01-23 21:38:22 +01:00
Johannes Zellner b2204925d3 Remove unused setup_start.sh creation 2017-01-23 21:36:47 +01:00
Girish Ramakrishnan 63734155f2 doc: domain arg is redundant 2017-01-23 11:10:21 -08:00
Girish Ramakrishnan eb0ae3400a send mailConfig stat 2017-01-23 10:01:54 -08:00
Johannes Zellner db8db430b9 Avoid warning from systemd by reloading the daemon after chaning journald config 2017-01-23 11:01:02 +01:00
Johannes Zellner c0b2b1c26d Escape shell vars in the unbound unit file 2017-01-23 10:27:23 +01:00
Johannes Zellner 7da20e95e3 Use a proper systemd unit file for unbound
Part of #191
2017-01-23 10:14:20 +01:00
Girish Ramakrishnan f30f90e6be Stop mail container before moving the dirs 2017-01-22 21:57:34 -08:00
Girish Ramakrishnan 7f05b48bd7 Revert "Migrate mail data after downloading restore data"
This reverts commit e7c399c36a.
2017-01-22 02:42:14 -08:00
Girish Ramakrishnan ea257b95d9 Fix dirnames when backing up 2017-01-21 23:40:41 -08:00
Girish Ramakrishnan e7c399c36a Migrate mail data after downloading restore data
This allows us to be backward compatible
2017-01-21 23:33:57 -08:00
Girish Ramakrishnan d84666fb43 Move mail data out of box
This will help us with putting a size on box data

Mail container version is bumped because we want to recreate it

Part of #186
2017-01-20 20:22:08 -08:00
Girish Ramakrishnan 1eb33099af dkim directory is now automatically created in cloudron.js 2017-01-20 15:18:03 -08:00
Girish Ramakrishnan e35dbd522f More debugMode fixes 2017-01-20 09:56:44 -08:00
Girish Ramakrishnan db6474ef2a Merge readonlyRootfs and development mode into debug mode
The core issue we want to solve is to debug a running app.
Let's make it explicit that it is in debugging mode because
functions like update/backup/restore don't work.

Part of #171
2017-01-20 09:29:32 -08:00
Johannes Zellner e437671baf Add basic --help for gulp develop 2017-01-20 15:11:17 +01:00
Johannes Zellner f60d640c8e Set developmentMode default to false 2017-01-20 12:07:25 +01:00
Johannes Zellner 56c992e51b Check for 19GB instead of 20GB in cloudron-setup
This is as reporting the disk size may vary from the one selected when
creating the server. Eg EC2 20GB storage results in 21474836480 bytes
which in turn will be calculated as less than 20GB in the script
2017-01-20 11:22:43 +01:00
Girish Ramakrishnan 12ee7b9521 send readonly and dev mode fields 2017-01-19 19:01:29 -08:00
Girish Ramakrishnan c8de557ff7 More 0.97.0 changes 2017-01-19 15:59:52 -08:00
Girish Ramakrishnan 90adaf29d7 Update manifestformat (remove developmentMode)
Fixes #171
2017-01-19 15:57:29 -08:00
Girish Ramakrishnan a71323f8b3 Add developmentMode flag to appdb
Part of #171
2017-01-19 15:57:24 -08:00
Girish Ramakrishnan 155995c7f3 Allow memoryLimit to be unrestricted programatically 2017-01-19 15:11:40 -08:00
Girish Ramakrishnan 319632e996 add readonlyRootfs to the database 2017-01-19 15:11:40 -08:00
Johannes Zellner 33d55318d8 Do not read oauth details in gulpfile from env 2017-01-19 23:41:07 +01:00
Johannes Zellner ec1abf8926 Remove creation of now unused and broken provision.sh 2017-01-19 23:18:01 +01:00
Girish Ramakrishnan 9a41f111b0 Fix failing tests 2017-01-19 12:51:16 -08:00
Girish Ramakrishnan 7ef6bd0d3f Add readonlyRootfs flag to apps table
When turned off, it will put the app in a writable rootfs. This
allows us to debug live/production apps (like change start.sh) and
just get them up and running. Once turned off, this app cannot be
updated anymore (unless the force flag is set). This way we can
then update it using the CLI if we are convinced that the upcoming
update fixes the problem.

Part of #171
2017-01-19 11:55:25 -08:00
Girish Ramakrishnan 02f0bb3ea5 Add readonly flag
Part of #171
2017-01-19 10:55:13 -08:00
Girish Ramakrishnan e12b236617 More 0.97.0 changes 2017-01-19 10:45:41 -08:00
Girish Ramakrishnan 6662a4d7d6 Collect every 60min
If we are crashing so problem, we have bigger problems...
2017-01-19 10:11:36 -08:00
Girish Ramakrishnan 85315d8fc5 Do not stash more than 2mb in log file
For reference, each crash increases the file size by 112K.
So we can store around 20 crashes.

Fixes #190
2017-01-19 10:09:49 -08:00
Girish Ramakrishnan 9f5a7e4c08 cloudron-setup: keep the cursor in the same line 2017-01-19 10:09:47 -08:00
Girish Ramakrishnan ea0e61e6a4 Remove unused function 2017-01-19 09:12:54 -08:00
Johannes Zellner c301e9b088 Show better backup progress in settings ui 2017-01-19 17:30:01 +01:00
Johannes Zellner 70e861b106 Distinguish between app task and backup in progress 2017-01-19 17:08:18 +01:00
Johannes Zellner f5c6862627 Improve backup creation UI
- Do not prompt the user if he really wants to create a backup
- Show error message if a backup can't be created at the moment
2017-01-19 17:04:22 +01:00
Johannes Zellner d845f1ae5b Indicate in the mail subject if it contains more than one crash 2017-01-19 16:52:44 +01:00
Johannes Zellner 7c7d67c6c2 Append the log separator looks nicer 2017-01-19 16:30:20 +01:00
Johannes Zellner c9fcbcc61c No need to print the unitName in the separator 2017-01-19 15:42:30 +01:00
Johannes Zellner 9ac06e7f85 Stash crash logs for up to 30min
This avoids spaming us with crash logs

Part of #190
2017-01-19 15:23:20 +01:00
Johannes Zellner 6eafac2cad Do not rely on fdisk's human readable unit output
Using the bytes output will fix an issue where the disk size is reported
either as terrabyte or also megabyte.
So far we disallowed 1TB disks but allowed 20MB disks.
2017-01-19 13:53:50 +01:00
Johannes Zellner 60cb0bdfb1 Add 0.97.0 changes 2017-01-19 13:17:09 +01:00
Johannes Zellner 979956315c Only ever remove the app icon on uninstall 2017-01-19 12:39:31 +01:00
Johannes Zellner 62ba031702 Skip icon download without an appStoreId 2017-01-19 12:38:41 +01:00
Girish Ramakrishnan 284cb7bee5 doc: remove double header 2017-01-18 23:41:41 -08:00
Girish Ramakrishnan 735c22bc98 doc: more cleanup on selfhosting doc 2017-01-18 23:37:33 -08:00
Girish Ramakrishnan a2beed01a1 doc: move cli section down 2017-01-18 23:31:21 -08:00
Girish Ramakrishnan 93fc6b06a2 doc: add alerts section 2017-01-18 23:14:22 -08:00
Girish Ramakrishnan a327ce8a82 doc: cleanup selfhosting guide 2017-01-18 23:09:06 -08:00
Girish Ramakrishnan f8374929ac generate mail.ini and not mail_vars.ini 2017-01-18 09:11:34 -08:00
Girish Ramakrishnan 5f93290fc7 Fix crash 2017-01-18 08:43:11 -08:00
Johannes Zellner 4d139232bf caas always has a valid appstore token to show the appstore view 2017-01-18 13:05:25 +01:00
Girish Ramakrishnan 804947f039 use dir mount instead of file mount
file mounting is fraught with problems wrt change notifications.

first, we must be carefule that the inode does not change.

second, changes outside container do not result in fs events inside the container.
haraka cache settings files and relies on fs events. So, even
though the file gets updated inside the container, haraka doesn't
see it.

https://github.com/docker/docker/issues/15793
2017-01-17 23:59:23 -08:00
Girish Ramakrishnan 89fb2b57ff recreate mail config when we have owner email id 2017-01-17 23:34:05 -08:00
Girish Ramakrishnan 1262d11cb3 Prefix event enum with EVENT_ 2017-01-17 23:18:08 -08:00
Girish Ramakrishnan 1ba72db4f8 Add prerelease option 2017-01-17 21:23:57 -08:00
Girish Ramakrishnan 7d2304e4a1 Move 0.94.1 changes 2017-01-17 11:01:12 -08:00
Girish Ramakrishnan ebf1dc1b08 listen for cert changed events and restart mail container
neither haraka nor dovecot restarts on cert change

Fixes #47
2017-01-17 10:59:00 -08:00
Girish Ramakrishnan ce31f56eb6 Keep configurePlainIP private 2017-01-17 10:32:46 -08:00
Girish Ramakrishnan 7dd52779dc generate cert files for mail container
this allows us to not track paths anymore

part of #47
2017-01-17 10:21:44 -08:00
Girish Ramakrishnan 2eb5cab74b enable route to set admin certificate 2017-01-17 10:01:05 -08:00
Girish Ramakrishnan db50382b18 check user cert and then the le cert
part of #47
2017-01-17 09:59:40 -08:00
Girish Ramakrishnan 32b061c768 user certs are saved with extension user.cert/key
part of #47
2017-01-17 09:59:30 -08:00
Girish Ramakrishnan 740e85d28c make code a bit readable 2017-01-17 09:57:15 -08:00
Girish Ramakrishnan 568a7f814d rename func 2017-01-17 09:51:04 -08:00
Girish Ramakrishnan b99438e550 remove unused function 2017-01-17 09:18:48 -08:00
Girish Ramakrishnan bcdf90a8d9 typo 2017-01-17 09:17:09 -08:00
Girish Ramakrishnan 536c16929b Remove showTutorial 2017-01-17 09:11:34 -08:00
Johannes Zellner d392293b50 Remove unused require 2017-01-17 16:32:22 +01:00
Johannes Zellner 16371d4528 Use the apps.js layer instead of the raw appdb in apphealthmonitor.js 2017-01-17 16:32:12 +01:00
Johannes Zellner cdd0b48023 Remove redundant information in user event email 2017-01-17 16:16:39 +01:00
Johannes Zellner 15cac726c4 Use the correct var 2017-01-17 16:15:19 +01:00
Johannes Zellner 6dc69a4d5d Streamline the email subject lines 2017-01-17 16:02:42 +01:00
Johannes Zellner c52dfcf52f Adjust user deletion dialog based on feedback 2017-01-17 16:02:26 +01:00
Johannes Zellner eaac13b1c1 app.fqdn already takes care of altDomain 2017-01-17 16:01:10 +01:00
Johannes Zellner 3e83f3d4ee Put our link to all mails and sync the formatting 2017-01-17 15:47:18 +01:00
Johannes Zellner 3845a8f02b HTMLify user added email to admins 2017-01-17 15:34:50 +01:00
Johannes Zellner c932be77f8 Mention that backup storage configuration is about S3 configuration 2017-01-17 15:23:52 +01:00
Johannes Zellner d89324162f Remove tutorial route tests 2017-01-17 13:05:47 +01:00
Johannes Zellner a0ef86f287 Remove now unused tutorial route and business logic
We can bring that back again if needed
2017-01-17 12:50:59 +01:00
Johannes Zellner 7255a86b32 Remove welcome tutorial css parts 2017-01-17 12:47:05 +01:00
Johannes Zellner 81862bf934 Remove the tutorial components and logic 2017-01-17 12:44:07 +01:00
Johannes Zellner 81b7e5645c This not an error if a cloudron is not yet registered
The change avoids scary logs with backtrace
2017-01-17 11:41:50 +01:00
Johannes Zellner 801367b68d Use specific functions for configureAdmin (with domain) and configurePlainIp (always)
This prevents from double configuring on startup on caas cloudrons
2017-01-17 11:38:33 +01:00
Johannes Zellner f2e8f325d1 Correct debug lines for cert renewal or not existing 2017-01-17 10:35:42 +01:00
Girish Ramakrishnan 138743b55f More 0.94.1 changes 2017-01-16 16:39:18 -08:00
Johannes Zellner 7f8db644d1 Use in-memory rate limit
Related to #187
2017-01-16 16:49:03 +01:00
Johannes Zellner c7e410c41b Add express-rate-limit module 2017-01-16 16:48:43 +01:00
Johannes Zellner 08f3b0b612 Add rate limit test 2017-01-16 16:48:17 +01:00
Johannes Zellner a2782ef7a6 Normal users do not have access to the tutorial 2017-01-16 12:59:21 +01:00
Johannes Zellner 34fac8eb05 Do not show appstore for non-admins 2017-01-16 12:58:05 +01:00
Johannes Zellner 56338beae1 Ensure the appstore login input field has focus 2017-01-16 12:53:34 +01:00
Johannes Zellner 17e9f3b41d Move error label in app error dialog to the title 2017-01-16 12:47:58 +01:00
Johannes Zellner 2c06b9325f Add missing callback 2017-01-16 12:35:26 +01:00
Johannes Zellner 2dfb91dcc9 Embed the appstore login instead of a dialog 2017-01-16 12:34:33 +01:00
Johannes Zellner 9f20dfb237 Allow installation on reported main memory of 990 2017-01-16 10:36:16 +01:00
Girish Ramakrishnan da2aecc76a Save generated fallback certs as part of the backup
this way we don't get a new cert across restarts
2017-01-14 13:18:54 -08:00
Girish Ramakrishnan 7c72cd4399 Fix tests: we do not send mails anymore 2017-01-14 13:01:21 -08:00
Girish Ramakrishnan 5647b0430a Simplify onConfigured logic
We had all this logic because we allowed the user to create a CaaS
cloudron with a custom domain from the appstore. This flow has changed
now.

One can only set the DNS config after verification. Only thing that
is required is a domain check.
2017-01-14 12:59:16 -08:00
Girish Ramakrishnan 7c94543da8 bump test version 2017-01-13 20:06:15 -08:00
Girish Ramakrishnan 2118952120 send the ownerType as part of mailbox query 2017-01-13 19:53:58 -08:00
Girish Ramakrishnan d45927cdf4 unbound: listen on 0.0.0.0 2017-01-13 15:22:54 -08:00
Johannes Zellner c8e99e351e Update the selfhosting installation docs to reflect the dns setup changes 2017-01-13 15:15:25 +01:00
Girish Ramakrishnan fb56237122 0.94.1 changes 2017-01-12 19:28:27 -08:00
Girish Ramakrishnan 89152fabde use latest test image 2017-01-12 19:28:27 -08:00
Girish Ramakrishnan 726463d497 use le-staging in dev for better testing 2017-01-12 19:28:27 -08:00
Girish Ramakrishnan 055e41ac90 Make unbound reply on cloudron network
Because of the docker upgrade, dnsbl queries are failing again
since we are not using the unbound server from the containers.

For some reason, docker cannot query 127.0.0.1 (https://github.com/docker/docker/issues/14627).

Make unbound listed on the cloudron network and let docker proxy
DNS calls to unbound (docker always use the embedded DNS server
when using UDN).

See also #130
2017-01-12 19:28:23 -08:00
Girish Ramakrishnan 878878e5e4 Bump mail container for testing 2017-01-12 12:04:24 -08:00
Girish Ramakrishnan 7742c8a58e Remove unused function 2017-01-12 11:50:59 -08:00
Girish Ramakrishnan 04476999f7 Fix grammar 2017-01-12 11:48:03 -08:00
Girish Ramakrishnan 5bff7ebaa1 remove dead comment 2017-01-12 11:46:52 -08:00
Girish Ramakrishnan 44742ea3ae Fix bug where cloudron cannot be setup if initial dns credentials were invalid
To reproduce:
* https://ip
* provide invalid dns creds. at this point, config.fqdn gets set already
* cannot setup anymore
2017-01-12 11:46:52 -08:00
Girish Ramakrishnan d6ea7fc3a0 Move setupDns to cloudron.js 2017-01-12 11:46:49 -08:00
Girish Ramakrishnan 2b49cde2c2 cloudron-setup: validate tlsProvider 2017-01-12 10:31:54 -08:00
Johannes Zellner 1008981306 Adapt to new notification library version
the notification template is now in the html pages itself
2017-01-12 16:00:57 +01:00
Johannes Zellner 146f3ad00e Do not show 0 progress in update
If the initial app takes very long to backup, do not show 0 progress for
a long time
2017-01-12 16:00:57 +01:00
Johannes Zellner 5219eff190 Remove 'app at' for app backup message 2017-01-12 16:00:57 +01:00
Johannes Zellner abfd7b8aea Update angular notification library to support maxCount 2017-01-12 16:00:57 +01:00
Johannes Zellner d98f64094e Set the correct progress percentage 2017-01-12 16:00:56 +01:00
Johannes Zellner a8d254738e Only set the update page title to Cloudron 2017-01-12 16:00:56 +01:00
Johannes Zellner 1c9f2495e3 Show the detailed backup progress during update
Fixes #157
2017-01-12 16:00:34 +01:00
Johannes Zellner aa4d95f352 Remove unused node module showdown 2017-01-12 13:13:37 +01:00
Johannes Zellner 558093eab1 Remove now unused mailer.boxUpdateAvailable() 2017-01-12 13:11:18 +01:00
Johannes Zellner 865b041474 Do not send box update emails to admins
Fixes #160
2017-01-12 13:09:12 +01:00
Johannes Zellner 1888319313 Send altDomain as Host header if it is set
At least nextcloud will respond with 400 if the Host header is not
matching
2017-01-12 10:45:16 +01:00
Girish Ramakrishnan 0be7679619 Hold the docker package
One idea was to use docker binary packages. However, docker binaries
are statically linked and are incompatible with devicemapper.

See https://github.com/docker/docker/issues/14035 for more info.

Holding will let the user turn on automatic updates for non-security
packages as well.

Fixes #183
2017-01-12 01:09:19 -08:00
Girish Ramakrishnan bbef6c2bc2 Fix docker storage driver detection
When docker is not passed the --storage-driver option, it tries to
auto detect the storage driver. Roughly:
1. If existing storage paths like /var/lib/docker/aufs exist, it will
   choose that driver.

2. It has a priority list of drivers to scan in order (driver.go)
   As it stands the ordering is aufs, btrfs and then devicemapper.

3. Docker will attempt to "init" each driver. aufs, for example,
   tests for insmod'ing aufs and also looks into /proc/filesystems.

The fact that we installed aufs-tools and linux drivers (for aufs
driver) was a programming error since we want docker to use devicemapper.

However, what is curious is why docker still ended up choosing devicemapper
despite having all aufs requirements (as we do not pass --storage-driver explicitly).

The answer is that "apt-get install aufs-tool linux-image-* docker-engine"
can install packages in any order! This means there is a race on how docker
chooses the storage engine. In most cases, since linux-image-* is a big package,
docker gets to install first and ends up using devicemapper since aufs module is not found yet.
For some people, linux-image-* possibly installs first and thus docker
chooses aufs!

Mystery solved.

Part of #183
2017-01-12 01:08:22 -08:00
Girish Ramakrishnan be59267747 Enable unattended upgrades
This is usually installed and enabled by default

https://help.ubuntu.com/community/AutomaticSecurityUpdates

Note that automatic reboot is not enabled. Not clear if we should be.

Part of #183
2017-01-11 22:36:51 -08:00
Girish Ramakrishnan b4477d26b7 Reload the docker service file 2017-01-11 15:40:16 -08:00
Girish Ramakrishnan ce0afb3d80 Explicitly specify the storage driver as devicemapper
For reasons unknown, the images build by the buildbot (which currently
uses btrfs), does not work with devicemapper.

Existing cloudrons with aufs will not be affected because docker will
just ignore it.

devmapper: Base device already exists and has filesystem xfs on it. User specified filesystem will be ignored.

Existing AUFS users can move to devicemapper either by restoring to
a new cloudron (recommended) OR
* systemctl stop box
* systemctl stop docker
* rm -rf /var/lib/docker
* Edit /home/yellowtent/data/INFRA_VERSION. Change the "version" field to "1"
* systemctl start docker
* systemctl start box # this will download images all over

Fixes #182
2017-01-11 14:53:11 -08:00
Johannes Zellner 0b5cd304ea We also don't need to prefix with my. when using the adminFqdn 2017-01-11 23:09:06 +01:00
Girish Ramakrishnan e54ad97fa7 cloudron-setup: set the apiServerOrigin for --env 2017-01-11 12:36:01 -08:00
Girish Ramakrishnan 66960ea785 cloudron-setup: Add --env flag 2017-01-10 20:42:24 -08:00
Girish Ramakrishnan 72dd3026ca collect docker info output
this has information like the storage driver
2017-01-10 20:42:24 -08:00
Girish Ramakrishnan 4c719de86c restart docker only if config changed 2017-01-10 18:50:21 -08:00
Girish Ramakrishnan c7a0b017b4 Fix crash 2017-01-10 18:50:21 -08:00
Johannes Zellner 91c931b53c Revert "Remove broken external domain validation"
This reverts commit 9b1b833fac.
2017-01-11 03:46:41 +01:00
Girish Ramakrishnan 6f2b2adca9 Enable apparmor explicitly 2017-01-10 18:15:10 -08:00
Girish Ramakrishnan 3176bc1afa Fix failing tests 2017-01-10 16:54:15 -08:00
Girish Ramakrishnan b929adf2dd Fix migration 2017-01-10 16:23:01 -08:00
Girish Ramakrishnan f3d3b31bed Fix error return type 2017-01-10 16:16:42 -08:00
Girish Ramakrishnan f17eaaf025 Add TODO note 2017-01-10 16:16:37 -08:00
Girish Ramakrishnan 80d65acd0d Set the domain only during dns setup
If we change the domain when dns settings are changed, then migration
fails because we callout to appstore API via the domain (for example,
backup url call will fail because it uses the new domain name).
2017-01-10 16:16:32 -08:00
Girish Ramakrishnan ba02d333d1 remove unused requires 2017-01-10 16:16:25 -08:00
Johannes Zellner 9b9d30c092 Remove commented out section of the nginx.conf 2017-01-11 00:09:51 +01:00
Johannes Zellner d47de31744 Rename nakeddomain.html to noapp.html 2017-01-11 00:08:13 +01:00
Johannes Zellner edc7efae5f Do not overwrite the provider previously set 2017-01-11 00:02:19 +01:00
Johannes Zellner 18007be9e1 Also use adminFqdn in setup.js 2017-01-10 23:58:28 +01:00
Johannes Zellner d68ae4866c The adminFqdn already has the my. part 2017-01-10 23:58:28 +01:00
Girish Ramakrishnan f4b635a169 Fix error type 2017-01-10 14:21:36 -08:00
Johannes Zellner d674d72508 Add missing https:// for adminFqdn 2017-01-10 22:54:45 +01:00
Johannes Zellner 6ee76f8ee4 No need for my. my- magic anymore 2017-01-10 22:54:45 +01:00
Johannes Zellner 06338e0a1f Redirect to naked domain if we are not on a webadmin origin 2017-01-10 22:54:45 +01:00
Johannes Zellner 349c261238 Remove configStatus.domain and replace with toplevel adminFqdn 2017-01-10 22:54:45 +01:00
Girish Ramakrishnan eb057fb399 Add note that port 25 is blocked on some DO accounts 2017-01-10 12:38:34 -08:00
Johannes Zellner 5d739f012c Never use the cloudron email account for LetsEncrypt 2017-01-10 18:14:59 +01:00
Johannes Zellner 741d56635f show a maximum of 3 error notifications at once 2017-01-10 15:58:15 +01:00
Johannes Zellner 35404a2832 Return expected dns records also if we hit NXDOMAIN 2017-01-10 15:51:53 +01:00
Johannes Zellner 99505fc287 Call the correct function to get dns email records in the webadmin 2017-01-10 15:43:14 +01:00
Johannes Zellner a20b331095 Convert settings JSON to objects 2017-01-10 15:24:16 +01:00
Johannes Zellner 06a9a82da0 Disable query for non approved apps 2017-01-10 14:01:46 +01:00
Johannes Zellner 03383eecbc Also remind the user on app install if manual dns is used 2017-01-10 13:47:58 +01:00
Johannes Zellner 89ae1a8b92 Ensure wildcard backend is pre-selected on configure 2017-01-10 13:43:33 +01:00
Johannes Zellner 7061195059 Show different text for manual and wildcard dns backends 2017-01-10 13:41:20 +01:00
Johannes Zellner 9556d4b72c Fix the busy state of the dns backend change form 2017-01-10 13:34:00 +01:00
Johannes Zellner dd764f1508 Sync the dns provider selection in the ui parts 2017-01-10 13:16:25 +01:00
Johannes Zellner 0a154339e6 Fix the normal case of changing dns provider 2017-01-10 13:15:14 +01:00
Johannes Zellner 2502b94f20 Remind the user to setup the DNS record on app configuration 2017-01-10 13:11:37 +01:00
Johannes Zellner 9b1b833fac Remove broken external domain validation 2017-01-10 13:05:06 +01:00
Johannes Zellner 848ca9817d Give better DNS error feedback after app installation 2017-01-10 13:01:15 +01:00
Johannes Zellner 9a159b50c6 Do not recommend manual dns backend 2017-01-10 12:34:28 +01:00
Johannes Zellner 11fb0d9850 Verify the my.domain instead of the zone 2017-01-10 12:30:14 +01:00
Johannes Zellner 3f925e5b96 Improve manual dns backend error message 2017-01-10 12:09:30 +01:00
Johannes Zellner 714ae18658 Fix the manual dns verification 2017-01-10 12:07:32 +01:00
Johannes Zellner 226164c591 This error is already a SubdomainError 2017-01-10 11:40:05 +01:00
Johannes Zellner 1d44d0a987 Remove dns validation code in settings.js 2017-01-10 11:33:33 +01:00
Johannes Zellner babfb5efbb Make the verifyDnsConfig() api return the valid credentials 2017-01-10 11:32:44 +01:00
Johannes Zellner badbb89c92 Add INVALID_PROVIDER to SubdomainError 2017-01-10 11:32:24 +01:00
Johannes Zellner 50e705fb25 Remove unused requires 2017-01-10 11:14:16 +01:00
Johannes Zellner b9e0530ced Fill in the noops in the other backends 2017-01-10 11:13:33 +01:00
Johannes Zellner 9c793f1317 Make the new interface available in subdomains.js 2017-01-10 11:13:02 +01:00
Johannes Zellner cef93012bf Implement verifyDnsConfig() for manual dns 2017-01-10 11:12:38 +01:00
Johannes Zellner bd099cc844 Implement verifyDnsConfig() for route53 2017-01-10 11:12:25 +01:00
Johannes Zellner c1029ba3b0 Implement verifyDnsConfig() for digitalocean 2017-01-10 11:12:13 +01:00
Johannes Zellner 152025baa7 Add verifyDnsConfig() to the dns backend where it belongs 2017-01-10 11:11:41 +01:00
Johannes Zellner 94f0f48cba Send backend provider with stats route 2017-01-10 10:22:47 +01:00
Girish Ramakrishnan 9b5c312aa1 Disable Testing tab
Part of #180
2017-01-09 21:08:01 -08:00
Girish Ramakrishnan fdb488a4c3 installApp bundle first because syncConfigState might block 2017-01-09 19:06:32 -08:00
Girish Ramakrishnan 69536e2263 Do not show multiple Access control sections for email apps 2017-01-09 19:00:15 -08:00
Girish Ramakrishnan 3f8ea6f2ee Make app auto install as part of async flow
It was called in nextTick() and was done async but had no chance to
run because the platform.initialize() which is sync was blocking it
2017-01-09 18:24:41 -08:00
Girish Ramakrishnan 3b035405b0 debug.formatArgs API has changed 2017-01-09 16:41:04 -08:00
Girish Ramakrishnan 7b1a6e605b ensure backup directory exists
this is because the filename can now contain subpaths
2017-01-09 16:09:54 -08:00
Girish Ramakrishnan 26ed331f8e Add default clients in clients.js 2017-01-09 15:41:29 -08:00
Johannes Zellner 29581b1f48 cog is a circle 2017-01-09 22:58:01 +01:00
Girish Ramakrishnan 16ea13b88c Check status for cloudron to be ready 2017-01-09 13:29:17 -08:00
Girish Ramakrishnan 2311107465 remove misleading comments 2017-01-09 12:35:39 -08:00
Girish Ramakrishnan 35cf9c454a taskmanager: track paused state 2017-01-09 12:26:18 -08:00
Girish Ramakrishnan 4c2a57daf3 0.94.0 changes 2017-01-09 11:26:29 -08:00
Girish Ramakrishnan ed9889af11 Add note about alive and heartbeat job 2017-01-09 11:14:11 -08:00
Girish Ramakrishnan 89dc2ec3f6 Remove configured event 2017-01-09 11:02:33 -08:00
Girish Ramakrishnan 7811359b2f Move cron.initialize to cloudron.js 2017-01-09 11:00:09 -08:00
Girish Ramakrishnan 21c66915a6 Refactor taskmanager resume flow 2017-01-09 10:49:34 -08:00
Girish Ramakrishnan e3e99408d5 say the container was restarted automatically 2017-01-09 10:46:43 -08:00
Girish Ramakrishnan 01f16659ac remove unused requires 2017-01-09 10:33:23 -08:00
Girish Ramakrishnan 9e8f120fdd Make ensureFallbackCertificate error without a domain 2017-01-09 10:28:28 -08:00
Girish Ramakrishnan 3b9b9a1629 ensure fallback cert exists before platform is started 2017-01-09 10:28:28 -08:00
Girish Ramakrishnan 9e2f43c3b1 initialize platform only when domain is available 2017-01-09 10:28:25 -08:00
Girish Ramakrishnan 588bb2df2f Pull docker images in initialize script
This allows us to move platform.initialize to whenever the domain
is setup. Thus allowing box code to startup faster the first time
around.
2017-01-09 09:22:23 -08:00
Girish Ramakrishnan 3c55ba1ea9 doc: clarify httpPort 2017-01-09 09:17:35 -08:00
Johannes Zellner 2a86216a4a Fix race for mailConfig in settings view 2017-01-09 13:58:11 +01:00
Johannes Zellner e3ea2323c5 Defer configure checks to after tutorial
Fixes #154
2017-01-09 13:45:01 +01:00
Johannes Zellner 6b55f3ae11 Highlight the domain for the manual/wildcard DNS setup 2017-01-09 13:37:54 +01:00
Johannes Zellner f3496a421b Remove tooltip for memory requirement 2017-01-09 11:53:18 +01:00
Girish Ramakrishnan a4bba37606 Call mailer.start on configured 2017-01-07 23:40:34 -08:00
Girish Ramakrishnan 56c4908365 restart mail container on configure event 2017-01-07 23:33:20 -08:00
Girish Ramakrishnan 18f6c4f2cd Refactor configure event handling into onConfigured event 2017-01-07 23:31:29 -08:00
Girish Ramakrishnan d0ea1a4cf4 Send bounce alerts to cloudron owner
Fixes #166
2017-01-07 23:24:12 -08:00
Girish Ramakrishnan aa75824cc6 Pass alerts_from and alerts_to to mail container
Part of #166
2017-01-07 22:31:40 -08:00
Girish Ramakrishnan 61d5005c4b Use mail_vars.ini to pass mail container config 2017-01-07 16:42:24 -08:00
Girish Ramakrishnan 72d58f48e4 Remove invalid event 2017-01-07 14:28:33 -08:00
Girish Ramakrishnan 3f3b97dc16 Send oom email to cloudron admins
Part of #166
2017-01-07 13:52:33 -08:00
Girish Ramakrishnan 8a05fdcb10 Fix language 2017-01-07 12:35:26 -08:00
Girish Ramakrishnan 6fd3466db1 Send cert renewal errors to support@cloudron.io as well
Part of #166
2017-01-07 12:29:43 -08:00
Girish Ramakrishnan f354baf685 Inc -> UG 2017-01-07 11:59:13 -08:00
Girish Ramakrishnan d009acf8e0 doc: upgrading from filesystem backend
Fixes #156
2017-01-07 11:57:37 -08:00
Johannes Zellner fd479d04a0 Fix nginx config to make non vhost configs default_server
Nginx does not match on the ip as a vhost. This no basically replaces
the commented out section in the nginx.conf
2017-01-06 22:09:10 +01:00
Girish Ramakrishnan a3dc641be1 Skip sending heartbeat if we have no fqdn 2017-01-06 09:42:56 -08:00
Johannes Zellner a59f179e9d warn the user in manual and wildcard cert case 2017-01-06 18:42:22 +01:00
Johannes Zellner 4128bc437b Ensure text is center in the footer 2017-01-06 18:23:59 +01:00
Johannes Zellner e1b176594a The matching location needs to be my.domain 2017-01-06 18:17:27 +01:00
Johannes Zellner 35b11d7b22 Add footers to the setup views 2017-01-06 17:57:22 +01:00
Johannes Zellner bd65e1f35d Put some redirects in the setup pages to end up in the correct one always 2017-01-06 17:25:24 +01:00
Johannes Zellner a243478fff Create separate ip and my. domain nginx configs 2017-01-06 16:01:49 +01:00
Johannes Zellner f0fdc00e78 Always setup an nginx config for ip as the webadmin config 2017-01-06 12:42:21 +01:00
Johannes Zellner a21210ab29 Fix bug where we check for mail dns records without mail being enabled 2017-01-06 12:20:48 +01:00
Johannes Zellner 684e7df939 At least resolve nameservers for dns settings validator 2017-01-06 11:08:10 +01:00
Johannes Zellner 9be5f5d837 If we already have a domain set, directly wait for dns 2017-01-06 10:54:56 +01:00
Johannes Zellner 6c5fb67b58 Give the actual domain in status if set
This allows the webui served up on ip to redirect correctly
2017-01-06 10:47:42 +01:00
Girish Ramakrishnan 616ec408d6 Remove redundant reboot message 2017-01-06 10:23:10 +01:00
Girish Ramakrishnan 5969b4825c dns_ready is not required since it is part of status 2017-01-06 10:23:10 +01:00
Girish Ramakrishnan 64c888fbdb Send config state as part of the status 2017-01-06 10:23:10 +01:00
Girish Ramakrishnan 8a0fe413ba Visit IP if no domain provided 2017-01-06 10:23:10 +01:00
Girish Ramakrishnan 270a1f4b95 Merge gIsConfigured into config state 2017-01-06 10:23:10 +01:00
Girish Ramakrishnan 8f4ed47b63 track the config state in cloudron.js 2017-01-06 10:23:10 +01:00
Girish Ramakrishnan 09997398b1 Disallow dnsSetup if domain already set 2017-01-06 10:23:10 +01:00
Girish Ramakrishnan 0b68d1c9aa Reconfigure admin when domain gets set 2017-01-06 10:23:10 +01:00
Girish Ramakrishnan cc9904c8c7 Move nginx config and cert generation to box code 2017-01-06 10:23:10 +01:00
Girish Ramakrishnan 16ab523cb2 Store IP certs as part of nginx cert dir (otherwise, it will get backed up) 2017-01-06 10:23:10 +01:00
Girish Ramakrishnan 20a75b7819 tag -> prefix 2017-01-05 23:20:02 -08:00
Girish Ramakrishnan 49e299b62d Add ubuntu-standard
Fixes #170
2017-01-05 14:05:46 -08:00
Girish Ramakrishnan 98a2090c72 install curl and python before using them 2017-01-05 14:03:30 -08:00
Johannes Zellner 38c542b05a Add route to check dns and cert status 2017-01-05 20:37:26 +01:00
Johannes Zellner fc5fa621f3 Ensure the dkim folder for the domain exists 2017-01-05 17:14:27 +01:00
Johannes Zellner 6ec1a75cbb Ensure Dkim key in the readDkimPublicKeySync() function 2017-01-05 17:04:03 +01:00
Johannes Zellner bbba16cc9a make input fields shorter 2017-01-05 16:35:38 +01:00
Johannes Zellner 564d3d563c Preselect dns provider if possible 2017-01-05 16:32:34 +01:00
Johannes Zellner a858a4b4c1 Let the user know what we are waiting for 2017-01-05 16:31:23 +01:00
Johannes Zellner 2d6d8a7ea8 Create fallback certs only if fqdn is already set 2017-01-05 16:29:10 +01:00
Johannes Zellner 5b5ed9e043 Always create box/mail/dkim folder 2017-01-05 16:15:00 +01:00
Johannes Zellner 801c40420c Create setup nginx config and cert for ip setup 2017-01-05 16:02:03 +01:00
Johannes Zellner c185b3db71 Set correct busy states in setup views 2017-01-05 15:59:07 +01:00
Johannes Zellner 0f70b73e81 Cleanup some of the setup html code 2017-01-05 14:43:18 +01:00
Johannes Zellner d9865f9b0f Allow box to startup without fqdn 2017-01-05 14:02:04 +01:00
Johannes Zellner 59deb8b708 Do not fire configured event if no fqdn is set 2017-01-05 13:05:36 +01:00
Johannes Zellner 617fa98dee Further improve the dns setup ui 2017-01-05 12:31:37 +01:00
Johannes Zellner c9cb1cabc4 Improve dns setup ui 2017-01-05 12:08:52 +01:00
Johannes Zellner 92ab6b5aa4 Cleanup the dns setup code 2017-01-05 11:53:45 +01:00
Johannes Zellner a66f250350 Redirect to setupdns.html for non caas if not activated 2017-01-05 11:53:23 +01:00
Johannes Zellner 39200f4418 Add client.js wrapper for dns setup route 2017-01-05 11:53:05 +01:00
Johannes Zellner 4f1c7742ef Add public route for dns setup
This route is only available until the Cloudron is activated and also
only in self-hosted ones
2017-01-05 11:52:38 +01:00
Johannes Zellner e812cbcbe9 add setupdns to gulpfile 2017-01-05 11:17:39 +01:00
Johannes Zellner 2e0670a5c1 Strip dns setup from normal setup.html 2017-01-05 11:02:52 +01:00
Johannes Zellner 92c92db595 Add separate file for dns setup 2017-01-05 11:02:43 +01:00
Johannes Zellner 1764567e1f Make domain optional in cloudron-setup 2017-01-05 10:49:41 +01:00
Johannes Zellner 7eeb8bcac1 Only mark dns fields red if dirty and invalid 2017-01-05 10:49:41 +01:00
Johannes Zellner c718b4ccdd ngEnter directive is now unused 2017-01-05 10:49:41 +01:00
Johannes Zellner 4f5ffc92a6 Cleanup setup.js 2017-01-05 10:49:41 +01:00
Johannes Zellner 4c485f7bd0 Remove old setup wizard step templates 2017-01-05 10:49:41 +01:00
Johannes Zellner 7076a31821 Also send domain with dns credentials 2017-01-05 10:49:41 +01:00
Johannes Zellner 68965f6da3 Change the location to the new domain at the end of setup 2017-01-05 10:49:41 +01:00
Johannes Zellner b6a545d1f5 Add separate entry for wildcard in dns setup
Fixes #168
2017-01-05 10:49:41 +01:00
Johannes Zellner c0afff4d13 Add view for dns credentials in setup 2017-01-05 10:49:41 +01:00
Johannes Zellner 604faa6669 Skip forward for caas after admin setup 2017-01-05 10:49:41 +01:00
Johannes Zellner d94d1af7f5 Avoid angular flicker in setup 2017-01-05 10:49:41 +01:00
Johannes Zellner 9feb5dedd5 Remove all the wizard step logic from setup 2017-01-05 10:49:41 +01:00
Johannes Zellner 99948c4ed5 Use class nesting for setup 2017-01-05 10:49:41 +01:00
Girish Ramakrishnan 967bab678d Fix listing of app backups
The id can now contain path and not just the filename
2017-01-05 01:03:44 -08:00
Girish Ramakrishnan 135c296ac7 Remove the Z suffix 2017-01-05 00:12:31 -08:00
Girish Ramakrishnan e83ee48ed5 Pass collation tag to backup functions
Fixes #159
2017-01-05 00:10:16 -08:00
Girish Ramakrishnan 1539fe0906 preserve msecs portion in backup file format
this is required because the second precision causes backups to fail
because of duplicate file name. this happens in tests.

part of #159
2017-01-04 21:57:03 -08:00
Girish Ramakrishnan c06bddd19e Fix backup filename prefix in sql query 2017-01-04 21:41:31 -08:00
Girish Ramakrishnan ceb78f21bb remove redundant reuseOldAppBackup 2017-01-04 21:20:36 -08:00
Girish Ramakrishnan 5af201d4ee remove unused require 2017-01-04 19:37:39 -08:00
Girish Ramakrishnan 794efb5ef5 Merge backupDone webhook into caas storage backend 2017-01-04 16:29:25 -08:00
Girish Ramakrishnan 31a9437b2c Add backupDone hook 2017-01-04 16:23:12 -08:00
Girish Ramakrishnan 2b27e554fd Change backup filenames
appbackup_%s_%s-v%s.tar.gz -> app_%s_%s_v%s.tar.gz
    drop 'backup'. rationale: it is known these files are backups
    timestamp has '-'. rationale: colon in filename confuses tools like scp (they think it is a hostname)

backup_%s-v%s.tar.gz -> box_%s_v%s.tar.gz
    drop 'backup' and name it 'box'. this makes it clear it related to the box backup
    timestamp has '-'. rationale: colon in filename confuses tools like scp (they think it is a hostname)

Part of #159
2017-01-04 13:36:25 -08:00
Girish Ramakrishnan 4784b7b00e Fix coding style 2017-01-04 13:36:16 -08:00
Girish Ramakrishnan e547a719f6 remove dead code 2017-01-04 13:35:39 -08:00
Johannes Zellner 24f2d201ed Remove ip cache in sysinfo 2017-01-04 21:40:47 +01:00
Girish Ramakrishnan 792dfc731c Revert "Make virtualbox 20GB vdi work"
This reverts commit 67d840a1b3.

Change the docs for virtualbox for now to create a bigger VDI
2017-01-04 10:14:57 -08:00
Johannes Zellner 6697b39e79 Set password digest explicitly
sha1 used to be the fallback but with node 6.* the fallback is deprecated
2017-01-04 09:59:14 -08:00
Girish Ramakrishnan db1eeff2c3 Add test to check if user can be readded after removal
Fixes #162
2017-01-03 19:12:00 -08:00
Girish Ramakrishnan fc624701bf Use cloudron-setup from CDN
Fixes #165
2017-01-03 15:39:17 -08:00
Girish Ramakrishnan 591cc52944 Run initializeBaseImage script from the release tarball
Part of #165
2017-01-03 14:48:39 -08:00
Girish Ramakrishnan 67d840a1b3 Make virtualbox 20GB vdi work 2017-01-03 14:30:59 -08:00
Girish Ramakrishnan 8ffa951407 Clearly mark message as an error 2017-01-03 14:28:04 -08:00
Girish Ramakrishnan af39c2c7ae Replace cloudron-version with a python script
This will allow us to check version without node installed

Part of #165
2017-01-03 14:23:00 -08:00
Girish Ramakrishnan 5903c7d0bc remove x-bit from logcollector.js 2017-01-03 09:46:53 -08:00
Johannes Zellner dbb79fc9e6 Remove unused customDomain check in setup flow 2017-01-03 14:58:41 +01:00
Johannes Zellner ef1408fddb Remove unsed vars in cloudron-setup 2017-01-03 09:26:08 +01:00
Johannes Zellner 47ecb0e1cf Test minimum requirements before continue in cloudron-setup
Fixes #153
2017-01-02 18:03:28 +01:00
Johannes Zellner 55fad3d57e Convert booleans for the correct object 2017-01-02 14:15:20 +01:00
Johannes Zellner 496a44d412 Also update app dns records in dynamic dns case 2017-01-02 14:00:07 +01:00
Johannes Zellner 05721f73cc Fix typo 2017-01-02 13:51:58 +01:00
Johannes Zellner 424c36ea49 Convert boolean settings values
The db table only stores strings
2017-01-02 13:47:51 +01:00
Johannes Zellner a38097e2f5 Refresh dns if dynamic dns is enabled 2017-01-02 13:14:03 +01:00
Johannes Zellner b26cb4d339 Add dynamic dns settings key 2017-01-02 13:05:48 +01:00
Johannes Zellner 3523974163 Add initial refreshDNS() function 2017-01-02 13:00:30 +01:00
Johannes Zellner a2bdd294a8 update the version tag in the selfhosting docs 2017-01-01 17:17:24 +01:00
Girish Ramakrishnan f85bfdf451 Explain what the MB is 2016-12-31 09:39:17 -08:00
242 changed files with 16978 additions and 6523 deletions
+107
View File
@@ -698,3 +698,110 @@
[0.93.0]
* Smoother upgrades
[0.94.0]
* Cloudron domain can now be set after installation
* Backups are now organized by directory
* Document upgrading from Filesystem backend
* Send certificate renewal errors, OOM errors to cloudron admins
* Email bounce alerts are sent to the Cloudron owner
[0.94.1]
* Suppress upgrade emails
* Enable unattended upgrades
* Standardize on using devicemapper for docker storage backend
* Show detailed backup progress
* Fix DNSBL issue in mail container
* Fix issue where bounce emails were not sent to aliases
* Remove tutorial
* Restart mail container on certificate change
[0.97.0]
* Fix missing app icon issue
* Fix issue where box sends out crash reports incessantly
* (API) Allow memory limit to be set to -1 (unlimited)
* (API) Move developmentMode flag from manifest to apps route
[0.98.0]
* Send stat on whether email is enabled
* Fix bug where heartbeat was sent for self-hosted Cloudrons
* Make Cloudron function even when disk is full
* Fix thunderbird connection issue
* Send more detailed logs for backup failures
* Restart nginx if it crashed automatically
* Support all DNS providers for managed Cloudrons
* Add granular configuration for auto-updates
[0.99.0]
* Fix bug where ports <= 1023 were not reserved
* Cleanup graphs UI
* Polish webadmin UI
* Fix bug where hard disk size was detected incorrectly
[0.99.1]
* Fix bug with duplicate nginx configs
[0.100.0]
* Improve DNS notifications for email
* Do not enable HSTS for subdomains
[0.100.1]
* Fix crash when fetching mail records
* Fix crash in LDAP server when username and displayName are empty
[0.101.0]
* New base image 0.10.0
* Better error handling of unpurchase errors
* Validate that cloudron domain name is a subdomain of public suffic list
* Add canada and london to S3 backup regions
* Bundle Font Awesome as part of webadmin
* Fix crash in custom certiicate validation
* Get A+ rating in SSL Check
* More robust detection and injection of SPF record
* Add azure, lightsail, linode, ovh, vultr to provider list
[0.102.0]
* Fix issue where SPF record check was only done 5 times (updated 'async')
* Make auto-generated self-signed cert load quickly on Firefox
* Ensure we download docker images and have an app data volume on app re-configure
* Improve certificate renewal erorr message
* Fix disk usage graph
* Show Repair UI for errored apps
[0.102.1]
* Add terms link when signing up for Cloudron.io account
* Fix issue where Cloudrons with many apps (> 35) were unable to backup
* Improve wording of DNS Setup
[0.103.0]
* Do not send crash logs and other notifications to support@cloudron.io for self-hosted instances
* Make auto-generated self-signed cert load quickly on Firefox (take 2)
[0.104.0]
* (mail) Fix crash when sending mails to groups with just 1 user
* (ldap) Add isadmin attribute to better map users in apps
* (ldap) Hide users which have not yet set a username in ldap searches
* (core) Add SSH authorized_keys management
* (core) Add additional security related headers to the nginx reverse proxy
* (ui) Add remote SSH support option
* (ui) Fix eventlog display
* (ui) Fix CNAME setup information
[0.105.0]
* Always show email related checks
* Show outbound SMTP port 25 status
* Hide remote feature for normal users
* Only list users via ldap searches who have access to the app
* Fix installation issue on servers with a differente locale set
[0.105.1]
* Fix crash when setupToken is not provided in activate API
* Add inline Docker GPG key
* Re-download icon when repairing app
* Fix issue where pre-installed apps were not installed correctly
* Fix issue where new cloudrons could not be activated
[0.106.0]
* (mail) Fix email forwarding to external domains
* (mail) Set maximum email size to 25MB
* Remove SimpleAuth addon
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 14 KiB

+193
View File
@@ -0,0 +1,193 @@
#!/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 ""
+1 -1
View File
@@ -31,7 +31,7 @@ function create_droplet() {
local image_region="sfo1"
local ubuntu_image_slug="ubuntu-16-04-x64"
local box_size="512mb"
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}"
+70 -26
View File
@@ -2,10 +2,11 @@
set -euv -o pipefail
readonly PROVIDER="${1:-generic}"
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
@@ -16,26 +17,12 @@ export DEBIAN_FRONTEND=noninteractive
apt-get -o Dpkg::Options::="--force-confdef" update -y
apt-get -o Dpkg::Options::="--force-confdef" dist-upgrade -y
# https://docs.docker.com/engine/installation/linux/ubuntulinux/
echo "==> Installing Docker"
apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" > /etc/apt/sources.list.d/docker.list
apt-get -y update
apt-get -y install \
aufs-tools \
linux-image-extra-$(uname -r) \
linux-image-extra-virtual \
docker-engine=1.12.5-0~ubuntu-xenial # apt-cache madison docker-engine
echo "==> Enable memory accounting"
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 "==> 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)
apt-get -y install \
acl \
awscli \
@@ -43,6 +30,7 @@ apt-get -y install \
build-essential \
cron \
curl \
dmsetup \
iptables \
logrotate \
mysql-server-5.7 \
@@ -51,6 +39,7 @@ apt-get -y install \
pwgen \
rcconf \
swaks \
unattended-upgrades \
unbound
echo "==> Installing node.js"
@@ -61,18 +50,73 @@ ln -sf /usr/local/node-6.9.2/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"
echo "==> Downloading docker images"
if [ -f ${SOURCE_DIR}/infra_version.js ]; then
images=$(node -e "var i = require('${SOURCE_DIR}/infra_version.js'); console.log(i.baseImages.join(' '), Object.keys(i.images).map(function (x) { return i.images[x].tag; }).join(' '));")
# https://docs.docker.com/engine/installation/linux/ubuntulinux/
echo "==> Installing Docker"
docker_key="-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1
echo "Pulling images: ${images}"
for image in ${images}; do
docker pull "${image}"
done
else
echo "No infra_versions.js found, skipping image download"
mQINBFWln24BEADrBl5p99uKh8+rpvqJ48u4eTtjeXAWbslJotmC/CakbNSqOb9o
ddfzRvGVeJVERt/Q/mlvEqgnyTQy+e6oEYN2Y2kqXceUhXagThnqCoxcEJ3+KM4R
mYdoe/BJ/J/6rHOjq7Omk24z2qB3RU1uAv57iY5VGw5p45uZB4C4pNNsBJXoCvPn
TGAs/7IrekFZDDgVraPx/hdiwopQ8NltSfZCyu/jPpWFK28TR8yfVlzYFwibj5WK
dHM7ZTqlA1tHIG+agyPf3Rae0jPMsHR6q+arXVwMccyOi+ULU0z8mHUJ3iEMIrpT
X+80KaN/ZjibfsBOCjcfiJSB/acn4nxQQgNZigna32velafhQivsNREFeJpzENiG
HOoyC6qVeOgKrRiKxzymj0FIMLru/iFF5pSWcBQB7PYlt8J0G80lAcPr6VCiN+4c
NKv03SdvA69dCOj79PuO9IIvQsJXsSq96HB+TeEmmL+xSdpGtGdCJHHM1fDeCqkZ
hT+RtBGQL2SEdWjxbF43oQopocT8cHvyX6Zaltn0svoGs+wX3Z/H6/8P5anog43U
65c0A+64Jj00rNDr8j31izhtQMRo892kGeQAaaxg4Pz6HnS7hRC+cOMHUU4HA7iM
zHrouAdYeTZeZEQOA7SxtCME9ZnGwe2grxPXh/U/80WJGkzLFNcTKdv+rwARAQAB
tDdEb2NrZXIgUmVsZWFzZSBUb29sIChyZWxlYXNlZG9ja2VyKSA8ZG9ja2VyQGRv
Y2tlci5jb20+iQI4BBMBAgAiBQJVpZ9uAhsvBgsJCAcDAgYVCAIJCgsEFgIDAQIe
AQIXgAAKCRD3YiFXLFJgnbRfEAC9Uai7Rv20QIDlDogRzd+Vebg4ahyoUdj0CH+n
Ak40RIoq6G26u1e+sdgjpCa8jF6vrx+smpgd1HeJdmpahUX0XN3X9f9qU9oj9A4I
1WDalRWJh+tP5WNv2ySy6AwcP9QnjuBMRTnTK27pk1sEMg9oJHK5p+ts8hlSC4Sl
uyMKH5NMVy9c+A9yqq9NF6M6d6/ehKfBFFLG9BX+XLBATvf1ZemGVHQusCQebTGv
0C0V9yqtdPdRWVIEhHxyNHATaVYOafTj/EF0lDxLl6zDT6trRV5n9F1VCEh4Aal8
L5MxVPcIZVO7NHT2EkQgn8CvWjV3oKl2GopZF8V4XdJRl90U/WDv/6cmfI08GkzD
YBHhS8ULWRFwGKobsSTyIvnbk4NtKdnTGyTJCQ8+6i52s+C54PiNgfj2ieNn6oOR
7d+bNCcG1CdOYY+ZXVOcsjl73UYvtJrO0Rl/NpYERkZ5d/tzw4jZ6FCXgggA/Zxc
jk6Y1ZvIm8Mt8wLRFH9Nww+FVsCtaCXJLP8DlJLASMD9rl5QS9Ku3u7ZNrr5HWXP
HXITX660jglyshch6CWeiUATqjIAzkEQom/kEnOrvJAtkypRJ59vYQOedZ1sFVEL
MXg2UCkD/FwojfnVtjzYaTCeGwFQeqzHmM241iuOmBYPeyTY5veF49aBJA1gEJOQ
TvBR8Q==
=Fm3p
-----END PGP PUBLIC KEY BLOCK-----
"
echo "$docker_key" | apt-key add -
echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" > /etc/apt/sources.list.d/docker.list
apt-get -y update
# create systemd drop-in file
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=devicemapper" > /etc/systemd/system/docker.service.d/cloudron.conf
apt-get -y --allow-downgrades install docker-engine=1.12.5-0~ubuntu-xenial # apt-cache madison docker-engine
apt-mark hold docker-engine # do not update docker
storage_driver=$(docker info | grep "Storage Driver" | sed 's/.*: //')
if [[ "${storage_driver}" != "devicemapper" ]]; then
echo "Docker is using "${storage_driver}" instead of devicemapper"
exit 1
fi
echo "==> Enable memory accounting"
apt-get -y install grub2
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.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}"
done
echo "==> Install collectd"
if ! apt-get install -y collectd collectd-utils; then
# FQDNLookup is true in default debian config. The box code has a custom collectd.conf that fixes this
+3 -8
View File
@@ -5,17 +5,15 @@
require('supererror')({ splatchError: true });
// remove timestamp from debug() based output
require('debug').formatArgs = function formatArgs() {
arguments[0] = this.namespace + ' ' + arguments[0];
return arguments;
require('debug').formatArgs = function formatArgs(args) {
args[0] = this.namespace + ' ' + args[0];
};
var appHealthMonitor = require('./src/apphealthmonitor.js'),
async = require('async'),
config = require('./src/config.js'),
ldap = require('./src/ldap.js'),
server = require('./src/server.js'),
simpleauth = require('./src/simpleauth.js');
server = require('./src/server.js');
console.log();
console.log('==========================================');
@@ -34,7 +32,6 @@ console.log();
async.series([
server.start,
ldap.start,
simpleauth.start,
appHealthMonitor.start,
], function (error) {
if (error) {
@@ -49,13 +46,11 @@ var NOOP_CALLBACK = function () { };
process.on('SIGINT', function () {
server.stop(NOOP_CALLBACK);
ldap.stop(NOOP_CALLBACK);
simpleauth.stop(NOOP_CALLBACK);
setTimeout(process.exit.bind(process), 3000);
});
process.on('SIGTERM', function () {
server.stop(NOOP_CALLBACK);
ldap.stop(NOOP_CALLBACK);
simpleauth.stop(NOOP_CALLBACK);
setTimeout(process.exit.bind(process), 3000);
});
-64
View File
@@ -318,67 +318,3 @@ cloudron exec
> swaks --server "${MAIL_SMTP_SERVER}" -p "${MAIL_SMTP_PORT}" --from "${MAIL_SMTP_USERNAME}@${MAIL_DOMAIN}" --body "Test mail from cloudron app at $(hostname -f)" --auth-user "${MAIL_SMTP_USERNAME}" --auth-password "${MAIL_SMTP_PASSWORD}"
```
## simpleauth
Simple Auth can be used for authenticating users with a HTTP request. This method of authentication is targeted
at applications, which for whatever reason can't use the ldap addon.
The response contains an `accessToken` which can then be used to access the [Cloudron API](/references/api.html).
Exported environment variables:
```
SIMPLE_AUTH_SERVER= # the simple auth HTTP server
SIMPLE_AUTH_PORT= # the simple auth server port
SIMPLE_AUTH_URL= # the simple auth server URL. same as "http://SIMPLE_AUTH_SERVER:SIMPLE_AUTH_PORT
SIMPLE_AUTH_CLIENT_ID # a client id for identifying the request originator with the auth server
```
This addons provides two REST APIs:
**POST /api/v1/login**
Request JSON body:
```
{
"username": "<username> or <email>",
"password": "<password>"
}
```
Response 200 with JSON body:
```
{
"accessToken": "<accessToken>",
"user": {
"id": "<userId>",
"username": "<username>",
"email": "<email>",
"admin": <admin boolean>,
"displayName": "<display name>"
}
}
```
**GET /api/v1/logout**
Request params:
```
?access_token=<accessToken>
```
Response 200 with JSON body:
```
{}
```
For debugging, [cloudron exec](https://www.npmjs.com/package/cloudron) can be used to run the `curl` tool within the context of the app:
```
cloudron exec
> USERNAME=<enter username>
> PASSWORD=<enter password>
> PAYLOAD="{\"clientId\":\"${SIMPLE_AUTH_CLIENT_ID}\", \"username\":\"${USERNAME}\", \"password\":\"${PASSWORD}\"}"
> curl -H "Content-Type: application/json" -X POST -d "${PAYLOAD}" "${SIMPLE_AUTH_ORIGIN}/api/v1/login"
```
+48 -26
View File
@@ -62,7 +62,7 @@ curl -H "Content-Type: application/json" -H "Authorization: Bearer <token>" http
## OAuth
OAuth authentication is meant to be used by apps. An app can get an OAuth token using the
[oauth](addons.html#oauth) or [simpleauth](addons.html#simpleauth) addon.
[oauth](addons.html#oauth) addon.
Tokens obtained via OAuth have a restricted scope wherein they can only access the user's profile.
This restriction is so that apps cannot make undesired changes to the user's Cloudron.
@@ -151,6 +151,8 @@ If `altDomain` is set, the app can be accessed from `https://<altDomain>`.
* `SAMEORIGIN` - allows embedding from the same domain as the app. This is the default.
* `ALLOW-FROM https://example.com/` - allows this app to be embedded from example.com
`memoryLimit` is the maximum memory this app can use (in bytes) including swap. If set to 0, the app uses the `memoryLimit` value set in the manifest. If set to -1, the app gets unlimited memory.
Read more about the options at [MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options).
Response (200):
@@ -197,7 +199,8 @@ Response (200):
health: <enum>, // health of the application
location: <string>, // subdomain on which app is installed
fqdn: <string>, // the FQDN of this app
altDomain: <string> // alternate domain from which this app can be reached
altDomain: <string>, // alternate domain from which this app can be reached
cnameTarget: <string> || null, // If altDomain is set, this contains the CNAME location for the app
accessRestriction: null || { // list of users and groups who can access this application
users: [ ],
groups: [ ]
@@ -207,7 +210,8 @@ Response (200):
portBindings: { // mapping from application ports to public ports
},
iconUrl: <url>, // a relative url providing the icon
memoryLimit: <number> // memory constraint in bytes
memoryLimit: <number>, // memory constraint in bytes
sso: <boolean> // Enable single sign-on
}
```
@@ -255,6 +259,8 @@ is integrated with Cloudron Authentication.
`manifest` is the [application manifest](/references/manifest.html).
For apps that support optional single sign-on, the `sso` field can be used to disable Cloudron authentication. By default, single sign-on is enabled.
### List apps
GET `/api/v1/apps/:appId` <scope>admin</scope>
@@ -276,7 +282,8 @@ Response (200):
health: <enum>, // health of the application
location: <string>, // subdomain on which app is installed
fqdn: <string>, // the FQDN of this app
altDomain: <string> // alternate domain from which this app can be reached
altDomain: <string>, // alternate domain from which this app can be reached
cnameTarget: <string> || null, // If altDomain is set, this contains the CNAME location for the app
accessRestriction: null || { // list of users and groups who can access this application
users: [ ],
groups: [ ]
@@ -447,7 +454,7 @@ POST `/api/v1/apps/:appId/configure` <scope>admin</scope>
Re-configures an existing app with id `appId`.
Configuring an app won't preserve existing data. Cloudron apps are written in a way to support reconfiguring
Configuring an app preserves existing data. Cloudron apps are written in a way to support reconfiguring
any of the parameters listed below without loss of data.
Request:
@@ -652,6 +659,38 @@ curl -L <url> | openssl aes-256-cbc -d -pass "pass:$<backupKey>" | tar -zxf -
## Cloudron
### Activate the Cloudron
POST `/api/v1/cloudron/activate`
Activates the Cloudron with an admin username and password.
Request:
```
{
username: <string>, // the admin username
password: <string>, // the admin password
email: <email> // the admin email
}
```
Response (201):
```
{
"token": "771ee724a66aa557f95af06b4e6c27992f9230f6b1d65d5fbaa34cae9318d453",
"expires": 1490224113353
}
```
The `token` parameter can be used to make further API calls.
Curl example to activate the cloudron:
```
curl -X POST -H "Content-Type: application/json" -d '{"username": "girish", "password":"MySecret123#", "email": "girish@cloudron.io" }' https://my.cloudron.info/api/v1/cloudron/activate
```
### Update the Cloudron
POST `/api/v1/cloudron/update` <scope>admin</scope>
@@ -680,8 +719,9 @@ Gets information about an in-progress Cloudron update or backup.
`update` or `backup` is `null` when there is no such activity in progress.
```
Response (200):
```
{
update: null || { percent: <number>, message: <string> },
backup: null || { percent: <number>, message: <string> }
@@ -804,7 +844,7 @@ Response (200):
* user.remove
* user.update
`source` contains information on the originator of the action. For example, for user.login, this contains the IP address, the appId and the authType (ldap or simpleauth or oauth).
`source` contains information on the originator of the action. For example, for user.login, this contains the IP address, the appId and the authType (ldap or oauth).
`data` contains information on the event itself. For example, for user.login, this contains the userId that logged in. For app.install, it contains the manifest and location of the app that was installed.
@@ -964,24 +1004,6 @@ Response (204):
{}
```
### Tutorial
POST `/api/v1/profile/tutorial` <scope>profile</scope>
Toggles display of the tutorial when the token owner logs in.
Request:
```
{
showTutorial: <boolean>
}
```
Response (204):
```
{}
```
## Settings
### Get auto update pattern
@@ -1132,7 +1154,7 @@ POST `/api/v1/settings/mail_config` <scope>admin</scope> <scope>internal</scope>
Sets the email configuration. The Cloudron has a built-in email server for users.
This configuration can be used to enable or disable the email server. Note that
the Cloudron will always be able to send email on behalf of apps, regardless of
the Cloudron will always be able to send email on behalf of apps, regardless of
this setting.
Request:
-8
View File
@@ -29,7 +29,6 @@ Cloudron provides multiple authentication strategies.
* OAuth 2.0 provided by the [OAuth addon](/references/addons.html#oauth)
* LDAP provided by the [LDAP addon](/references/addons.html#ldap)
* Simple Auth provided by [Simple Auth addon](/references/addons.html#simpleauth)
# Choosing a strategy
@@ -44,13 +43,6 @@ Applications can be broadly categorized based on their user management as follow
* No user
* Such apps have no concept of logged-in user.
* The Cloudron provides a `website visibility` setting that allows a Cloudron admin to optionally
install an OAuth proxy in front of such applications. In such a case, a user visiting the website first
authenticates with the OAuth proxy and once authenticated is allowed into the application.
* When an OAuth proxy is installed, such applications can use the `X-Authenticated-User` header from the
[ICAP Extensions](https://tools.ietf.org/html/draft-stecher-icap-subid-00#section-3.4) de facto standard.
This value can be used for display purposes or creating meta data for a document.
* Single user
* Such apps only have a single user who is usually also the `admin`.
+8 -8
View File
@@ -1,6 +1,6 @@
# Overview
The application's Dockerfile must specify the FROM base image to be `cloudron/base:0.9.0`.
The application's Dockerfile must specify the FROM base image to be `cloudron/base:0.10.0`.
The base image already contains most popular software packages including node, nginx, apache,
ruby, PHP. Using the base image greatly reduces the size of app images.
@@ -17,16 +17,16 @@ install it yourself.
* Apache 2.4.18
* Composer 1.2.0
* Go 1.5.4, 1.6.3
* Go 1.6.4, 1.7.5 (install under `/usr/local/go-<version>`)
* Gunicorn 19.4.5
* Java 1.8
* Maven 3.3.9
* Mongo 2.6.10
* MySQL Client 5.7.13
* MySQL Client 5.7.17
* nginx 1.10.0
* Node 0.10.40, 0.12.7, 4.2.6, 4.4.7 (installed under `/usr/local/node-<version>`) [more information](#node-js)
* Node 0.10.48, 0.12.18, 4.7.3, 6.9.5 (installed under `/usr/local/node-<version>`) [more information](#node-js)
* Perl 5.22.1
* PHP 7.0.8
* PHP 7.0.13
* Postgresql client 9.5.4
* Python 2.7.12
* Redis 3.0.6
@@ -41,16 +41,16 @@ The base image can be inspected by installing [Docker](https://docs.docker.com/i
Once installed, pull down the base image locally using the following command:
```
docker pull cloudron/base:0.9.0
docker pull cloudron/base:0.10.0
```
To inspect the base image:
```
docker run -ti cloudron/base:0.9.0 /bin/bash
docker run -ti cloudron/base:0.10.0 /bin/bash
```
*Note:* Please use `docker 1.9.0` or above to pull the base image. Doing otherwise results in a base
image with an incorrect image id. The image id of `cloudron/base:0.9.0` is `d038af182821`.
image with an incorrect image id. The image id of `cloudron/base:0.10.0` is `5ec8ca8525be`.
# The `cloudron` user
+11 -38
View File
@@ -47,12 +47,14 @@ Type: object
Required: no
Allowed keys
* [email](addons.html#email)
* [ldap](addons.html#ldap)
* [localstorage](addons.html#localstorage)
* [mongodb](addons.html#mongodb)
* [mysql](addons.html#mysql)
* [oauth](addons.html#oauth)
* [postgresql](addons.html#postgresql)
* [recvmail](addons.html#recvmail)
* [redis](addons.html#redis)
* [sendmail](addons.html#sendmail)
@@ -76,7 +78,7 @@ The `author` field contains the name and email of the app developer (or company)
Example:
```
"author": "Cloudron Inc <girish@cloudron.io>"
"author": "Cloudron UG <girish@cloudron.io>"
```
## changelog
@@ -93,26 +95,6 @@ Example:
"changelog": "* Add support for IE8 \n* New logo"
```
## configurePath
Type: path string
Required: no
The `configurePath` can be used to specify the absolute path to the configuration / settings
page of the app. When this path is present, an absoluted URL is constructed from the app's
install location this path and presented to the user in the configuration dialog of the app.
This is useful for apps that have a main page which does not display a configuration / settings
url (i.e) it's hidden for aesthetic reasons. For example, a blogging app like wordpress might
keep the admin page url hidden in the main page. Setting the configurationPath makes the
configuration url discoverable by the user.
Example:
```
"configurePath": "/wp-admin"
```
## contactEmail
Type: email
@@ -150,20 +132,6 @@ Example:
"description:": "file://DESCRIPTION.md"
```
## developmentMode
Type: boolean
Required: no
Setting `developmentMode` to true disables readonly rootfs and the default memory limit. In addition,
the application *pauses* on start and can be started manually using `cloudron exec`. Note that you
cannot submit an app to the store with this field turned on.
This mode can be used to identify the files being modified by your application - often required to
debug situations where your app does not run on a readonly rootfs. Run your app using `cloudron exec`
and use `find / -mmin -30` to find file that have been changed or created in the last 30 minutes.
## healthCheckPath
Type: url path
@@ -186,9 +154,10 @@ Type: positive integer
Required: yes
The `httpPort` field contains the TCP port on which your app is listening for HTTP requests. This port
is exposed to the world via subdomain/location that the user chooses at installation time. While not
required, it is good practice to mark this port as `EXPOSE` in the Dockerfile.
The `httpPort` field contains the TCP port on which your app is listening for HTTP requests. This
is the HTTP port the Cloudron will use to access your app internally.
While not required, it is good practice to mark this port as `EXPOSE` in the Dockerfile.
Cloudron Apps are containerized and thus two applications can listen on the same port. In reality,
they are in different network namespaces and do not conflict with each other.
@@ -311,6 +280,10 @@ The intended use of this field is to display some post installation steps that t
complete the installation. For example, displaying the default admin credentials and informing the user to
to change it.
The message can have the following special tags:
* `<sso> ... </sso>` - Content in `sso` blocks are shown if SSO enabled.
* `<nosso> ... </nosso>`- Content in `nosso` blocks are shows when SSO is disabled.
## optionalSso
Type: boolean
+113 -98
View File
@@ -1,8 +1,7 @@
# Overview
The Cloudron platform can be installed on public cloud servers from EC2, Digital Ocean, Hetzner,
Linode, OVH, Scaleway, Vultr etc. Running Cloudron on a home server or company intranet is work
in progress.
Linode, OVH, Scaleway, Vultr etc. Cloudron also runs well on a home server or company intranet.
If you run into any trouble following this guide, ask us at our [chat](https://chat.cloudron.io).
@@ -20,32 +19,9 @@ The Cloudron requires a domain name when it is installed. Apps are installed int
The `my` subdomain is special and is the location of the Cloudron web interface. For this to
work, the Cloudron requires a way to programmatically configure the DNS entries of the domain.
Note that the Cloudron will never overwrite _existing_ DNS entries and refuse to install
apps on existing subdomains.
apps on existing subdomains (so, it is safe to reuse an existing domain that runs other services).
# CLI Tool
The [Cloudron tool](https://git.cloudron.io/cloudron/cloudron-cli) is useful for managing
a Cloudron. <b class="text-danger">The Cloudron CLI tool has to be run on a Laptop or PC</b>
## Linux & OS X
Installing the CLI tool requires node.js and npm. The CLI tool can be installed using the following command:
```
npm install -g cloudron
```
Depending on your setup, you may need to run this as root.
On OS X, it is known to work with the `openssl` package from homebrew.
See [#14](https://git.cloudron.io/cloudron/cloudron-cli/issues/14) for more information.
## Windows
The CLI tool does not work on Windows. Please contact us on our [chat](https://chat.cloudron.io) if you want to help with Windows support.
# Provider
# Cloud Server
DigitalOcean and EC2 (Amazon Web Services) are frequently tested by us.
@@ -58,32 +34,24 @@ In addition to those, the Cloudron community has successfully installed the plat
* [hosttech](https://www.hosttech.ch/?promocode=53619290)
* [Linode](https://www.linode.com/?r=f68d816692c49141e91dd4cef3305da457ac0f75)
* [OVH](https://www.ovh.com/)
* [Rosehosting](https://secure.rosehosting.com/clientarea/?affid=661)
* [Scaleway](https://www.scaleway.com/)
* [So you Start](https://www.soyoustart.com/)
* [Vultr](http://www.vultr.com/?ref=7063201)
* [Vultr](http://www.vultr.com/?ref=7110116-3B)
Please let us know if any of them requires tweaks or adjustments.
# Installing
## Choose Domain
A domain name is required when installing the Cloudron. Currently, only Second Level Domains
are supported. For example, `example.com`, `example.co.uk` will work fine. Choosing a domain
name at any other level like `cloudron.example.com` will not work.
The domain name must use one of the following name servers:
* AWS Route 53
* Digital Ocean
* Wildcard - If your domain does not use any of the name servers above, you can manually add
a wildcard (`*`) DNS entry.
You will have to provide the DNS API credentials after you complete the installation.
## Create server
Create an `Ubuntu 16.04 (Xenial)` server with at-least `1gb` RAM. Do not make any changes
to vanilla ubuntu. Be sure to allocate a static IPv4 address for your server.
Create an `Ubuntu 16.04 (Xenial)` server with at-least `1gb` RAM and 20GB disk space.
Do not make any changes to vanilla ubuntu. Be sure to allocate a static IPv4 address
for your server.
Cloudron has a built-in firewall and ports are opened and closed dynamically, as and when
apps are installed, re-configured or removed. For this reason, be sure to open all TCP and
UDP traffic to the server and leave the traffic management to the Cloudron.
### Linode
@@ -95,30 +63,19 @@ Since Linode does not manage SSH keys, be sure to add the public key to
Use the [boot script](https://github.com/scaleway-community/scaleway-docker/issues/2) to
enable memory accouting.
## Setup `my` subdomain
The Cloudron web interface is installed at the `my` subdomain of your domain.
Add a `A` DNS record for the `my` subdomain with the IP of the server created
above. Doing this will allow the Cloudron to start up with a valid TLS certificate.
## Run setup
SSH into your server and run the following commands:
```
wget https://git.cloudron.io/cloudron/box/raw/v0.92.1/scripts/cloudron-setup
wget https://cloudron.io/cloudron-setup
chmod +x cloudron-setup
./cloudron-setup --domain <domain> --provider <digitalocean|ec2|generic|scaleway>
./cloudron-setup --provider <azure|digitalocean|ec2|lightsail|linode|ovh|rosehosting|scaleway|vultr|generic>
```
The setup will take around 10-15 minutes.
`cloudron-setup` takes the following arguments:
* `--domain` is the domain name in which apps are installed. Currently, only Second Level
Domains are supported. For example, `example.com`, `example.co.uk`, `example.rocks` will
work fine. Choosing a domain name at any other level like `cloudron.example.com` will not
work.
**cloudron-setup** takes the following arguments:
* `--provider` is the name of your VPS provider. If the name is not on the list, simply
choose `generic`. In most cases, the `generic` provider mostly will work fine.
@@ -140,23 +97,17 @@ the latest version. You can set this to an older version when restoring a Cloudr
* `--restore-url` is a backup URL to restore from.
## Finish setup
## Domain setup
Once the setup script completes, the server will reboot, then visit `https://my.<domain>` to complete the installation.
Once the setup script completes, the server will reboot, then visit your server by its
IP address (`https://ip`) to complete the installation.
Please note the following:
The setup website will show a certificate warning. Accept the self-signed certificate
and proceed to the domain setup.
1. The website should already have a valid TLS certificate. If you see any certificate warnings, it means your Cloudron was not created correctly.
2. If you see a login screen, instead of a setup screen, it means that someone else got to your Cloudron first and set it up
already! In this unlikely case, simply delete the server and start over.
Once the setup is done, you can access the admin page in the future at `https://my.<domain>`.
## DNS
Cloudron has to be given the API credentials for configuring your domain under `Certs & Domains`
in the web UI.
Currently, only subdomains of the [Public Suffix List](https://publicsuffix.org/) are supported.
For example, `example.com`, `example.co.uk` will work fine. Choosing other non-registrable
domain names like `cloudron.example.com` will not work.
### Route 53
@@ -203,17 +154,21 @@ If your domain *does not* use Route 53 or Digital Ocean, setup a wildcard (`*`)
IP of the server created above. If your DNS provider has an API, please open an
[issue](https://git.cloudron.io/cloudron/box/issues) and we may be able to support it.
## Backups
## Finish Setup
Once the domain setup is done, the Cloudron will configure the DNS and get a SSL certificate. It will automatically redirect to `https://my.<domain>`.
# Backups
The Cloudron creates encrypted backups once a day. Each app is backed up independently and these
backups have the prefix `appbackup_`. The platform state is backed up independently with the
prefix `backup_`.
backups have the prefix `app_`. The platform state is backed up independently with the
prefix `box_`.
By default, backups reside in `/var/backups`. Please note that having backups reside in the same
physical machine as the Cloudron server instance is dangerous and it must be changed to
an external storage location like `S3` as soon as possible.
### Amazon S3
## Amazon S3
Provide S3 backup credentials in the `Settings` page and leave the endpoint field empty.
@@ -245,7 +200,10 @@ for most use-cases.
}
```
### Minio S3
The `Encryption key` is an arbitrary passphrase used to encrypt the backups. Keep the passphrase safe; it is
required to decrypt the backups when restoring the Cloudron.
## Minio S3
[Minio](https://minio.io/) is a distributed object storage server, providing the same API as Amazon S3.
Since Cloudron supports S3, any API compatible solution should be supported as well, if this is not the case, let us know.
@@ -270,6 +228,8 @@ The information to be copied to the Cloudron's backup settings form may look sim
<img src="/docs/img/minio_backup_config.png" class="shadow"><br/>
The `Encryption key` is an arbitrary passphrase used to encrypt the backups. Keep the passphrase safe; it is
required to decrypt the backups when restoring the Cloudron.
# Email
@@ -286,22 +246,61 @@ reputation should be easy to get back.
## Checklist
* Once your Cloudron is ready, setup a Reverse DNS PTR record to be setup for the `my` subdomain.
* If you are unable to receive mail, first thing to check is if your VPS provider lets you
receive mail on port 25.
* AWS/EC2 - Fill the PTR [request form](https://aws-portal.amazon.com/gp/aws/html-forms-controller/contactus/ec2-email-limit-rdns-request.
* Digital Ocean - New accounts frequently have port 25 blocked. Write to their support to
unblock your server.
* EC2, Lightsail & Scaleway - Edit your security group to allow email.
* Setup a Reverse DNS PTR record to be setup for the `my` subdomain.
**Note:** PTR records are a feature of your VPS provider and not your domain provider.
* You can verify the PTR record [https://mxtoolbox.com/ReverseLookup.aspx](here).
* AWS EC2 & Lightsail - Fill the [PTR request form](https://aws-portal.amazon.com/gp/aws/html-forms-controller/contactus/ec2-email-limit-rdns-request).
* Digital Ocean - Digital Ocean sets up a PTR record based on the droplet's name. So, simply rename
your droplet to `my.<domain>`.
your droplet to `my.<domain>`. Note that some new Digital Ocean accounts have [port 25 blocked](https://www.digitalocean.com/community/questions/port-25-smtp-external-access).
* Scaleway - Edit your security group to allow email. You can also set a PTR record on the interface with your
`my.<domain>`.
* Linode - Follow this [guide](https://www.linode.com/docs/networking/dns/setting-reverse-dns).
* Scaleway - Edit your security group to allow email and [reboot the server](https://community.online.net/t/security-group-not-working/2096) for the change to take effect. You can also set a PTR record on the interface with your `my.<domain>`.
* Check if your IP is listed in any DNSBL list [here](http://multirbl.valli.org/). In most cases,
you can apply for removal of your IP by filling out a form at the DNSBL manager site.
* When using wildcard or manual DNS backends, you have to setup the DMARC, MX records manually.
* Finally, check your spam score at [mail-tester.com](https://www.mail-tester.com/). The Cloudron
should get 100%, if not please let us know.
# CLI Tool
The [Cloudron tool](https://git.cloudron.io/cloudron/cloudron-cli) is useful for managing
a Cloudron. <b class="text-danger">The Cloudron CLI tool has to be installed & run on a Laptop or PC</b>
Once installed, you can install, configure, list, backup and restore apps from the command line.
## Linux & OS X
Installing the CLI tool requires node.js and npm. The CLI tool can be installed using the following command:
```
npm install -g cloudron
```
Depending on your setup, you may need to run this as root.
On OS X, it is known to work with the `openssl` package from homebrew.
See [#14](https://git.cloudron.io/cloudron/cloudron-cli/issues/14) for more information.
## Windows
The CLI tool does not work on Windows. Please contact us on our [chat](https://chat.cloudron.io) if you want to help with Windows support.
# Updates
Apps installed from the Cloudron Store are automatically updated every night.
@@ -318,24 +317,26 @@ case an update fails, it can be [restored](/references/selfhosting.html#restore)
### Upgrade
An **upgrade** requires a new OS image and thus involves creating the Cloudron from scratch.
This process involves creating a new server with the latest code and restoring it from the
last backup. Currently only Cloudrons using the **S3 backup storage** support upgrades.
Read more about [backup storage](#s3), otherwise contact us in our [chat](https://chat.cloudron.io).
An **upgrade** requires a new OS image. This process involves creating a new server from scratch
with the latest code and restoring it from the last backup.
To upgrade follow these steps closely:
* Create a new backup - `cloudron machine backup create <domain>`
* Create a new backup - `cloudron machine backup create`
* List the latest backup - `cloudron machine backup list <domain>`
* List the latest backup - `cloudron machine backup list`
* Make the latest box backup (files starting with `backup_`) public. This can be done from the AWS S3 console as seen here:
* Make the backup available for the new cloudron instance:
<img src="/docs/img/aws_backup_public.png" class="shadow haze"><br/>
* `S3` - When storing backup ins S3, make the latest box backup public - files starting with `box_` (from v0.94.0) or `backup_`. This can be done from the AWS S3 console as seen here:
* Copy the new public URL of the latest backup for use as the `--restore-url` below.
<img src="/docs/img/aws_backup_public.png" class="shadow haze"><br/>
<img src="/docs/img/aws_backup_link.png" class="shadow haze"><br/>
Copy the new public URL of the latest backup for use as the `--restore-url` below.
<img src="/docs/img/aws_backup_link.png" class="shadow haze"><br/>
* `File system` - When storing backups in `/var/backups`, you have to make the box and the app backups available to the new Cloudron instance's `/var/backups`. This can be achieved in a variety of ways depending on the situation: like scp'ing the backup files to the machine before installation, mounting the external backup hard drive into the new Cloudron's `/var/backup` OR downloading a copy of the backup using `cloudron machine backup download` and uploading them to the new machine. After doing so, pass `file:///var/backups/<path to box backup>` as the `--restore-url` below.
* Create a new Cloudron by following the [installing](/references/selfhosting.html#installing) section.
When running the setup script, pass in the `--encryption-key` and `--restore-url` flags.
@@ -344,24 +345,30 @@ To upgrade follow these steps closely:
Similar to the initial installation, a Cloudron upgrade looks like:
```
$ ssh root@newserverip
> wget https://git.cloudron.io/cloudron/box/raw/v0.92.1/scripts/cloudron-setup
> wget https://cloudron.io/cloudron-setup
> chmod +x cloudron-setup
> ./cloudron-setup --domain <domain> --provider <digitalocean|ec2|generic|scaleway> --encryption-key <key> --restore-url <publicS3Url>
> ./cloudron-setup --provider <digitalocean|ec2|generic|scaleway> --domain <example.com> --encryption-key <key> --restore-url <publicS3Url>
```
Note: When upgrading an old version of Cloudron (<= 0.94.0), pass the `--version 0.94.1` flag and then continue updating
from that.
* Finally, once you see the newest version being displayed in your Cloudron webinterface, you can safely delete the old server instance.
# Restore
To restore a Cloudron from a specific backup:
* Select the backup - `cloudron machine backup list <domain>`
* Select the backup - `cloudron machine backup list`
* Make the box backup public (this can be done from the S3 console). Also, copy the URL of
the backup for use as the `restore-url` below.
* Make the backup public
* `S3` - Make the box backup publicly readable - files starting with `box_` (from v0.94.0) or `backup_`. This can be done from the AWS S3 console. Once the box has restored, you can make it private again.
* `File system` - When storing backups in `/var/backups`, you have to make the box and the app backups available to the new Cloudron instance's `/var/backups`. This can be achieved in a variety of ways depending on the situation: like scp'ing the backup files to the new machine before Cloudron installation OR mounting an external backup hard drive into the new Cloudron's `/var/backup` OR downloading a copy of the backup using `cloudron machine backup download` and uploading them to the new machine. After doing so, pass `file:///var/backups/<path to box backup>` as the `--restore-url` below.
* Create a new Cloudron by following the [installing](/references/selfhosting.html#installing) section.
When running the setup script, pass in the `version`, `restore-key` and `restore-url` flags.
When running the setup script, pass in the `version`, `encryption-key`, `domain` and `restore-url` flags.
The `version` field is the version of the Cloudron that the backup corresponds to (it is embedded
in the backup file name).
@@ -375,6 +382,14 @@ You can SSH into your Cloudron and collect logs:
* `docker ps` will give you the list of containers. The addon containers are named as `mail`, `postgresql`,
`mysql` etc. If you want to get a specific container's log output, `journalctl -a CONTAINER_ID=<container_id>`.
# Alerts
The Cloudron will notify the Cloudron administrator via email if apps go down, run out of memory, have updates
available etc.
You will have to setup a 3rd party service like [Cloud Watch](https://aws.amazon.com/cloudwatch/) or [UptimeRobot](http://uptimerobot.com/) to monitor the Cloudron itself. You can use `https://my.<domain>/api/v1/cloudron/status`
as the health check URL.
# Help
If you run into any problems, join us at our [chat](https://chat.cloudron.io) or [email us](mailto:support@cloudron.io).
+3 -3
View File
@@ -75,7 +75,7 @@ A Dockerfile contains commands to assemble an image.
Create a file named `tutorial/Dockerfile` with the following content:
```dockerfile
FROM cloudron/base:0.9.0
FROM cloudron/base:0.10.0
ADD server.js /app/code/server.js
@@ -171,7 +171,7 @@ Login successful.
Build scheduled with id 76cebfdd-7822-4f3d-af17-b3eb393ae604
Downloading source
Building
Step 0 : FROM cloudron/base:0.9.0
Step 0 : FROM cloudron/base:0.10.0
---> 97583855cc0c
Step 1 : ADD server.js /app/code
---> b09b97ecdfbc
@@ -333,7 +333,7 @@ and modify our Dockerfile to look like this:
File `tutorial/Dockerfile`
```dockerfile
FROM cloudron/base:0.9.0
FROM cloudron/base:0.10.0
ADD server.js /app/code/server.js
ADD package.json /app/code/package.json
+21 -16
View File
@@ -5,8 +5,8 @@ This tutorial outlines how to package an existing web application for the Cloudr
If you are aware of Docker and Heroku, you should feel at home packaging for the
Cloudron. Roughly, the steps involved are:
* Create a Dockerfile for your application. If your application already has
a Dockerfile, you should able to reuse most of it. By virtue of Docker, the Cloudron
* Create a Dockerfile for your application. If your application already has a Dockerfile, it
is a good starting point for packaging for the Cloudron. By virtue of Docker, the Cloudron
is able to run apps written in any language/framework.
* Create a CloudronManifest.json that provides information like title, author, description
@@ -79,27 +79,27 @@ console.log("Server running at port 8000");
The Dockerfile contains instructions on how to create an image for your application.
```Dockerfile
FROM cloudron/base:0.9.0
FROM cloudron/base:0.10.0
ADD server.js /app/code/server.js
CMD [ "/usr/local/node-4.2.1/bin/node", "/app/code/server.js" ]
CMD [ "/usr/local/node-4.4.7/bin/node", "/app/code/server.js" ]
```
The `FROM` command specifies that we want to start off with Cloudron's [base image](/references/baseimage.html).
All Cloudron apps **must** start from this base image. This approach conserves space on the Cloudron since
Docker images tend to be quiet large.
Docker images tend to be quite large and also helps us to do a security audit on apps more easily.
The `ADD` command copies the source code of the app into the directory `/app/code`. There is nothing special
about the `/app/code` directory and it is merely a convention we use to store the application code.
The `CMD` command specifies how to run the server. The base image already contains many different versions of
node.js. We use Node 4.2.1 here.
node.js. We use Node 4.4.7 here.
This Dockerfile can be built and run locally as:
```
docker build -t tutorial .
docker run -p 8000:8000 -ti tutorial
docker run -p 8000:8000 -t tutorial
```
## Manifest
@@ -188,7 +188,7 @@ Build scheduled with id e7706847-f2e3-4ba2-9638-3f334a9453a5
Waiting for build to begin, this may take a bit...
Downloading source
Building
Step 1 : FROM cloudron/base:0.9.0
Step 1 : FROM cloudron/base:0.10.0
---> be9fc6312b2d
Step 2 : ADD server.js /app/code/server.js
---> 10513e428d7a
@@ -271,14 +271,18 @@ You can also execute arbitrary commands:
$ cloudron exec env # display the env variables that your app is running with
```
### DevelopmentMode
### Debugging
When debugging complex startup scripts, one can specify `"developmentMode": true,` in the CloudronManifest.json.
This will ignore the `RUN` command, specified in the Dockerfile and allows the developer to interactively test
the startup scripts using `cloudron exec`.
An app can be placed in `debug` mode by passing `--debug` to `cloudron install` or `cloudron configure`.
Doing so, runs the app in a non-readonly rootfs and unlimited memory. By default, this will also ignore
the `RUN` command specified in the Dockerfile. The developer can then interactively test the app and
startup scripts using `cloudron exec`.
**Note:** that an app running in this mode has full read/write access to the filesystem and all memory limits are lifted.
This mode can be used to identify the files being modified by your application - often required to
debug situations where your app does not run on a readonly rootfs. Run your app using `cloudron exec`
and use `find / -mmin -30` to find file that have been changed or created in the last 30 minutes.
You can turn off debugging mode using `cloudron configure --no-debug`.
# Addons
@@ -385,6 +389,8 @@ field in the manifest.
Design your application runtime for concurrent use by 50 users. The Cloudron is not designed for
concurrent access by 100s or 1000s of users.
An app can determine it's memory limit by reading `/sys/fs/cgroup/memory/memory.limit_in_bytes`.
## Authentication
Apps should integrate with one of the [authentication strategies](/references/authentication.html).
@@ -429,9 +435,8 @@ other Cloudron users. This can be done using:
cloudron upload
```
The app should now be visible in the Store view of your cloudron under
the 'Testing' section. You can check if the icon, description and other details
appear correctly.
You should now be able to visit `/#/appstore/<appid>?version=<appversion>` on your
Cloudron to check if the icon, description and other details appear correctly.
Other Cloudron users can install your app on their Cloudron's using
`cloudron install --appstore-id <appid@version>`.
+30 -4
View File
@@ -40,12 +40,21 @@ gulp.task('3rdparty', function () {
// JavaScript
// --------------
gulp.task('js', ['js-index', 'js-setup', 'js-update'], function () {});
if (argv.help || argv.h) {
console.log('Supported arguments for "gulp develop":');
console.log(' --client-id <clientId>');
console.log(' --client-secret <clientSecret>');
console.log(' --api-origin <cloudron api uri>');
process.exit(1);
}
gulp.task('js', ['js-index', 'js-setup', 'js-setupdns', 'js-update'], function () {});
var oauth = {
clientId: argv.clientId || process.env.CLOUDRON_CLIENT_ID || 'cid-webadmin',
clientSecret: argv.clientSecret || process.env.CLOUDRON_CLIENT_SECRET || 'unused',
apiOrigin: argv.apiOrigin || process.env.CLOUDRON_API_ORIGIN || ''
clientId: argv.clientId || 'cid-webadmin',
clientSecret: argv.clientSecret || 'unused',
apiOrigin: argv.apiOrigin || ''
};
console.log();
@@ -94,6 +103,22 @@ gulp.task('js-setup', function () {
.pipe(gulp.dest('webadmin/dist/js'));
});
gulp.task('js-setupdns', function () {
// needs special treatment for error handling
var uglifyer = uglify();
uglifyer.on('error', function (error) {
console.error(error);
});
gulp.src(['webadmin/src/js/setupdns.js', 'webadmin/src/js/client.js'])
.pipe(ejs({ oauth: oauth }, { ext: '.js' }))
.pipe(sourcemaps.init())
.pipe(concat('setupdns.js', { newLine: ';' }))
.pipe(uglifyer)
.pipe(sourcemaps.write())
.pipe(gulp.dest('webadmin/dist/js'));
});
gulp.task('js-update', function () {
// needs special treatment for error handling
var uglifyer = uglify();
@@ -162,6 +187,7 @@ gulp.task('watch', ['default'], function () {
gulp.watch(['webadmin/src/templates/*.html'], ['html-templates']);
gulp.watch(['webadmin/src/js/update.js'], ['js-update']);
gulp.watch(['webadmin/src/js/setup.js', 'webadmin/src/js/client.js'], ['js-setup']);
gulp.watch(['webadmin/src/js/setupdns.js', 'webadmin/src/js/client.js'], ['js-setupdns']);
gulp.watch(['webadmin/src/js/index.js', 'webadmin/src/js/client.js', 'webadmin/src/js/appstore.js', 'webadmin/src/js/main.js', 'webadmin/src/views/*.js'], ['js-index']);
gulp.watch(['webadmin/src/3rdparty/**/*'], ['3rdparty']);
});
+2 -2
View File
@@ -1,5 +1,5 @@
var dbm = require('db-migrate');
var type = dbm.dataType;
'use strict';
var url = require('url');
exports.up = function(db, callback) {
+1 -2
View File
@@ -1,5 +1,4 @@
var dbm = require('db-migrate');
var type = dbm.dataType;
'use strict';
var fs = require('fs'),
async = require('async'),
@@ -1,5 +1,4 @@
dbm = dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE users ADD COLUMN resetToken VARCHAR(128) DEFAULT ""', function (error) {
@@ -14,4 +13,3 @@ exports.down = function(db, callback) {
callback(error);
});
};
@@ -1,5 +1,4 @@
dbm = dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('DELETE FROM tokens', [], function (error) {
@@ -1,5 +1,4 @@
dbm = dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE authcodes ADD COLUMN expiresAt BIGINT NOT NULL', function (error) {
@@ -13,4 +12,4 @@ exports.down = function(db, callback) {
if (error) console.error(error);
callback(error);
});
};
};
@@ -1,5 +1,4 @@
dbm = dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE appPortBindings ADD COLUMN environmentVariable VARCHAR(128) NOT NULL', function (error) {
@@ -14,4 +13,3 @@ exports.down = function(db, callback) {
callback(error);
});
};
@@ -1,5 +1,4 @@
dbm = dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE appPortBindings DROP COLUMN containerPort', function (error) {
@@ -14,4 +13,3 @@ exports.down = function(db, callback) {
callback(error);
});
};
@@ -1,5 +1,4 @@
dbm = dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('DELETE FROM tokens', [], function (error) {
@@ -1,5 +1,4 @@
dbm = dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps DROP COLUMN version', function (error) {
@@ -14,4 +13,3 @@ exports.down = function(db, callback) {
callback(error);
});
};
@@ -1,5 +1,4 @@
dbm = dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps DROP COLUMN healthy, ADD COLUMN health VARCHAR(128)', [], function (error) {
@@ -1,5 +1,4 @@
dbm = dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN lastBackupId VARCHAR(128)', function (error) {
@@ -14,4 +13,3 @@ exports.down = function(db, callback) {
callback(error);
});
};
@@ -1,5 +1,4 @@
dbm = dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN createdAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP', function (error) {
@@ -14,4 +13,3 @@ exports.down = function(db, callback) {
callback(error);
});
};
@@ -1,5 +1,4 @@
dbm = dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
// everyday at 1am
@@ -8,5 +7,4 @@ exports.up = function(db, callback) {
exports.down = function(db, callback) {
db.runSql('DELETE * FROM settings WHERE name="autoupdate_pattern"', [ ], callback);
}
};
@@ -1,6 +1,6 @@
dbm = dbm || require('db-migrate');
'use strict';
var safe = require('safetydance');
var type = dbm.dataType;
exports.up = function(db, callback) {
var tz = safe.fs.readFileSync('/etc/timezone', 'utf8');
@@ -12,4 +12,3 @@ exports.up = function(db, callback) {
exports.down = function(db, callback) {
db.runSql('DELETE * FROM settings WHERE name="time_zone"', [ ], callback);
};
@@ -1,5 +1,5 @@
dbm = dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
var async = require('async');
exports.up = function(db, callback) {
@@ -1,5 +1,5 @@
dbm = dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
var async = require('async');
exports.up = function(db, callback) {
@@ -1,5 +1,4 @@
dbm = dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN lastManifestJson VARCHAR(2048)', function (error) {
@@ -14,4 +13,3 @@ exports.down = function(db, callback) {
callback(error);
});
};
@@ -1,5 +1,4 @@
var dbm = global.dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps CHANGE lastManifestJson lastBackupConfigJson VARCHAR(2048)', [], function (error) {
@@ -14,4 +13,3 @@ exports.down = function(db, callback) {
callback(error);
});
};
@@ -1,5 +1,4 @@
dbm = dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN oldConfigJson VARCHAR(2048)', function (error) {
@@ -14,4 +13,3 @@ exports.down = function(db, callback) {
callback(error);
});
};
@@ -1,5 +1,4 @@
var dbm = global.dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('DELETE FROM settings', [ ], callback);
@@ -1,5 +1,4 @@
dbm = dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN oauthProxy BOOLEAN DEFAULT 0', function (error) {
@@ -14,4 +13,3 @@ exports.down = function(db, callback) {
callback(error);
});
};
@@ -1,5 +1,5 @@
dbm = dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
var async = require('async');
exports.up = function(db, callback) {
@@ -1,5 +1,4 @@
var dbm = global.dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps CHANGE accessRestriction accessRestrictionJson VARCHAR(2048)', [], function (error) {
@@ -14,4 +13,3 @@ exports.down = function(db, callback) {
callback(error);
});
};
@@ -1,5 +1,4 @@
dbm = dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps MODIFY manifestJson TEXT', [], function (error) {
@@ -1,5 +1,5 @@
dbm = dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
var async = require('async');
exports.up = function(db, callback) {
@@ -1,4 +1,4 @@
dbm = dbm || require('db-migrate');
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE users ADD COLUMN displayName VARCHAR(512) DEFAULT ""', function (error) {
@@ -1,4 +1,4 @@
dbm = dbm || require('db-migrate');
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN memoryLimit BIGINT DEFAULT 0', function (error) {
@@ -1,5 +1,4 @@
var dbm = global.dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
var cmd = "CREATE TABLE groups(" +
@@ -1,5 +1,4 @@
var dbm = global.dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
var cmd = "CREATE TABLE IF NOT EXISTS groupMembers(" +
@@ -1,6 +1,5 @@
'use strict';
var dbm = global.dbm || require('db-migrate');
var async = require('async');
var ADMIN_GROUP_ID = 'admin'; // see groups.js
@@ -1,5 +1,4 @@
var dbm = global.dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
var cmd = "CREATE TABLE backups(" +
@@ -1,5 +1,4 @@
var dbm = global.dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE backups ADD COLUMN configJson TEXT', function (error) {
@@ -14,4 +13,3 @@ exports.down = function(db, callback) {
callback(error);
});
};
@@ -1,5 +1,4 @@
var dbm = dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE backups DROP COLUMN configJson', function (error) {
@@ -14,4 +13,3 @@ exports.down = function(db, callback) {
callback(error);
});
};
@@ -1,5 +1,4 @@
var dbm = global.dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE backups CHANGE filename id VARCHAR(128)', [], function (error) {
@@ -1,4 +1,4 @@
dbm = dbm || require('db-migrate');
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE users MODIFY username VARCHAR(254) UNIQUE', [], function (error) {
@@ -1,7 +1,5 @@
'use strict';
var dbm = dbm || require('db-migrate');
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN altDomain VARCHAR(256)', function (error) {
if (error) console.error(error);
@@ -1,5 +1,4 @@
var dbm = global.dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
var cmd = "CREATE TABLE eventlog(" +
@@ -1,4 +1,4 @@
dbm = dbm || require('db-migrate');
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE users ADD COLUMN showTutorial BOOLEAN DEFAULT 0', function (error) {
@@ -1,8 +1,5 @@
'use strict';
var dbm = global.dbm || require('db-migrate');
var type = dbm.dataType;
exports.up = function(db, callback) {
var cmd = 'CREATE TABLE mailboxes(' +
'name VARCHAR(128) NOT NULL,' +
@@ -1,5 +1,6 @@
var dbm = global.dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
var async = require('async');
// imports mailbox entries for existing users
exports.up = function(db, callback) {
@@ -1,5 +1,4 @@
dbm = dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps DROP COLUMN lastBackupConfigJson', function (error) {
@@ -1,5 +1,4 @@
var dbm = global.dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps MODIFY installationProgress TEXT', [], function (error) {
@@ -1,4 +1,4 @@
dbm = dbm || require('db-migrate');
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN xFrameOptions VARCHAR(512)', function (error) {
@@ -1,5 +1,4 @@
var dbm = global.dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.all('SELECT id FROM users', function (error, results) {
@@ -14,4 +13,3 @@ exports.up = function(db, callback) {
exports.down = function(db, callback) {
db.runSql('DELETE * FROM settings WHERE name="mail_config"', [ ], callback);
};
@@ -1,6 +1,6 @@
'use strict';
var dbm = dbm || require('db-migrate');
var async = require('async');
exports.up = function(db, callback) {
async.series([
@@ -71,4 +71,3 @@ exports.down = function(db, callback) {
});
});
};
+1 -2
View File
@@ -1,5 +1,4 @@
var dbm = global.dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps ADD COLUMN sso BOOLEAN DEFAULT 1', function (error) {
@@ -1,5 +1,4 @@
var dbm = global.dbm || require('db-migrate');
var type = dbm.dataType;
'use strict';
exports.up = function(db, callback) {
db.runSql('ALTER TABLE apps DROP COLUMN oauthProxy', function (error) {
@@ -0,0 +1,15 @@
'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);
});
};
@@ -0,0 +1,15 @@
'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);
});
};
@@ -0,0 +1,15 @@
'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);
});
};
+3 -3
View File
@@ -19,7 +19,6 @@ CREATE TABLE IF NOT EXISTS users(
modifiedAt VARCHAR(512) NOT NULL,
admin INTEGER NOT NULL,
displayName VARCHAR(512) DEFAULT '',
showTutorial BOOLEAN DEFAULT 0,
PRIMARY KEY(id));
CREATE TABLE IF NOT EXISTS groups(
@@ -61,13 +60,14 @@ CREATE TABLE IF NOT EXISTS apps(
manifestJson TEXT,
httpPort INTEGER, // this is the nginx proxy port and not manifest.httpPort
location VARCHAR(128) NOT NULL UNIQUE,
dnsRecordId VARCHAR(512),
dnsRecordId VARCHAR(512), // tracks any id that we got back to track dns updates (unused)
accessRestrictionJson TEXT, // { users: [ ], groups: [ ] }
createdAt TIMESTAMP(2) NOT NULL DEFAULT CURRENT_TIMESTAMP,
memoryLimit BIGINT DEFAULT 0,
altDomain VARCHAR(256),
xFrameOptions VARCHAR(512),
sso BOOLEAN DEFAULT 1, // whether user chose to enable SSO
debugModeJson TEXT, // options for development mode
lastBackupId VARCHAR(128), // tracks last valid backup, can be removed
@@ -105,7 +105,7 @@ CREATE TABLE IF NOT EXISTS backups(
creationTime TIMESTAMP,
version VARCHAR(128) NOT NULL, /* app version or box version */
type VARCHAR(16) NOT NULL, /* 'box' or 'app' */
dependsOn VARCHAR(4096), /* comma separate list of objects this backup depends on */
dependsOn TEXT, /* comma separate list of objects this backup depends on */
state VARCHAR(16) NOT NULL,
PRIMARY KEY (filename));
+3434 -1142
View File
File diff suppressed because it is too large Load Diff
+7 -6
View File
@@ -13,11 +13,11 @@
"node >=4.0.0 <=4.1.1"
],
"dependencies": {
"async": "^1.2.1",
"async": "^2.1.4",
"aws-sdk": "^2.1.46",
"body-parser": "^1.13.1",
"checksum": "^0.1.1",
"cloudron-manifestformat": "^2.5.1",
"cloudron-manifestformat": "^2.8.0",
"connect-ensure-login": "^0.1.1",
"connect-lastmile": "^0.1.0",
"connect-timeout": "^1.5.0",
@@ -25,12 +25,14 @@
"cookie-session": "^1.1.0",
"cron": "^1.0.9",
"csurf": "^1.6.6",
"db-migrate": "^0.9.2",
"db-migrate": "^0.10.0-beta.20",
"db-migrate-mysql": "^1.1.10",
"debug": "^2.2.0",
"dockerode": "^2.2.10",
"ejs": "^2.2.4",
"ejs-cli": "^1.2.0",
"express": "^4.12.4",
"express-rate-limit": "^2.6.0",
"express-session": "^1.11.3",
"gulp-sass": "^3.0.0",
"hat": "0.0.3",
@@ -58,15 +60,14 @@
"proxy-middleware": "^0.13.0",
"safetydance": "^0.1.1",
"semver": "^4.3.6",
"showdown": "^1.4.4",
"showdown": "^1.6.0",
"split": "^1.0.0",
"superagent": "^1.8.3",
"supererror": "^0.7.1",
"tldjs": "^1.6.2",
"underscore": "^1.7.0",
"valid-url": "^1.0.9",
"validator": "^4.9.0",
"x509": "^0.2.4"
"validator": "^4.9.0"
},
"devDependencies": {
"bootstrap-sass": "^3.3.3",
+114 -58
View File
@@ -7,9 +7,35 @@ if [[ ${EUID} -ne 0 ]]; then
exit 1
fi
if [[ $(lsb_release -rs) != "16.04" ]]; then
echo "Cloudron requires Ubuntu 16.04" > /dev/stderr
exit 1
fi
# change this to a hash when we make a upgrade release
readonly INIT_BASESYSTEM_SCRIPT_URL="https://git.cloudron.io/cloudron/box/raw/master/baseimage/initializeBaseUbuntuImage.sh"
readonly LOG_FILE="/var/log/cloudron-setup.log"
readonly DATA_FILE="/root/cloudron-install-data.json"
readonly MINIMUM_DISK_SIZE_GB="19" # this is the size of "/" and required to fit in docker images 19 is a safe bet for different reporting on 20GB min
readonly MINIMUM_MEMORY="974" # this is mostly reported for 1GB main memory (DO 992, EC2 990, Linode 989, Serverdiscounter.com 974)
readonly curl="curl --fail --connect-timeout 20 --retry 10 --retry-delay 2 --max-time 2400"
# copied from cloudron-resize-fs.sh
readonly physical_memory=$(LC_ALL=C free -m | awk '/Mem:/ { print $2 }')
readonly disk_device="$(for d in $(find /dev -type b); do [ "$(mountpoint -d /)" = "$(mountpoint -x $d)" ] && echo $d && break; done)"
readonly disk_size_bytes=$(LC_ALL=C fdisk -l ${disk_device} | grep "Disk ${disk_device}" | awk '{ printf $5 }')
readonly disk_size_gb=$((${disk_size_bytes}/1024/1024/1024))
# verify the system has minimum requirements met
if [[ "${physical_memory}" -lt "${MINIMUM_MEMORY}" ]]; then
echo "Error: Cloudron requires atleast 1GB physical memory"
exit 1
fi
if [[ "${disk_size_gb}" -lt "${MINIMUM_DISK_SIZE_GB}" ]]; then
echo "Error: Cloudron requires atleast 20GB disk space (Disk space on ${disk_device} is ${disk_size_gb}GB)"
exit 1
fi
initBaseImage="true"
# provisioning data
@@ -21,10 +47,13 @@ dnsProvider="manual"
tlsProvider="le-prod"
versionsUrl="https://s3.amazonaws.com/prod-cloudron-releases/versions.json"
requestedVersion="latest"
apiServer="https://api.cloudron.io"
apiServerOrigin="https://api.cloudron.io"
dataJson=""
prerelease="false"
sourceTarballUrl=""
rebootServer="true"
args=$(getopt -o "" -l "domain:,help,skip-baseimage-init,data:,provider:,encryption-key:,restore-url:,tls-provider:,version:,versions-url:,api-server:,dns-provider:" -n "$0" -- "$@")
args=$(getopt -o "" -l "domain:,help,skip-baseimage-init,data:,provider:,encryption-key:,restore-url:,tls-provider:,version:,versions-url:,api-server:,dns-provider:,env:,prerelease,skip-reboot,source-url:" -n "$0" -- "$@")
eval set -- "${args}"
while true; do
@@ -37,10 +66,26 @@ while true; do
--tls-provider) tlsProvider="$2"; shift 2;;
--dns-provider) dnsProvider="$2"; shift 2;;
--version) requestedVersion="$2"; shift 2;;
--env)
if [[ "$2" == "dev" ]]; then
apiServerOrigin="https://api.dev.cloudron.io"
versionsUrl="https://s3.amazonaws.com/dev-cloudron-releases/versions.json"
tlsProvider="le-staging"
prerelease="true"
elif [[ "$2" == "staging" ]]; then
apiServerOrigin="https://api.staging.cloudron.io"
versionsUrl="https://s3.amazonaws.com/staging-cloudron-releases/versions.json"
tlsProvider="le-staging"
prerelease="true"
fi
shift 2;;
--versions-url) versionsUrl="$2"; shift 2;;
--api-server) apiServer="$2"; shift 2;;
--api-server) apiServerOrigin="$2"; shift 2;;
--skip-baseimage-init) initBaseImage="false"; shift;;
--skip-reboot) rebootServer="false"; shift;;
--data) dataJson="$2"; shift 2;;
--prerelease) prerelease="true"; shift;;
--source-url) sourceTarballUrl="$2"; version="0.0.1+custom"; shift 2;;
--) break;;
*) echo "Unknown option $1"; exit 1;;
esac
@@ -48,21 +93,28 @@ done
# validate arguments in the absence of data
if [[ -z "${dataJson}" ]]; then
if [[ -z "${domain}" ]]; then
echo "--domain is required"
if [[ -z "${provider}" ]]; then
echo "--provider is required (azure, digitalocean, ec2, lightsail, linode, ovh, scaleway, vultr or generic)"
exit 1
elif [[ \
"${provider}" != "ami" && \
"${provider}" != "azure" && \
"${provider}" != "digitalocean" && \
"${provider}" != "ec2" && \
"${provider}" != "lightsail" && \
"${provider}" != "linode" && \
"${provider}" != "ovh" && \
"${provider}" != "rosehosting" && \
"${provider}" != "scaleway" && \
"${provider}" != "vultr" && \
"${provider}" != "generic" \
]]; then
echo "--provider must be one of: azure, digitalocean, ec2, lightsail, linode, ovh, rosehosting, scaleway, vultr or generic"
exit 1
fi
if [[ -z "${provider}" ]]; then
echo "--provider is required (generic, scaleway, ec2, digitalocean)"
exit 1
elif [[ \
"${provider}" != "generic" && \
"${provider}" != "scaleway" && \
"${provider}" != "ec2" && \
"${provider}" != "digitalocean" \
]]; then
echo "--provider must be one of: generic, scaleway, ec2, digitalocean"
if [[ "${tlsProvider}" != "fallback" && "${tlsProvider}" != "le-prod" && "${tlsProvider}" != "le-staging" ]]; then
echo "--tls-provider must be one of: le-prod, le-staging, fallback"
exit 1
fi
@@ -80,8 +132,6 @@ echo "##############################################"
echo " Cloudron Setup (${requestedVersion}) "
echo "##############################################"
echo ""
echo "The server will reboot at the end to complete the setup."
echo ""
echo " Follow setup logs in a second terminal with:"
echo " $ tail -f ${LOG_FILE}"
echo ""
@@ -89,45 +139,31 @@ echo " Join us at https://chat.cloudron.io for any questions."
echo ""
if [[ "${initBaseImage}" == "true" ]]; then
echo "=> Update package repositories ..."
echo "=> Updating apt and installing script dependencies"
if ! apt-get update &>> "${LOG_FILE}"; then
echo "Could not update package repositories"
exit 1
fi
echo "=> Installing setup dependencies ..."
if ! apt-get install curl -y &>> "${LOG_FILE}"; then
if ! apt-get install curl python3 ubuntu-standard -y &>> "${LOG_FILE}"; then
echo "Could not install setup dependencies (curl)"
exit 1
fi
echo "=> Downloading initialization script"
if ! curl -s "${INIT_BASESYSTEM_SCRIPT_URL}" > /tmp/initializeBaseUbuntuImage.sh; then
echo "Could not download initialization script"
exit 1
fi
echo "=> Installing base dependencies (this takes some time) ..."
if ! /bin/bash /tmp/initializeBaseUbuntuImage.sh "${provider}" &>> "${LOG_FILE}"; then
echo "Init script failed. See ${LOG_FILE} for details"
exit 1
fi
rm /tmp/initializeBaseUbuntuImage.sh
fi
echo "=> Checking version"
if ! npm install -g cloudron-version@0.1.1 &>> "${LOG_FILE}"; then
echo "Failed to install cloudron-version npm package"
exit 1
fi
NPM_BIN=$(npm bin -g 2>/dev/null)
if ! version=$(${NPM_BIN}/cloudron-version --out version --versions-url "${versionsUrl}" --version "${requestedVersion}"); then
echo "No such version ${requestedVersion}"
exit 1
fi
if ! sourceTarballUrl=$(${NPM_BIN}/cloudron-version --out tarballUrl --versions-url "${versionsUrl}" --version "${requestedVersion}"); then
echo "No source code for version ${requestedVersion}"
exit 1
if [[ "${sourceTarballUrl}" == "" ]]; then
releaseJson=$($curl -s "${versionsUrl}")
if [[ "$requestedVersion" == "latest" ]]; then
pre=$([[ "${prerelease}" == "true" ]] && echo "null" || echo "-pre")
version=$(echo "${releaseJson}" | python3 -c "import json,sys,collections;obj=json.load(sys.stdin, object_pairs_hook=collections.OrderedDict);latest=list(v for v in obj if '${pre}' not in v)[-1];print(latest)")
else
version="${requestedVersion}"
fi
if ! sourceTarballUrl=$(echo "${releaseJson}" | python3 -c 'import json,sys;obj=json.load(sys.stdin);print(obj[sys.argv[1]]["sourceTarballUrl"])' "${version}"); then
echo "No source code for version ${requestedVersion}"
exit 1
fi
fi
# Build data
@@ -138,7 +174,7 @@ if [[ -z "${dataJson}" ]]; then
"boxVersionsUrl": "${versionsUrl}",
"fqdn": "${domain}",
"provider": "${provider}",
"apiServerOrigin": "${apiServer}",
"apiServerOrigin": "${apiServerOrigin}",
"tlsConfig": {
"provider": "${tlsProvider}"
},
@@ -150,6 +186,9 @@ if [[ -z "${dataJson}" ]]; then
"backupFolder": "/var/backups",
"key": "${encryptionKey}"
},
"updateConfig": {
"prerelease": ${prerelease}
},
"version": "${version}"
}
EOF
@@ -160,7 +199,7 @@ EOF
"boxVersionsUrl": "${versionsUrl}",
"fqdn": "${domain}",
"provider": "${provider}",
"apiServerOrigin": "${apiServer}",
"apiServerOrigin": "${apiServerOrigin}",
"restore": {
"url": "${restoreUrl}",
"key": "${encryptionKey}"
@@ -174,31 +213,48 @@ else
data="${dataJson}"
fi
echo "=> Downloading and running installer for version ${version} (this takes some time) ..."
echo "=> Downloading version ${version} ..."
box_src_tmp_dir=$(mktemp -dt box-src-XXXXXX)
if ! curl -sL "${sourceTarballUrl}" | tar -zxf - -C "${box_src_tmp_dir}"; then
if ! $curl -sL "${sourceTarballUrl}" | tar -zxf - -C "${box_src_tmp_dir}"; then
echo "Could not download source tarball. See ${LOG_FILE} for details"
exit 1
fi
if ! /bin/bash "${box_src_tmp_dir}/scripts/installer.sh" --data "${data}" &>> "${LOG_FILE}"; then
if [[ "${initBaseImage}" == "true" ]]; then
echo -n "=> Installing base dependencies and downloading docker images (this takes some time) ..."
if ! /bin/bash "${box_src_tmp_dir}/baseimage/initializeBaseUbuntuImage.sh" "${provider}" "../src" &>> "${LOG_FILE}"; then
echo "Init script failed. See ${LOG_FILE} for details"
exit 1
fi
echo ""
fi
echo "=> Installing version ${version} (this takes some time) ..."
echo "${data}" > "${DATA_FILE}"
if ! /bin/bash "${box_src_tmp_dir}/scripts/installer.sh" --data-file "${DATA_FILE}" &>> "${LOG_FILE}"; then
echo "Failed to install cloudron. See ${LOG_FILE} for details"
exit 1
fi
rm "${DATA_FILE}"
echo -n "=> Waiting for cloudron to be ready (this takes some time) ..."
while true; do
echo -n "."
if journalctl -u box -a | grep "platformReady: " >/dev/null; then
break
if status=$($curl -q -f "http://localhost:3000/api/v1/cloudron/status" 2>/dev/null); then
[[ -z "$domain" ]] && break # with no domain, we are up and running
[[ "$status" == *"\"tls\": true"* ]] && break # with a domain, wait for the cert
fi
sleep 10
done
echo -e "\n\nRebooting this server now to let bootloader changes take effect.\n"
echo -e "Visit https://my.${domain} to finish setup once the server has rebooted.\n"
if [[ "${initBaseImage}" == "true" ]]; then
systemctl reboot
if [[ -n "${domain}" ]]; then
echo -e "\n\nVisit https://my.${domain} to finish setup once the server has rebooted.\n"
else
echo -e "\n\nVisit https://<IP> to finish setup once the server has rebooted.\n"
fi
if [[ "${rebootServer}" == "true" ]]; then
echo -e "\n\nRebooting this server now to let bootloader changes take effect.\n"
systemctl reboot
fi
+3 -26
View File
@@ -2,30 +2,23 @@
set -eu
assertNotEmpty() {
: "${!1:? "$1 is not set."}"
}
# Only GNU getopt supports long options. OS X comes bundled with the BSD getopt
# brew install gnu-getopt to get the GNU getopt on OS X
[[ $(uname -s) == "Darwin" ]] && GNU_GETOPT="/usr/local/opt/gnu-getopt/bin/getopt" || GNU_GETOPT="getopt"
readonly GNU_GETOPT
args=$(${GNU_GETOPT} -o "" -l "revision:,output:,no-upload" -n "$0" -- "$@")
args=$(${GNU_GETOPT} -o "" -l "revision:,output:" -n "$0" -- "$@")
eval set -- "${args}"
readonly SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
delete_bundle="yes"
commitish="HEAD"
upload="yes"
bundle_file=""
while true; do
case "$1" in
--revision) commitish="$2"; shift 2;;
--output) bundle_file="$2"; delete_bundle="no"; shift 2;;
--no-upload) upload="no"; shift;;
--output) bundle_file="$2"; shift 2;;
--) break;;
*) echo "Unknown option $1"; exit 1;;
esac
@@ -90,21 +83,5 @@ echo "Create final tarball"
echo "Cleaning up ${bundle_dir}"
rm -rf "${bundle_dir}"
if [[ "${upload}" == "yes" ]]; then
echo "Uploading bundle to S3"
echo "Tarball saved at ${bundle_file}"
assertNotEmpty AWS_DEV_ACCESS_KEY
assertNotEmpty AWS_DEV_SECRET_KEY
# That special header is needed to allow access with singed urls created with different aws credentials than the ones the file got uploaded
s3cmd --multipart-chunk-size-mb=5 --ssl --acl-public --access_key="${AWS_DEV_ACCESS_KEY}" --secret_key="${AWS_DEV_SECRET_KEY}" --no-mime-magic put "${bundle_file}" "s3://dev-cloudron-releases/box-${version}.tar.gz"
versions_file_url="https://dev-cloudron-releases.s3.amazonaws.com/box-${version}.tar.gz"
echo "The URL for the versions file is: ${versions_file_url}"
fi
if [[ "${delete_bundle}" == "no" ]]; then
echo "Tarball preserved at ${bundle_file}"
else
rm "${bundle_file}"
fi
+1 -9
View File
@@ -16,10 +16,6 @@ readonly box_src_tmp_dir="$(realpath ${script_dir}/..)"
readonly is_update=$([[ -f "${CLOUDRON_CONF}" ]] && echo "yes" || echo "no")
# create a provision file for testing. %q escapes args. %q is reused as much as necessary to satisfy $@
(echo -e "#!/bin/bash\n"; printf "%q " "${script_dir}/installer.sh" "$@") > /root/provision.sh
chmod +x /root/provision.sh
arg_data=""
args=$(getopt -o "" -l "data:,data-file:" -n "$0" -- "$@")
@@ -56,7 +52,7 @@ fi
if [[ "${is_update}" == "yes" ]]; then
echo "Setting up update splash screen"
"${box_src_tmp_dir}/setup/splashpage.sh" --data "${arg_data}" # show splash from new code
"${box_src_tmp_dir}/setup/splashpage.sh" --data "${arg_data}" || true # show splash from new code
${BOX_SRC_DIR}/setup/stop.sh # stop the old code
fi
@@ -68,9 +64,5 @@ rm -rf "${BOX_SRC_DIR}"
mv "${box_src_tmp_dir}" "${BOX_SRC_DIR}"
chown -R "${USER}:${USER}" "${BOX_SRC_DIR}"
# create a start file for testing. %q escapes args
(echo -e "#!/bin/bash\n"; printf "%q " "${BOX_SRC_DIR}/setup/start.sh" --data "${arg_data}") > /home/yellowtent/setup_start.sh
chmod +x /home/yellowtent/setup_start.sh
echo "==> installer: calling box setup script"
"${BOX_SRC_DIR}/setup/start.sh" --data "${arg_data}"
+5
View File
@@ -11,6 +11,11 @@ readonly ADMIN_LOCATION="my" # keep this in sync with constants.js
echo "Setting up nginx update page"
if [[ ! -f "${DATA_DIR}/nginx/applications/admin.conf" ]]; then
echo "No admin.conf found. This Cloudron has no domain yet. Skip splash setup"
exit
fi
source "${script_dir}/argparser.sh" "$@" # this injects the arg_* variables used below
# keep this is sync with config.js appFqdn()
+92 -92
View File
@@ -6,11 +6,12 @@ echo "==> Cloudron Start"
readonly USER="yellowtent"
readonly DATA_FILE="/root/user_data.img"
readonly BOX_SRC_DIR="/home/${USER}/box"
readonly DATA_DIR="/home/${USER}/data"
readonly CONFIG_DIR="/home/${USER}/configs"
readonly SETUP_PROGRESS_JSON="/home/yellowtent/setup/website/progress.json"
readonly ADMIN_LOCATION="my" # keep this in sync with constants.js
readonly HOME_DIR="/home/${USER}"
readonly BOX_SRC_DIR="${HOME_DIR}/box"
readonly DATA_DIR="${HOME_DIR}/data" # app and platform data
readonly BOX_DATA_DIR="${HOME_DIR}/boxdata" # box data
readonly CONFIG_DIR="${HOME_DIR}/configs"
readonly SETUP_PROGRESS_JSON="${HOME_DIR}/setup/website/progress.json"
readonly curl="curl --fail --connect-timeout 20 --retry 10 --retry-delay 2 --max-time 2400"
@@ -18,12 +19,6 @@ readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${script_dir}/argparser.sh" "$@" # this injects the arg_* variables used below
# keep this is sync with config.js appFqdn()
readonly admin_fqdn=$([[ "${arg_is_custom_domain}" == "true" ]] && echo "${ADMIN_LOCATION}.${arg_fqdn}" || echo "${ADMIN_LOCATION}-${arg_fqdn}")
readonly admin_origin="https://${admin_fqdn}"
readonly is_update=$([[ -f "${CONFIG_DIR}/cloudron.conf" ]] && echo "true" || echo "false")
set_progress() {
local percent="$1"
local message="$2"
@@ -32,7 +27,7 @@ set_progress() {
(echo "{ \"update\": { \"percent\": \"${percent}\", \"message\": \"${message}\" }, \"backup\": {} }" > "${SETUP_PROGRESS_JSON}") 2> /dev/null || true # as this will fail in non-update mode
}
set_progress "10" "Configuring host"
set_progress "20" "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
timedatectl set-timezone UTC
@@ -70,12 +65,23 @@ mkdir -p /etc/iptables && iptables-save > /etc/iptables/rules.v4
echo "==> Configuring docker"
cp "${script_dir}/start/docker-cloudron-app.apparmor" /etc/apparmor.d/docker-cloudron-app
systemctl enable apparmor
systemctl restart apparmor
usermod yellowtent -a -G docker
sed -e 's,^ExecStart=.*$,ExecStart=/usr/bin/docker daemon -H fd:// --log-driver=journald --exec-opt native.cgroupdriver=cgroupfs,' -i /lib/systemd/system/docker.service
usermod ${USER} -a -G docker
temp_file=$(mktemp)
# create systemd drop-in. some apps do not work with aufs
echo -e "[Service]\nExecStart=\nExecStart=/usr/bin/dockerd -H fd:// --log-driver=journald --exec-opt native.cgroupdriver=cgroupfs --storage-driver=devicemapper --dns=172.18.0.1 --dns-search=." > "${temp_file}"
systemctl enable docker
systemctl restart docker
# restart docker if options changed
if [[ ! -f /etc/systemd/system/docker.service.d/cloudron.conf ]] || ! diff -q /etc/systemd/system/docker.service.d/cloudron.conf "${temp_file}" >/dev/null; then
mkdir -p /etc/systemd/system/docker.service.d
mv "${temp_file}" /etc/systemd/system/docker.service.d/cloudron.conf
systemctl daemon-reload
systemctl restart docker
fi
docker network create --subnet=172.18.0.0/16 cloudron || true
# caas has ssh on port 202 and we disable password login
if [[ "${arg_provider}" == "caas" ]]; then
@@ -91,12 +97,6 @@ if [[ "${arg_provider}" == "caas" ]]; then
fi
echo "==> Setup btrfs data"
if ! grep -q loop.ko /lib/modules/`uname -r`/modules.builtin; then
# on scaleway loop is not built-in
echo "loop" >> /etc/modules
modprobe loop
fi
if [[ ! -d "${DATA_DIR}" ]]; then
echo "==> Mounting loopback btrfs"
truncate -s "8192m" "${DATA_FILE}" # 8gb start (this will get resized dynamically by cloudron-resize-fs.service)
@@ -107,20 +107,34 @@ fi
# keep these in sync with paths.js
echo "==> Ensuring directories"
[[ "${is_update}" == "false" ]] && btrfs subvolume create "${DATA_DIR}/box"
mkdir -p "${DATA_DIR}/box/appicons"
mkdir -p "${DATA_DIR}/box/certs"
mkdir -p "${DATA_DIR}/box/mail/dkim/${arg_fqdn}"
mkdir -p "${DATA_DIR}/box/acme" # acme keys
if ! btrfs subvolume show "${DATA_DIR}/mail" &> /dev/null; then
# Migrate mail data to new format
docker stop mail || true # otherwise the move below might fail if mail container writes in the middle
rm -rf "${DATA_DIR}/mail" # this used to be mail container's run directory
btrfs subvolume create "${DATA_DIR}/mail"
[[ -d "${DATA_DIR}/box/mail" ]] && mv "${DATA_DIR}/box/mail/"* "${DATA_DIR}/mail"
rm -rf "${DATA_DIR}/box/mail"
fi
mkdir -p "${DATA_DIR}/graphite"
mkdir -p "${DATA_DIR}/mail/dkim"
mkdir -p "${DATA_DIR}/mysql"
mkdir -p "${DATA_DIR}/postgresql"
mkdir -p "${DATA_DIR}/mongodb"
mkdir -p "${DATA_DIR}/snapshots"
mkdir -p "${DATA_DIR}/addons"
mkdir -p "${DATA_DIR}/addons/mail"
mkdir -p "${DATA_DIR}/collectd/collectd.conf.d"
mkdir -p "${DATA_DIR}/acme" # acme challenges
mkdir -p "${DATA_DIR}/acme"
mkdir -p "${BOX_DATA_DIR}"
if btrfs subvolume show "${DATA_DIR}/box" &> /dev/null; then
# Migrate box data out of data volume
mv "${DATA_DIR}/box/"* "${BOX_DATA_DIR}"
btrfs subvolume delete "${DATA_DIR}/box"
fi
mkdir -p "${BOX_DATA_DIR}/appicons"
mkdir -p "${BOX_DATA_DIR}/certs"
mkdir -p "${BOX_DATA_DIR}/acme" # acme keys
echo "==> Configuring journald"
sed -e "s/^#SystemMaxUse=.*$/SystemMaxUse=100M/" \
@@ -133,32 +147,38 @@ sed -e "s/^WatchdogSec=.*$/WatchdogSec=3min/" \
-i /lib/systemd/system/systemd-journald.service
# Give user access to system logs
usermod -a -G systemd-journal yellowtent
usermod -a -G systemd-journal ${USER}
mkdir -p /var/log/journal # in some images, this directory is not created making system log to /run/systemd instead
chown root:systemd-journal /var/log/journal
systemctl daemon-reload
systemctl restart systemd-journald
setfacl -n -m u:yellowtent:r /var/log/journal/*/system.journal
setfacl -n -m u:${USER}:r /var/log/journal/*/system.journal
echo "==> Creating config directory"
rm -rf "${CONFIG_DIR}" && mkdir "${CONFIG_DIR}"
chown yellowtent:yellowtent "${CONFIG_DIR}"
echo "==> Setting up unbound"
# DO uses Google nameservers by default. This causes RBL queries to fail (host 2.0.0.127.zen.spamhaus.org)
# We do not use dnsmasq because it is not a recursive resolver and defaults to the value in the interfaces file (which is Google DNS!)
# We listen on 0.0.0.0 because there is no way control ordering of docker (which creates the 172.18.0.0/16) and unbound
echo -e "server:\n\tinterface: 0.0.0.0\n\taccess-control: 127.0.0.1 allow\n\taccess-control: 172.18.0.1/16 allow\n\tcache-max-negative-ttl: 30" > /etc/unbound/unbound.conf.d/cloudron-network.conf
echo "==> Adding systemd services"
cp -r "${script_dir}/start/systemd/." /etc/systemd/system/
systemctl daemon-reload
systemctl enable unbound
systemctl enable cloudron.target
systemctl enable iptables-restore
# For logrotate
systemctl enable --now cron
# DO uses Google nameservers by default. This causes RBL queries to fail (host 2.0.0.127.zen.spamhaus.org)
# We do not use dnsmasq because it is not a recursive resolver and defaults to the value in the interfaces file (which is Google DNS!)
systemctl enable --now unbound
# ensure unbound runs
systemctl restart unbound
echo "==> Configuring sudoers"
rm -f /etc/sudoers.d/yellowtent
cp "${script_dir}/start/sudoers" /etc/sudoers.d/yellowtent
rm -f /etc/sudoers.d/${USER}
cp "${script_dir}/start/sudoers" /etc/sudoers.d/${USER}
echo "==> Configuring collectd"
rm -rf /etc/collectd
@@ -171,35 +191,18 @@ echo "==> Configuring nginx"
unlink /etc/nginx 2>/dev/null || rm -rf /etc/nginx
ln -s "${DATA_DIR}/nginx" /etc/nginx
mkdir -p "${DATA_DIR}/nginx/applications"
mkdir -p "${DATA_DIR}/nginx/cert"
cp "${script_dir}/start/nginx/nginx.conf" "${DATA_DIR}/nginx/nginx.conf"
cp "${script_dir}/start/nginx/mime.types" "${DATA_DIR}/nginx/mime.types"
# generate these for update code paths as well to overwrite splash
admin_cert_file="${DATA_DIR}/nginx/cert/host.cert"
admin_key_file="${DATA_DIR}/nginx/cert/host.key"
if [[ -f "${DATA_DIR}/box/certs/${admin_fqdn}.cert" && -f "${DATA_DIR}/box/certs/${admin_fqdn}.key" ]]; then
admin_cert_file="${DATA_DIR}/box/certs/${admin_fqdn}.cert"
admin_key_file="${DATA_DIR}/box/certs/${admin_fqdn}.key"
fi
${BOX_SRC_DIR}/node_modules/.bin/ejs-cli -f "${script_dir}/start/nginx/appconfig.ejs" \
-O "{ \"vhost\": \"${admin_fqdn}\", \"adminOrigin\": \"${admin_origin}\", \"endpoint\": \"admin\", \"sourceDir\": \"${BOX_SRC_DIR}\", \"certFilePath\": \"${admin_cert_file}\", \"keyFilePath\": \"${admin_key_file}\", \"xFrameOptions\": \"SAMEORIGIN\" }" > "${DATA_DIR}/nginx/applications/admin.conf"
mkdir -p "${DATA_DIR}/nginx/cert"
if [[ -f "${DATA_DIR}/box/certs/host.cert" && -f "${DATA_DIR}/box/certs/host.key" ]]; then
cp "${DATA_DIR}/box/certs/host.cert" "${DATA_DIR}/nginx/cert/host.cert"
cp "${DATA_DIR}/box/certs/host.key" "${DATA_DIR}/nginx/cert/host.key"
else
if [[ -z "${arg_tls_cert}" || -z "${arg_tls_key}" ]]; then
echo "==> Creating fallback certs"
openssl req -x509 -newkey rsa:2048 -keyout "${DATA_DIR}/nginx/cert/host.key" -out "${DATA_DIR}/nginx/cert/host.cert" -days 3650 -subj "/CN=${arg_fqdn}" -nodes
else
echo "${arg_tls_cert}" > "${DATA_DIR}/nginx/cert/host.cert"
echo "${arg_tls_key}" > "${DATA_DIR}/nginx/cert/host.key"
fi
if ! grep -q "^Restart=" /etc/systemd/system/multi-user.target.wants/nginx.service; then
# default nginx service file does not restart on crash
echo -e "\n[Service]\nRestart=always\n" >> /etc/systemd/system/multi-user.target.wants/nginx.service
systemctl daemon-reload
fi
systemctl start nginx
# bookkeep the version as part of data
echo "{ \"version\": \"${arg_version}\", \"boxVersionsUrl\": \"${arg_box_versions_url}\" }" > "${DATA_DIR}/box/version"
echo "{ \"version\": \"${arg_version}\", \"boxVersionsUrl\": \"${arg_box_versions_url}\" }" > "${BOX_DATA_DIR}/version"
# remove old snapshots. if we do want to keep this around, we will have to fix the chown -R below
# which currently fails because these are readonly fs
@@ -207,14 +210,18 @@ echo "==> Cleaning up snapshots"
find "${DATA_DIR}/snapshots" -mindepth 1 -maxdepth 1 | xargs --no-run-if-empty btrfs subvolume delete
# restart mysql to make sure it has latest config
# wait for all running mysql jobs
cp "${script_dir}/start/mysql.cnf" /etc/mysql/mysql.cnf
while true; do
if ! systemctl list-jobs | grep mysql; then break; fi
echo "Waiting for mysql jobs..."
sleep 1
done
systemctl restart mysql
if [[ ! -f /etc/mysql/mysql.cnf ]] || ! diff -q "${script_dir}/start/mysql.cnf" /etc/mysql/mysql.cnf >/dev/null; then
# wait for all running mysql jobs
cp "${script_dir}/start/mysql.cnf" /etc/mysql/mysql.cnf
while true; do
if ! systemctl list-jobs | grep mysql; then break; fi
echo "Waiting for mysql jobs..."
sleep 1
done
systemctl restart mysql
else
systemctl start mysql
fi
readonly mysql_root_password="password"
mysqladmin -u root -ppassword password password # reset default root password
@@ -226,14 +233,15 @@ if [[ -n "${arg_restore_url}" ]]; then
echo "==> Downloading backup: ${arg_restore_url} and key: ${arg_restore_key}"
while true; do
if $curl -L "${arg_restore_url}" | openssl aes-256-cbc -d -pass "pass:${arg_restore_key}" | tar -zxf - -C "${DATA_DIR}/box"; then break; fi
if $curl -L "${arg_restore_url}" | openssl aes-256-cbc -d -pass "pass:${arg_restore_key}" \
| tar -zxf - --overwrite --transform="s,^box/\?,boxdata/," --transform="s,^mail/\?,data/mail/," --show-transformed-names -C "${HOME_DIR}"; then break; fi
echo "Failed to download data, trying again"
done
set_progress "35" "Setting up MySQL"
if [[ -f "${DATA_DIR}/box/box.mysqldump" ]]; then
if [[ -f "${BOX_DATA_DIR}/box.mysqldump" ]]; then
echo "==> Importing existing database into MySQL"
mysql -u root -p${mysql_root_password} box < "${DATA_DIR}/box/box.mysqldump"
mysql -u root -p${mysql_root_password} box < "${BOX_DATA_DIR}/box.mysqldump"
fi
fi
@@ -266,6 +274,11 @@ cat > "${CONFIG_DIR}/cloudron.conf" <<CONF_END
"appBundle": ${arg_app_bundle}
}
CONF_END
# pass these out-of-band because they have new lines which interfere with json
if [[ -n "${arg_tls_cert}" && -n "${arg_tls_key}" ]]; then
echo "${arg_tls_cert}" > "${CONFIG_DIR}/host.cert"
echo "${arg_tls_key}" > "${CONFIG_DIR}/host.key"
fi
echo "==> Creating config.json for webadmin"
cat > "${BOX_SRC_DIR}/webadmin/dist/config.json" <<CONF_END
@@ -275,12 +288,10 @@ cat > "${BOX_SRC_DIR}/webadmin/dist/config.json" <<CONF_END
CONF_END
echo "==> Changing ownership"
chown "${USER}:${USER}" "${CONFIG_DIR}/cloudron.conf"
chown "${USER}:${USER}" -R "${CONFIG_DIR}"
chown "${USER}:${USER}" -R "${DATA_DIR}/nginx" "${DATA_DIR}/collectd" "${DATA_DIR}/addons" "${DATA_DIR}/acme"
# during updates, do not trample mail ownership behind the the mail container's back
find "${DATA_DIR}/box" -mindepth 1 -maxdepth 1 -not -path "${DATA_DIR}/box/mail" -print0 | xargs -0 chown -R "${USER}:${USER}"
chown "${USER}:${USER}" "${DATA_DIR}/box"
chown "${USER}:${USER}" -R "${DATA_DIR}/box/mail/dkim" # this is owned by box currently since it generates the keys
chown "${USER}:${USER}" -R "${BOX_DATA_DIR}"
chown "${USER}:${USER}" -R "${DATA_DIR}/mail/dkim" # this is owned by box currently since it generates the keys
chown "${USER}:${USER}" "${DATA_DIR}/INFRA_VERSION" 2>/dev/null || true
chown "${USER}:${USER}" "${DATA_DIR}"
@@ -305,25 +316,14 @@ if [[ ! -z "${arg_tls_config}" ]]; then
-e "REPLACE INTO settings (name, value) VALUES (\"tls_config\", '$arg_tls_config')" box
fi
echo "==> Adding default clients"
# The domain might have changed, therefor we have to update the record
# !!! This needs to be in sync with the webadmin, specifically login_callback.js
readonly ADMIN_SCOPES="cloudron,developer,profile,users,apps,settings"
mysql -u root -p${mysql_root_password} \
-e "REPLACE INTO clients (id, appId, type, clientSecret, redirectURI, scope) VALUES (\"cid-webadmin\", \"Settings\", \"built-in\", \"secret-webadmin\", \"${admin_origin}\", \"${ADMIN_SCOPES}\")" box
mysql -u root -p${mysql_root_password} \
-e "REPLACE INTO clients (id, appId, type, clientSecret, redirectURI, scope) VALUES (\"cid-sdk\", \"SDK\", \"built-in\", \"secret-sdk\", \"${admin_origin}\", \"*,roleSdk\")" box
mysql -u root -p${mysql_root_password} \
-e "REPLACE INTO clients (id, appId, type, clientSecret, redirectURI, scope) VALUES (\"cid-cli\", \"Cloudron Tool\", \"built-in\", \"secret-cli\", \"${admin_origin}\", \"*,roleSdk\")" box
echo "==> Generating dhparams (takes forever)"
if [[ ! -f "${BOX_DATA_DIR}/dhparams.pem" ]]; then
openssl dhparam -out "${BOX_DATA_DIR}/dhparams.pem" 2048
fi
set_progress "60" "Starting Cloudron"
systemctl start cloudron.target
sleep 2 # give systemd sometime to start the processes
set_progress "80" "Reloading nginx"
nginx -s reload
set_progress "100" "Done"
set_progress "90" "Almost done"
+4 -4
View File
@@ -13,12 +13,12 @@ disk_device="$(for d in $(find /dev -type b); do [ "$(mountpoint -d /)" = "$(mou
existing_swap=$(cat /proc/meminfo | grep SwapTotal | awk '{ printf "%.0f", $2/1024 }')
# all sizes are in mb
readonly physical_memory=$(free -m | awk '/Mem:/ { print $2 }')
readonly physical_memory=$(LC_ALL=C free -m | awk '/Mem:/ { print $2 }')
readonly swap_size=$((${physical_memory} - ${existing_swap})) # if you change this, fix enoughResourcesAvailable() in client.js
readonly app_count=$((${physical_memory} / 200)) # estimated app count
readonly disk_size_gb=$(fdisk -l ${disk_device} | grep "Disk ${disk_device}" | awk '{ printf "%.0f", $3 }')
readonly disk_size=$((disk_size_gb * 1024))
readonly system_size=10240 # 10 gigs for system libs, apps images, installer, box code and tmp
readonly disk_size_bytes=$(LC_ALL=C fdisk -l ${disk_device} | grep "Disk ${disk_device}" | awk '{ printf $5 }') # can't rely on fdisk human readable units, using bytes instead
readonly disk_size=$((${disk_size_bytes}/1024/1024))
readonly system_size=10240 # 10 gigs for system libs, apps images, installer, box code, data and tmp
readonly ext4_reserved=$((disk_size * 5 / 100)) # this can be changes using tune2fs -m percent /dev/vda1
echo "Disk device: ${disk_device}"
+16 -2
View File
@@ -5,8 +5,12 @@ map $http_upgrade $connection_upgrade {
}
server {
<% if (vhost) { %>
listen 443;
server_name <%= vhost %>;
<% } else { %>
listen 443 default_server;
<% } %>
ssl on;
# paths are relative to prefix and not to this file
@@ -21,12 +25,22 @@ server {
# https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # don't use SSLv3 ref: POODLE
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains";
# ciphers according to https://weakdh.org/sysadmin.html
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
ssl_dhparam /home/yellowtent/boxdata/dhparams.pem;
add_header Strict-Transport-Security "max-age=15768000";
# https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options
add_header X-Frame-Options "<%= xFrameOptions %>";
# https://github.com/twitter/secureheaders
# https://www.owasp.org/index.php/OWASP_Secure_Headers_Project#tab=Compatibility_Matrix
# https://wiki.mozilla.org/Security/Guidelines/Web_Security
add_header X-XSS-Protection "1; mode=block";
add_header X-Download-Options "noopen";
add_header X-Content-Type-Options "nosniff";
add_header X-Permitted-Cross-Domain-Policies "none";
proxy_http_version 1.1;
proxy_intercept_errors on;
proxy_read_timeout 3500;
-29
View File
@@ -57,35 +57,6 @@ http {
}
}
# This server handles the naked domain for custom domains.
# It can also be used for wildcard subdomain 404. This feature is not used by the Cloudron itself
# because box always sets up DNS records for app subdomains.
server {
listen 443 default_server;
ssl on;
ssl_certificate cert/host.cert;
ssl_certificate_key cert/host.key;
error_page 404 = @fallback;
location @fallback {
internal;
root /home/yellowtent/box/webadmin/dist;
rewrite ^/$ /nakeddomain.html break;
}
location / {
internal;
root /home/yellowtent/box/webadmin/dist;
rewrite ^/$ /nakeddomain.html break;
}
# required for /api/v1/cloudron/avatar
location /api/ {
proxy_pass http://127.0.0.1:3000;
client_max_body_size 1m;
}
}
include applications/*.conf;
}
+3
View File
@@ -36,3 +36,6 @@ yellowtent ALL=(root) NOPASSWD: /home/yellowtent/box/src/scripts/rmbackup.sh
Defaults!/home/yellowtent/box/src/scripts/update.sh env_keep="HOME BOX_ENV"
yellowtent ALL=(root) NOPASSWD: /home/yellowtent/box/src/scripts/update.sh
Defaults!/home/yellowtent/box/src/scripts/authorized_keys.sh env_keep="HOME BOX_ENV"
yellowtent ALL=(root) NOPASSWD: /home/yellowtent/box/src/scripts/authorized_keys.sh
+1 -1
View File
@@ -4,7 +4,7 @@ OnFailure=crashnotifier@%n.service
StopWhenUnneeded=true
; journald crashes result in a EPIPE in node. Cannot ignore it as it results in loss of logs.
BindsTo=systemd-journald.service
After=mysql.service
After=mysql.service nginx.service
; As cloudron-resize-fs is a one-shot, the Wants= automatically ensures that the service *finishes*
Wants=cloudron-resize-fs.service
+14
View File
@@ -0,0 +1,14 @@
# The default ubuntu unbound service uses SysV fallback mode, we want a proper unit file so unbound gets restarted correctly
[Unit]
Description=Unbound DNS Resolver
After=network.target
[Service]
PIDFile=/run/unbound.pid
ExecStart=/usr/sbin/unbound -d
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
[Install]
WantedBy=multi-user.target
+1 -59
View File
@@ -106,18 +106,6 @@ var KNOWN_ADDONS = {
teardown: NOOP,
backup: NOOP,
restore: NOOP
},
simpleauth: {
setup: setupSimpleAuth,
teardown: teardownSimpleAuth,
backup: NOOP,
restore: setupSimpleAuth
},
_docker: {
setup: NOOP,
teardown: NOOP,
backup: NOOP,
restore: NOOP
}
};
@@ -219,7 +207,6 @@ function getBindsSync(app, addons) {
for (var addon in addons) {
switch (addon) {
case '_docker': binds.push('/var/run/docker.sock:/var/run/docker.sock:rw'); break;
case 'localstorage': binds.push(path.join(paths.DATA_DIR, app.id, 'data') + ':/app/data:rw'); break;
default: break;
}
@@ -287,57 +274,12 @@ function teardownOauth(app, options, callback) {
debugApp(app, 'teardownOauth');
clients.delByAppIdAndType(app.id, clients.TYPE_OAUTH, function (error) {
if (error && error.reason !== ClientsError.NOT_FOUND) console.error(error);
if (error && error.reason !== ClientsError.NOT_FOUND) debug(error);
appdb.unsetAddonConfig(app.id, 'oauth', callback);
});
}
function setupSimpleAuth(app, options, callback) {
assert.strictEqual(typeof app, 'object');
assert.strictEqual(typeof options, 'object');
assert.strictEqual(typeof callback, 'function');
if (!app.sso) return callback(null);
var appId = app.id;
var scope = 'profile';
clients.delByAppIdAndType(app.id, clients.TYPE_SIMPLE_AUTH, function (error) { // remove existing creds
if (error && error.reason !== ClientsError.NOT_FOUND) return callback(error);
clients.add(appId, clients.TYPE_SIMPLE_AUTH, '', scope, function (error, result) {
if (error) return callback(error);
var env = [
'SIMPLE_AUTH_SERVER=172.18.0.1',
'SIMPLE_AUTH_PORT=' + config.get('simpleAuthPort'),
'SIMPLE_AUTH_URL=http://172.18.0.1:' + config.get('simpleAuthPort'), // obsolete, remove
'SIMPLE_AUTH_ORIGIN=http://172.18.0.1:' + config.get('simpleAuthPort'),
'SIMPLE_AUTH_CLIENT_ID=' + result.id
];
debugApp(app, 'Setting simple auth addon config to %j', env);
appdb.setAddonConfig(appId, 'simpleauth', env, callback);
});
});
}
function teardownSimpleAuth(app, options, callback) {
assert.strictEqual(typeof app, 'object');
assert.strictEqual(typeof options, 'object');
assert.strictEqual(typeof callback, 'function');
debugApp(app, 'teardownSimpleAuth');
clients.delByAppIdAndType(app.id, clients.TYPE_SIMPLE_AUTH, function (error) {
if (error && error.reason !== ClientsError.NOT_FOUND) console.error(error);
appdb.unsetAddonConfig(app.id, 'simpleauth', callback);
});
}
function setupEmail(app, options, callback) {
assert.strictEqual(typeof app, 'object');
assert.strictEqual(typeof options, 'object');
+23 -7
View File
@@ -1,5 +1,3 @@
/* jslint node:true */
'use strict';
exports = module.exports = {
@@ -54,13 +52,14 @@ var assert = require('assert'),
async = require('async'),
database = require('./database.js'),
DatabaseError = require('./databaseerror'),
mailboxdb = require('./mailboxdb.js'),
safe = require('safetydance'),
util = require('util');
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' ].join(',');
'apps.xFrameOptions', 'apps.sso', 'apps.debugModeJson' ].join(',');
var PORT_BINDINGS_FIELDS = [ 'hostPort', 'environmentVariable', 'appId' ].join(',');
@@ -98,6 +97,10 @@ function postProcess(result) {
result.xFrameOptions = result.xFrameOptions || 'SAMEORIGIN';
result.sso = !!result.sso; // make it bool
assert(result.debugModeJson === null || typeof result.debugModeJson === 'string');
result.debugMode = safe.JSON.parse(result.debugModeJson);
delete result.debugModeJson;
}
function get(id, callback) {
@@ -185,11 +188,12 @@ function add(id, appStoreId, manifest, location, portBindings, data, callback) {
var installationState = data.installationState || exports.ISTATE_PENDING_INSTALL;
var lastBackupId = data.lastBackupId || null; // used when cloning
var sso = 'sso' in data ? data.sso : null;
var debugModeJson = data.debugMode ? JSON.stringify(data.debugMode) : null;
var queries = [ ];
var queries = [];
queries.push({
query: 'INSERT INTO apps (id, appStoreId, manifestJson, installationState, location, accessRestrictionJson, memoryLimit, altDomain, xFrameOptions, lastBackupId, sso) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
args: [ id, appStoreId, manifestJson, installationState, location, accessRestrictionJson, memoryLimit, altDomain, xFrameOptions, lastBackupId, sso ]
query: 'INSERT INTO apps (id, appStoreId, manifestJson, installationState, location, accessRestrictionJson, memoryLimit, altDomain, xFrameOptions, lastBackupId, sso, debugModeJson) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
args: [ id, appStoreId, manifestJson, installationState, location, accessRestrictionJson, memoryLimit, altDomain, xFrameOptions, lastBackupId, sso, debugModeJson ]
});
Object.keys(portBindings).forEach(function (env) {
@@ -199,6 +203,14 @@ function add(id, appStoreId, manifest, location, portBindings, data, callback) {
});
});
// only allocate a mailbox if mailboxName is set
if (data.mailboxName) {
queries.push({
query: 'INSERT INTO mailboxes (name, ownerId, ownerType) VALUES (?, ?, ?)',
args: [ data.mailboxName, id, mailboxdb.TYPE_APP ]
});
}
database.transaction(queries, function (error) {
if (error && error.code === 'ER_DUP_ENTRY') return callback(new DatabaseError(DatabaseError.ALREADY_EXISTS, error.message));
if (error) return callback(new DatabaseError(DatabaseError.INTERNAL_ERROR, error));
@@ -239,13 +251,14 @@ function del(id, callback) {
assert.strictEqual(typeof callback, 'function');
var queries = [
{ query: 'DELETE FROM mailboxes WHERE ownerId=?', args: [ id ] },
{ query: 'DELETE FROM appPortBindings WHERE appId = ?', args: [ id ] },
{ query: 'DELETE FROM apps WHERE id = ?', args: [ id ] }
];
database.transaction(queries, function (error, results) {
if (error) return callback(new DatabaseError(DatabaseError.INTERNAL_ERROR, error));
if (results[1].affectedRows !== 1) return callback(new DatabaseError(DatabaseError.NOT_FOUND));
if (results[2].affectedRows !== 1) return callback(new DatabaseError(DatabaseError.NOT_FOUND));
callback(null);
});
@@ -299,6 +312,9 @@ function updateWithConstraints(id, app, constraints, callback) {
} else if (p === 'accessRestriction') {
fields.push('accessRestrictionJson = ?');
values.push(JSON.stringify(app[p]));
} else if (p === 'debugMode') {
fields.push('debugModeJson = ?');
values.push(JSON.stringify(app[p]));
} else if (p !== 'portBindings') {
fields.push(p + ' = ?');
values.push(app[p]);
+9 -9
View File
@@ -1,9 +1,9 @@
'use strict';
var appdb = require('./appdb.js'),
apps = require('./apps.js'),
assert = require('assert'),
async = require('async'),
config = require('./config.js'),
DatabaseError = require('./databaseerror.js'),
debug = require('debug')('box:apphealthmonitor'),
docker = require('./docker.js').connection,
@@ -50,7 +50,7 @@ function setHealth(app, health, callback) {
debugApp(app, 'marking as unhealthy since not seen for more than %s minutes', UNHEALTHY_THRESHOLD/(60 * 1000));
if (app.appStoreId !== '') mailer.appDied(app); // do not send mails for dev apps
if (!app.debugMode) mailer.appDied(app); // do not send mails for dev apps
gHealthInfo[app.id].emailSent = true;
} else {
debugApp(app, 'waiting for sometime to update the app health');
@@ -93,7 +93,7 @@ function checkAppHealth(app, callback) {
var healthCheckUrl = 'http://127.0.0.1:' + app.httpPort + manifest.healthCheckPath;
superagent
.get(healthCheckUrl)
.set('Host', config.appFqdn(app.location)) // required for some apache configs with rewrite rules
.set('Host', app.fqdn) // required for some apache configs with rewrite rules
.redirects(0)
.timeout(HEALTHCHECK_INTERVAL)
.end(function (error, res) {
@@ -111,13 +111,13 @@ function checkAppHealth(app, callback) {
}
function processApps(callback) {
appdb.getAll(function (error, apps) {
apps.getAll(function (error, result) {
if (error) return callback(error);
async.each(apps, checkAppHealth, function (error) {
async.each(result, checkAppHealth, function (error) {
if (error) console.error(error);
var alive = apps
var alive = result
.filter(function (a) { return a.installationState === appdb.ISTATE_INSTALLED && a.runState === appdb.RSTATE_RUNNING && a.health === appdb.HEALTH_HEALTHY; })
.map(function (a) { return (a.location || 'naked_domain') + '|' + a.manifest.id; }).join(', ');
@@ -138,7 +138,7 @@ function run() {
/*
OOM can be tested using stress tool like so:
docker run -ti -m 100M cloudron/base:0.9.0 /bin/bash
docker run -ti -m 100M cloudron/base:0.10.0 /bin/bash
apt-get update && apt-get install stress
stress --vm 1 --vm-bytes 200M --vm-hang 0
*/
@@ -166,8 +166,8 @@ function processDockerEvents() {
debug('OOM Context: %s', context);
// do not send mails for dev apps
if ((!app || app.appStoreId !== '') && (now - lastOomMailTime > OOM_MAIL_LIMIT)) {
mailer.unexpectedExit(program, context); // app can be null if it's an addon crash
if ((!app || !app.debugMode) && (now - lastOomMailTime > OOM_MAIL_LIMIT)) {
mailer.oomEvent(program, context); // app can be null if it's an addon crash
lastOomMailTime = now;
}
});
+82 -64
View File
@@ -129,18 +129,21 @@ function validateHostname(location, fqdn) {
// validate the port bindings
function validatePortBindings(portBindings, tcpPorts) {
assert.strictEqual(typeof portBindings, 'object');
// keep the public ports in sync with firewall rules in scripts/initializeBaseUbuntuImage.sh
// these ports are reserved even if we listen only on 127.0.0.1 because we setup HostIp to be 127.0.0.1
// for custom tcp ports
var RESERVED_PORTS = [
22, /* ssh */
25, /* smtp */
53, /* dns */
80, /* http */
143, /* imap */
202, /* caas ssh */
443, /* https */
465, /* smtps */
587, /* submission */
919, /* ssh */
993, /* imaps */
2003, /* graphite (lo) */
2004, /* graphite (lo) */
@@ -149,7 +152,6 @@ function validatePortBindings(portBindings, tcpPorts) {
config.get('sysadminPort'), /* sysadmin app server (lo) */
config.get('smtpPort'), /* internal smtp port (lo) */
config.get('ldapPort'), /* ldap server (lo) */
config.get('simpleAuthPort'), /* simple auth server (lo) */
3306, /* mysql (lo) */
4190, /* managesieve */
8000 /* graphite (lo) */
@@ -162,9 +164,9 @@ function validatePortBindings(portBindings, tcpPorts) {
if (!/^[a-zA-Z0-9_]+$/.test(env)) return new AppsError(AppsError.BAD_FIELD, env + ' is not valid environment variable');
if (!Number.isInteger(portBindings[env])) return new AppsError(AppsError.BAD_FIELD, portBindings[env] + ' is not an integer');
if (portBindings[env] <= 0 || portBindings[env] > 65535) return new AppsError(AppsError.BAD_FIELD, portBindings[env] + ' is out of range');
if (RESERVED_PORTS.indexOf(portBindings[env]) !== -1) return new AppsError(AppsError.PORT_RESERVED, String(portBindings[env]));
if (portBindings[env] <= 1023 || portBindings[env] > 65535) return new AppsError(AppsError.BAD_FIELD, portBindings[env] + ' is not in permitted range');
}
// it is OK if there is no 1-1 mapping between values in manifest.tcpPorts and portBindings. missing values implies
@@ -207,6 +209,9 @@ function validateMemoryLimit(manifest, memoryLimit) {
// this is needed so an app update can change the value in the manifest, and if not set by the user, the new value should be used
if (memoryLimit === 0) return null;
// a special value that indicates unlimited memory
if (memoryLimit === -1) return null;
if (memoryLimit < min) return new AppsError(AppsError.BAD_FIELD, 'memoryLimit too small');
if (memoryLimit > max) return new AppsError(AppsError.BAD_FIELD, 'memoryLimit too large');
@@ -227,6 +232,16 @@ function validateXFrameOptions(xFrameOptions) {
return (uri.protocol === 'http:' || uri.protocol === 'https:') ? null : new AppsError(AppsError.BAD_FIELD, 'xFrameOptions ALLOW-FROM uri must be a valid http[s] uri' );
}
function validateDebugMode(debugMode) {
assert.strictEqual(typeof debugMode, 'object');
if (debugMode === null) return null;
if ('cmd' in debugMode && debugMode.cmd !== null && !Array.isArray(debugMode.cmd)) return new AppsError(AppsError.BAD_FIELD, 'debugMode.cmd must be an array or null' );
if ('readonlyRootfs' in debugMode && typeof debugMode.readonlyRootfs !== 'boolean') return new AppsError(AppsError.BAD_FIELD, 'debugMode.readonlyRootfs must be a boolean' );
return null;
}
function getDuplicateErrorDetails(location, portBindings, error) {
assert.strictEqual(typeof location, 'string');
assert.strictEqual(typeof portBindings, 'object');
@@ -234,7 +249,7 @@ function getDuplicateErrorDetails(location, portBindings, error) {
var match = error.message.match(/ER_DUP_ENTRY: Duplicate entry '(.*)' for key/);
if (!match) {
console.error('Unexpected SQL error message.', error);
debug('Unexpected SQL error message.', error);
return new AppsError(AppsError.INTERNAL_ERROR);
}
@@ -262,7 +277,7 @@ function getAppConfig(app) {
}
function getIconUrlSync(app) {
var iconPath = paths.APPICONS_DIR + '/' + app.id + '.png';
var iconPath = paths.APP_ICONS_DIR + '/' + app.id + '.png';
return fs.existsSync(iconPath) ? '/api/v1/apps/' + app.id + '/icon' : null;
}
@@ -280,11 +295,9 @@ function hasAccessTo(app, user, callback) {
if (!app.accessRestriction.groups) return callback(null, false);
async.some(app.accessRestriction.groups, function (groupId, iteratorDone) {
groups.isMember(groupId, user.id, function (error, member) {
iteratorDone(!error && member); // async.some does not take error argument in callback
});
}, function (result) {
callback(null, result);
groups.isMember(groupId, user.id, iteratorDone);
}, function (error, result) {
callback(null, !error && result);
});
}
@@ -298,6 +311,7 @@ function get(appId, callback) {
app.iconUrl = getIconUrlSync(app);
app.fqdn = app.altDomain || config.appFqdn(app.location);
app.cnameTarget = app.altDomain ? config.appFqdn(app.location) : null;
callback(null, app);
});
@@ -316,6 +330,7 @@ function getByIpAddress(ip, callback) {
app.iconUrl = getIconUrlSync(app);
app.fqdn = app.altDomain || config.appFqdn(app.location);
app.cnameTarget = app.altDomain ? config.appFqdn(app.location) : null;
callback(null, app);
});
@@ -331,6 +346,7 @@ function getAll(callback) {
apps.forEach(function (app) {
app.iconUrl = getIconUrlSync(app);
app.fqdn = app.altDomain || config.appFqdn(app.location);
app.cnameTarget = app.altDomain ? config.appFqdn(app.location) : null;
});
callback(null, apps);
@@ -344,11 +360,9 @@ function getAllByUser(user, callback) {
getAll(function (error, result) {
if (error) return callback(error);
async.filter(result, function (app, callback) {
hasAccessTo(app, user, function (error, hasAccess) {
callback(hasAccess);
});
}, callback.bind(null, null)); // never error
async.filter(result, function (app, iteratorDone) {
hasAccessTo(app, user, iteratorDone);
}, callback);
});
}
@@ -370,7 +384,7 @@ function purchase(appId, appstoreId, callback) {
superagent.post(url).send(data).query({ accessToken: appstoreConfig.token }).timeout(30 * 1000).end(function (error, result) {
if (error && !error.response) return callback(new AppsError(AppsError.EXTERNAL_ERROR, error));
if (result.statusCode === 404) return callback(new AppsError(AppsError.NOT_FOUND));
if (result.statusCode === 403) return callback(new AppsError(AppsError.BILLING_REQUIRED));
if (result.statusCode === 403 || result.statusCode === 401) return callback(new AppsError(AppsError.BILLING_REQUIRED));
if (result.statusCode !== 201 && result.statusCode !== 200) return callback(new AppsError(AppsError.EXTERNAL_ERROR, util.format('App purchase failed. %s %j', result.status, result.body)));
callback(null);
@@ -412,10 +426,13 @@ function unpurchase(appId, appstoreId, callback) {
superagent.get(url).query({ accessToken: appstoreConfig.token }).timeout(30 * 1000).end(function (error, result) {
if (error && !error.response) return callback(new AppsError(AppsError.EXTERNAL_ERROR, error));
if (result.statusCode === 403 || result.statusCode === 401) return callback(new AppsError(AppsError.BILLING_REQUIRED));
if (result.statusCode === 404) return callback(null); // was never purchased
if (result.statusCode !== 201 && result.statusCode !== 200) return callback(new AppsError(AppsError.EXTERNAL_ERROR, util.format('App purchase failed. %s %j', result.status, result.body)));
superagent.del(url).query({ accessToken: appstoreConfig.token }).timeout(30 * 1000).end(function (error, result) {
if (error && !error.response) return callback(new AppsError(AppsError.EXTERNAL_ERROR, error));
if (result.statusCode === 403 || result.statusCode === 401) return callback(new AppsError(AppsError.BILLING_REQUIRED));
if (result.statusCode !== 204) return callback(new AppsError(AppsError.EXTERNAL_ERROR, util.format('App unpurchase failed. %s %j', result.status, result.body)));
callback(null);
@@ -476,7 +493,8 @@ function install(data, auditSource, callback) {
memoryLimit = data.memoryLimit || 0,
altDomain = data.altDomain || null,
xFrameOptions = data.xFrameOptions || 'SAMEORIGIN',
sso = 'sso' in data ? data.sso : null;
sso = 'sso' in data ? data.sso : null,
debugMode = data.debugMode || null;
assert(data.appStoreId || data.manifest); // atleast one of them is required
@@ -504,9 +522,12 @@ function install(data, auditSource, callback) {
error = validateXFrameOptions(xFrameOptions);
if (error) return callback(error);
error = validateDebugMode(debugMode);
if (error) return callback(error);
if ('sso' in data && !('optionalSso' in manifest)) return callback(new AppsError(AppsError.BAD_FIELD, 'sso can only be specified for apps with optionalSso'));
// if sso was unspecified, enable it by default if possible
if (sso === null) sso = !!manifest.addons['simpleauth'] || !!manifest.addons['ldap'] || !!manifest.addons['oauth'];
if (sso === null) sso = !!manifest.addons['ldap'] || !!manifest.addons['oauth'];
if (altDomain !== null && !validator.isFQDN(altDomain)) return callback(new AppsError(AppsError.BAD_FIELD, 'Invalid alt domain'));
@@ -515,7 +536,7 @@ function install(data, auditSource, callback) {
if (icon) {
if (!validator.isBase64(icon)) return callback(new AppsError(AppsError.BAD_FIELD, 'icon is not base64'));
if (!safe.fs.writeFileSync(path.join(paths.APPICONS_DIR, appId + '.png'), new Buffer(icon, 'base64'))) {
if (!safe.fs.writeFileSync(path.join(paths.APP_ICONS_DIR, appId + '.png'), new Buffer(icon, 'base64'))) {
return callback(new AppsError(AppsError.INTERNAL_ERROR, 'Error saving icon:' + safe.error.message));
}
}
@@ -533,30 +554,26 @@ function install(data, auditSource, callback) {
memoryLimit: memoryLimit,
altDomain: altDomain,
xFrameOptions: xFrameOptions,
sso: sso
sso: sso,
debugMode: debugMode,
mailboxName: (location ? location : manifest.title.toLowerCase().replace(/[^a-zA-Z0-9]/g, '')) + '.app'
};
var from = (location ? location : manifest.title.toLowerCase().replace(/[^a-zA-Z0-9]/g, '')) + '.app';
mailboxdb.add(from, appId, mailboxdb.TYPE_APP, function (error) {
if (error && error.reason === DatabaseError.ALREADY_EXISTS) return callback(new AppsError(AppsError.ALREADY_EXISTS, 'Mailbox already exists'));
appdb.add(appId, appStoreId, manifest, location, portBindings, data, function (error) {
if (error && error.reason === DatabaseError.ALREADY_EXISTS) return callback(getDuplicateErrorDetails(location, portBindings, error));
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
appdb.add(appId, appStoreId, manifest, location, portBindings, data, function (error) {
if (error && error.reason === DatabaseError.ALREADY_EXISTS) return callback(getDuplicateErrorDetails(location, portBindings, error));
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
// save cert to boxdata/certs
if (cert && key) {
if (!safe.fs.writeFileSync(path.join(paths.APP_CERTS_DIR, config.appFqdn(location) + '.user.cert'), cert)) return callback(new AppsError(AppsError.INTERNAL_ERROR, 'Error saving cert: ' + safe.error.message));
if (!safe.fs.writeFileSync(path.join(paths.APP_CERTS_DIR, config.appFqdn(location) + '.user.key'), key)) return callback(new AppsError(AppsError.INTERNAL_ERROR, 'Error saving key: ' + safe.error.message));
}
// save cert to data/box/certs
if (cert && key) {
if (!safe.fs.writeFileSync(path.join(paths.APP_CERTS_DIR, config.appFqdn(location) + '.user.cert'), cert)) return callback(new AppsError(AppsError.INTERNAL_ERROR, 'Error saving cert: ' + safe.error.message));
if (!safe.fs.writeFileSync(path.join(paths.APP_CERTS_DIR, config.appFqdn(location) + '.user.key'), key)) return callback(new AppsError(AppsError.INTERNAL_ERROR, 'Error saving key: ' + safe.error.message));
}
taskmanager.restartAppTask(appId);
taskmanager.restartAppTask(appId);
eventlog.add(eventlog.ACTION_APP_INSTALL, auditSource, { appId: appId, location: location, manifest: manifest });
eventlog.add(eventlog.ACTION_APP_INSTALL, auditSource, { appId: appId, location: location, manifest: manifest });
callback(null, { id : appId });
});
callback(null, { id : appId });
});
});
});
@@ -612,7 +629,13 @@ function configure(appId, data, auditSource, callback) {
if (error) return callback(error);
}
// save cert to data/box/certs. TODO: move this to apptask when we have a real task queue
if ('debugMode' in data) {
values.debugMode = data.debugMode;
error = validateDebugMode(values.debugMode);
if (error) return callback(error);
}
// save cert to boxdata/certs. TODO: move this to apptask when we have a real task queue
if ('cert' in data && 'key' in data) {
if (data.cert && data.key) {
error = certificates.validateCertificate(data.cert, data.key, config.appFqdn(location));
@@ -683,11 +706,11 @@ function update(appId, data, auditSource, callback) {
if (data.icon) {
if (!validator.isBase64(data.icon)) return callback(new AppsError(AppsError.BAD_FIELD, 'icon is not base64'));
if (!safe.fs.writeFileSync(path.join(paths.APPICONS_DIR, appId + '.png'), new Buffer(data.icon, 'base64'))) {
if (!safe.fs.writeFileSync(path.join(paths.APP_ICONS_DIR, appId + '.png'), new Buffer(data.icon, 'base64'))) {
return callback(new AppsError(AppsError.INTERNAL_ERROR, 'Error saving icon:' + safe.error.message));
}
} else {
safe.fs.unlinkSync(path.join(paths.APPICONS_DIR, appId + '.png'));
safe.fs.unlinkSync(path.join(paths.APP_ICONS_DIR, appId + '.png'));
}
}
@@ -699,12 +722,16 @@ function update(appId, data, auditSource, callback) {
// this allows cloudron install -f --app <appid> for an app installed from the appStore
if (app.manifest.id !== values.manifest.id) {
if (!data.force) return callback(new AppsError(AppsError.BAD_FIELD, 'manifest id does not match. force to override'));
// clear appStoreId so that this app does not get updates anymore. this will mark it as a dev app
// clear appStoreId so that this app does not get updates anymore
values.appStoreId = '';
}
// do not update apps in debug mode
if (app.debugMode && !data.force) return callback(new AppsError(AppsError.BAD_STATE, 'debug mode enabled. force to override'));
// Ensure we update the memory limit in case the new app requires more memory as a minimum
if (values.manifest.memoryLimit && app.memoryLimit < values.manifest.memoryLimit) {
// 0 and -1 are special values for memory limit indicating unset and unlimited
if (app.memoryLimit > 0 && values.manifest.memoryLimit && app.memoryLimit < values.manifest.memoryLimit) {
values.memoryLimit = values.manifest.memoryLimit;
}
@@ -867,24 +894,19 @@ function clone(appId, data, auditSource, callback) {
accessRestriction: app.accessRestriction,
xFrameOptions: app.xFrameOptions,
lastBackupId: backupId,
sso: !!app.sso
sso: !!app.sso,
mailboxName: (location ? location : manifest.title.toLowerCase().replace(/[^a-zA-Z0-9]/g, '')) + '.app'
};
var from = (location ? location : manifest.title.toLowerCase().replace(/[^a-zA-Z0-9]/g, '')) + '.app';
mailboxdb.add(from, newAppId, mailboxdb.TYPE_APP, function (error) {
if (error && error.reason === DatabaseError.ALREADY_EXISTS) return callback(new AppsError(AppsError.ALREADY_EXISTS, 'Mailbox already exists'));
appdb.add(newAppId, appStoreId, manifest, location, portBindings, data, function (error) {
if (error && error.reason === DatabaseError.ALREADY_EXISTS) return callback(getDuplicateErrorDetails(location, portBindings, error));
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
appdb.add(newAppId, appStoreId, manifest, location, portBindings, data, function (error) {
if (error && error.reason === DatabaseError.ALREADY_EXISTS) return callback(getDuplicateErrorDetails(location, portBindings, error));
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
taskmanager.restartAppTask(newAppId);
taskmanager.restartAppTask(newAppId);
eventlog.add(eventlog.ACTION_APP_CLONE, auditSource, { appId: newAppId, oldAppId: appId, backupId: backupId, location: location, manifest: manifest });
eventlog.add(eventlog.ACTION_APP_CLONE, auditSource, { appId: newAppId, oldAppId: appId, backupId: backupId, location: location, manifest: manifest });
callback(null, { id : newAppId });
});
callback(null, { id : newAppId });
});
});
});
@@ -904,18 +926,14 @@ function uninstall(appId, auditSource, callback) {
unpurchase(appId, result.appStoreId, function (error) {
if (error) return callback(error);
mailboxdb.delByOwnerId(appId, function (error) {
if (error && error.reason !== DatabaseError.NOT_FOUND) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
taskmanager.stopAppTask(appId, function () {
appdb.setInstallationCommand(appId, appdb.ISTATE_PENDING_UNINSTALL, function (error) {
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new AppsError(AppsError.NOT_FOUND, 'No such app'));
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
taskmanager.stopAppTask(appId, function () {
appdb.setInstallationCommand(appId, appdb.ISTATE_PENDING_UNINSTALL, function (error) {
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new AppsError(AppsError.NOT_FOUND, 'No such app'));
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
eventlog.add(eventlog.ACTION_APP_UNINSTALL, auditSource, { appId: appId });
eventlog.add(eventlog.ACTION_APP_UNINSTALL, auditSource, { appId: appId });
taskmanager.startAppTask(appId, callback);
});
taskmanager.startAppTask(appId, callback);
});
});
});
+27 -22
View File
@@ -22,9 +22,8 @@ exports = module.exports = {
require('supererror')({ splatchError: true });
// remove timestamp from debug() based output
require('debug').formatArgs = function formatArgs() {
arguments[0] = this.namespace + ' ' + arguments[0];
return arguments;
require('debug').formatArgs = function formatArgs(args) {
args[0] = this.namespace + ' ' + args[0];
};
var addons = require('./addons.js'),
@@ -34,8 +33,6 @@ var addons = require('./addons.js'),
async = require('async'),
backups = require('./backups.js'),
certificates = require('./certificates.js'),
clients = require('./clients.js'),
ClientsError = clients.ClientsError,
config = require('./config.js'),
database = require('./database.js'),
debug = require('debug')('box:apptask'),
@@ -193,6 +190,9 @@ function downloadIcon(app, callback) {
assert.strictEqual(typeof app, 'object');
assert.strictEqual(typeof callback, 'function');
// nothing to download if we dont have an appStoreId
if (!app.appStoreId) return callback(null);
debugApp(app, 'Downloading icon of %s@%s', app.appStoreId, app.manifest.version);
var iconUrl = config.apiServerOrigin() + '/api/v1/apps/' + app.appStoreId + '/versions/' + app.manifest.version + '/icon';
@@ -206,22 +206,21 @@ function downloadIcon(app, callback) {
if (error && !error.response) return retryCallback(new Error('Network error downloading icon:' + error.message));
if (res.statusCode !== 200) return retryCallback(null); // ignore error. this can also happen for apps installed with cloudron-cli
if (!safe.fs.writeFileSync(path.join(paths.APPICONS_DIR, app.id + '.png'), res.body)) return retryCallback(new Error('Error saving icon:' + safe.error.message));
if (!safe.fs.writeFileSync(path.join(paths.APP_ICONS_DIR, app.id + '.png'), res.body)) return retryCallback(new Error('Error saving icon:' + safe.error.message));
retryCallback(null);
});
}, callback);
}
function registerSubdomain(app, callback) {
function registerSubdomain(app, overwrite, callback) {
assert.strictEqual(typeof app, 'object');
assert.strictEqual(typeof overwrite, 'boolean');
assert.strictEqual(typeof callback, 'function');
sysinfo.getIp(function (error, ip) {
sysinfo.getPublicIp(function (error, ip) {
if (error) return callback(error);
// even though the bare domain is already registered in the appstore, we still
// need to register it so that we have a dnsRecordId to wait for it to complete
async.retry({ times: 200, interval: 5000 }, function (retryCallback) {
debugApp(app, 'Registering subdomain location [%s]', app.location);
@@ -231,7 +230,7 @@ function registerSubdomain(app, callback) {
// refuse to update any existing DNS record for custom domains that we did not create
// note that the appstore sets up the naked domain for non-custom domains
if (config.isCustomDomain() && values.length !== 0 && !app.dnsRecordId) return retryCallback(null, new Error('DNS Record already exists'));
if (config.isCustomDomain() && values.length !== 0 && !overwrite) return retryCallback(null, new Error('DNS Record already exists'));
subdomains.upsert(app.location, 'A', [ ip ], function (error, changeId) {
if (error && (error.reason === SubdomainError.STILL_BUSY || error.reason === SubdomainError.EXTERNAL_ERROR)) return retryCallback(error); // try again
@@ -258,7 +257,7 @@ function unregisterSubdomain(app, location, callback) {
return callback(null);
}
sysinfo.getIp(function (error, ip) {
sysinfo.getPublicIp(function (error, ip) {
if (error) return callback(error);
async.retry({ times: 30, interval: 5000 }, function (retryCallback) {
@@ -281,7 +280,7 @@ function removeIcon(app, callback) {
assert.strictEqual(typeof app, 'object');
assert.strictEqual(typeof callback, 'function');
fs.unlink(path.join(paths.APPICONS_DIR, app.id + '.png'), function (error) {
fs.unlink(path.join(paths.APP_ICONS_DIR, app.id + '.png'), function (error) {
if (error && error.code !== 'ENOENT') debugApp(app, 'cannot remove icon : %s', error);
callback(null);
});
@@ -296,7 +295,7 @@ function waitForDnsPropagation(app, callback) {
return callback(null);
}
sysinfo.getIp(function (error, ip) {
sysinfo.getPublicIp(function (error, ip) {
if (error) return callback(error);
subdomains.waitForDns(config.appFqdn(app.location), ip, 'A', { interval: 5000, times: 120 }, callback);
@@ -356,7 +355,6 @@ function install(app, callback) {
addons.teardownAddons.bind(null, app, app.manifest.addons),
deleteVolume.bind(null, app),
unregisterSubdomain.bind(null, app, app.location),
// removeIcon.bind(null, app), // do not remove icon for non-appstore installs
reserveHttpPort.bind(null, app),
@@ -364,7 +362,7 @@ function install(app, callback) {
downloadIcon.bind(null, app),
updateApp.bind(null, app, { installationProgress: '30, Registering subdomain' }),
registerSubdomain.bind(null, app),
registerSubdomain.bind(null, app, false /* overwrite */),
updateApp.bind(null, app, { installationProgress: '40, Downloading image' }),
docker.downloadImage.bind(null, app.manifest),
@@ -412,7 +410,7 @@ function backup(app, callback) {
async.series([
updateApp.bind(null, app, { installationProgress: '10, Backing up' }),
backups.backupApp.bind(null, app, app.manifest),
backups.backupApp.bind(null, app, app.manifest, 'appbackups' /* tag */),
// done!
function (callback) {
@@ -456,7 +454,6 @@ function restore(app, callback) {
docker.deleteImage(app.oldConfig.manifest, done);
},
removeIcon.bind(null, app),
reserveHttpPort.bind(null, app),
@@ -464,7 +461,7 @@ function restore(app, callback) {
downloadIcon.bind(null, app),
updateApp.bind(null, app, { installationProgress: '55, Registering subdomain' }), // ip might change during upgrades
registerSubdomain.bind(null, app),
registerSubdomain.bind(null, app, true /* overwrite */),
updateApp.bind(null, app, { installationProgress: '60, Downloading image' }),
docker.downloadImage.bind(null, app.manifest),
@@ -526,8 +523,17 @@ function configure(app, callback) {
reserveHttpPort.bind(null, app),
updateApp.bind(null, app, { installationProgress: '20, Downloading icon' }),
downloadIcon.bind(null, app),
updateApp.bind(null, app, { installationProgress: '35, Registering subdomain' }),
registerSubdomain.bind(null, app),
registerSubdomain.bind(null, app, true /* overwrite */),
updateApp.bind(null, app, { installationProgress: '40, Downloading image' }),
docker.downloadImage.bind(null, app.manifest),
updateApp.bind(null, app, { installationProgress: '45, Ensuring volume' }),
createVolume.bind(null, app),
// re-setup addons since they rely on the app's fqdn (e.g oauth)
updateApp.bind(null, app, { installationProgress: '50, Setting up addons' }),
@@ -595,14 +601,13 @@ function update(app, callback) {
docker.deleteImage(app.oldConfig.manifest, done);
},
// removeIcon.bind(null, app), // do not remove icon, otherwise the UI breaks for a short time...
function (next) {
if (app.installationState === appdb.ISTATE_PENDING_FORCE_UPDATE) return next(null);
async.series([
updateApp.bind(null, app, { installationProgress: '30, Backing up app' }),
backups.backupApp.bind(null, app, app.oldConfig.manifest)
backups.backupApp.bind(null, app, app.oldConfig.manifest, 'appbackups' /* tag */)
], next);
},
+2 -1
View File
@@ -49,8 +49,9 @@ function getByAppIdPaged(page, perPage, appId, callback) {
assert.strictEqual(typeof appId, 'string');
assert.strictEqual(typeof callback, 'function');
// box versions (0.93.x and below) used to use appbackup_ prefix
database.query('SELECT ' + BACKUPS_FIELDS + ' FROM backups WHERE type = ? AND state = ? AND id LIKE ? ORDER BY creationTime DESC LIMIT ?,?',
[ exports.BACKUP_TYPE_APP, exports.BACKUP_STATE_NORMAL, 'appbackup\\_' + appId + '\\_%', (page-1)*perPage, perPage ], function (error, results) {
[ exports.BACKUP_TYPE_APP, exports.BACKUP_STATE_NORMAL, '%app%\\_' + appId + '\\_%', (page-1)*perPage, perPage ], function (error, results) {
if (error) return callback(new DatabaseError(DatabaseError.INTERNAL_ERROR, error));
results.forEach(function (result) { postProcess(result); });
+34 -51
View File
@@ -46,8 +46,7 @@ var addons = require('./addons.js'),
shell = require('./shell.js'),
settings = require('./settings.js'),
SettingsError = require('./settings.js').SettingsError,
util = require('util'),
webhooks = require('./webhooks.js');
util = require('util');
var BACKUP_BOX_CMD = path.join(__dirname, 'scripts/backupbox.sh'),
BACKUP_APP_CMD = path.join(__dirname, 'scripts/backupapp.sh'),
@@ -132,7 +131,6 @@ function getByAppIdPaged(page, perPage, appId, callback) {
});
}
// backupId is the filename. appbackup_%s_%s-v%s.tar.gz
function getRestoreConfig(backupId, callback) {
assert.strictEqual(typeof backupId, 'string');
assert.strictEqual(typeof callback, 'function');
@@ -149,7 +147,6 @@ function getRestoreConfig(backupId, callback) {
});
}
// backupId is the filename. appbackup_%s_%s-v%s.tar.gz
function getRestoreUrl(backupId, callback) {
assert.strictEqual(typeof backupId, 'string');
assert.strictEqual(typeof callback, 'function');
@@ -174,15 +171,16 @@ function getRestoreUrl(backupId, callback) {
});
}
function copyLastBackup(app, manifest, callback) {
function copyLastBackup(app, manifest, prefix, callback) {
assert.strictEqual(typeof app, 'object');
assert.strictEqual(typeof app.lastBackupId, 'string');
assert(manifest && typeof manifest === 'object');
assert.strictEqual(typeof prefix, 'string');
assert.strictEqual(typeof callback, 'function');
var now = new Date();
var toFilenameArchive = util.format('appbackup_%s_%s-v%s.tar.gz', app.id, now.toISOString(), manifest.version);
var toFilenameConfig = util.format('appbackup_%s_%s-v%s.json', app.id, now.toISOString(), manifest.version);
var timestamp = (new Date()).toISOString().replace(/[T.]/g, '-').replace(/[:Z]/g,'');
var toFilenameArchive = util.format('%s/app_%s_%s_v%s.tar.gz', prefix, app.id, timestamp, manifest.version);
var toFilenameConfig = util.format('%s/app_%s_%s_v%s.json', prefix, app.id, timestamp, manifest.version);
settings.getBackupConfig(function (error, backupConfig) {
if (error) return callback(new BackupsError(BackupsError.INTERNAL_ERROR, error));
@@ -206,11 +204,12 @@ function copyLastBackup(app, manifest, callback) {
});
}
function backupBoxWithAppBackupIds(appBackupIds, callback) {
function backupBoxWithAppBackupIds(appBackupIds, prefix, callback) {
assert(util.isArray(appBackupIds));
assert.strictEqual(typeof prefix, 'string');
var now = new Date();
var filebase = util.format('backup_%s-v%s', now.toISOString(), config.version());
var timestamp = (new Date()).toISOString().replace(/[T.]/g, '-').replace(/[:Z]/g,'');
var filebase = util.format('%s/box_%s_v%s', prefix, timestamp, config.version());
var filename = filebase + '.tar.gz';
settings.getBackupConfig(function (error, backupConfig) {
@@ -229,7 +228,7 @@ function backupBoxWithAppBackupIds(appBackupIds, callback) {
backupdb.add({ id: filename, version: config.version(), type: backupdb.BACKUP_TYPE_BOX, dependsOn: appBackupIds }, function (error) {
if (error) return callback(new BackupsError(BackupsError.INTERNAL_ERROR, error));
webhooks.backupDone(filename, null /* app */, appBackupIds, function (error) {
api(backupConfig.provider).backupDone(filename, null /* app */, appBackupIds, function (error) {
if (error) return callback(error);
callback(null, filename);
});
@@ -239,18 +238,6 @@ function backupBoxWithAppBackupIds(appBackupIds, callback) {
});
}
// this function expects you to have a lock
// function backupBox(callback) {
// apps.getAll(function (error, allApps) {
// if (error) return callback(new BackupsError(BackupsError.INTERNAL_ERROR, error));
//
// var appBackupIds = allApps.map(function (app) { return app.lastBackupId; });
// appBackupIds = appBackupIds.filter(function (id) { return id !== null; }); // remove apps that were never backed up
//
// backupBoxWithAppBackupIds(appBackupIds, callback);
// });
// }
function canBackupApp(app) {
// only backup apps that are installed or pending configure or called from apptask. Rest of them are in some
// state not good for consistent backup (i.e addons may not have been setup completely)
@@ -260,29 +247,14 @@ function canBackupApp(app) {
app.installationState === appdb.ISTATE_PENDING_UPDATE; // called from apptask
}
// set the 'creation' date of lastBackup so that the backup persists across time based archival rules
// s3 does not allow changing creation time, so copying the last backup is easy way out for now
function reuseOldAppBackup(app, manifest, callback) {
assert.strictEqual(typeof app.lastBackupId, 'string');
assert(manifest && typeof manifest === 'object');
assert.strictEqual(typeof callback, 'function');
copyLastBackup(app, manifest, function (error, newBackupId) {
if (error) return callback(error);
debugApp(app, 'reuseOldAppBackup: reused old backup %s as %s', app.lastBackupId, newBackupId);
callback(null, newBackupId);
});
}
function createNewAppBackup(app, manifest, callback) {
function createNewAppBackup(app, manifest, prefix, callback) {
assert.strictEqual(typeof app, 'object');
assert(manifest && typeof manifest === 'object');
assert.strictEqual(typeof prefix, 'string');
assert.strictEqual(typeof callback, 'function');
var now = new Date();
var filebase = util.format('appbackup_%s_%s-v%s', app.id, now.toISOString(), manifest.version);
var timestamp = (new Date()).toISOString().replace(/[T.]/g, '-').replace(/[:Z]/g,'');
var filebase = util.format('%s/app_%s_%s_v%s', prefix, app.id, timestamp, manifest.version);
var configFilename = filebase + '.json', dataFilename = filebase + '.tar.gz';
settings.getBackupConfig(function (error, backupConfig) {
@@ -324,9 +296,10 @@ function setRestorePoint(appId, lastBackupId, callback) {
});
}
function backupApp(app, manifest, callback) {
function backupApp(app, manifest, prefix, callback) {
assert.strictEqual(typeof app, 'object');
assert(manifest && typeof manifest === 'object');
assert.strictEqual(typeof prefix, 'string');
assert.strictEqual(typeof callback, 'function');
var backupFunction;
@@ -337,11 +310,13 @@ function backupApp(app, manifest, callback) {
return callback(new BackupsError(BackupsError.BAD_STATE, 'App not healthy and never backed up previously'));
}
backupFunction = reuseOldAppBackup.bind(null, app, manifest);
// set the 'creation' date of lastBackup so that the backup persists across time based archival rules
// s3 does not allow changing creation time, so copying the last backup is easy way out for now
backupFunction = copyLastBackup.bind(null, app, manifest, prefix);
} else {
var appConfig = apps.getAppConfig(app);
appConfig.manifest = manifest;
backupFunction = createNewAppBackup.bind(null, app, manifest);
backupFunction = createNewAppBackup.bind(null, app, manifest, prefix);
if (!safe.fs.writeFileSync(path.join(paths.DATA_DIR, app.id + '/config.json'), JSON.stringify(appConfig), 'utf8')) {
return callback(safe.error);
@@ -367,6 +342,8 @@ function backupBoxAndApps(auditSource, callback) {
callback = callback || NOOP_CALLBACK;
var prefix = (new Date()).toISOString().replace(/[T.]/g, '-').replace(/[:Z]/g,'');
eventlog.add(eventlog.ACTION_BACKUP_START, auditSource, { });
apps.getAll(function (error, allApps) {
@@ -375,18 +352,20 @@ function backupBoxAndApps(auditSource, callback) {
var processed = 0;
var step = 100/(allApps.length+1);
progress.set(progress.BACKUP, processed, '');
progress.set(progress.BACKUP, step * processed, '');
async.mapSeries(allApps, function iterator(app, iteratorCallback) {
progress.set(progress.BACKUP, step * processed, 'Backing up ' + (app.altDomain || config.appFqdn(app.location)));
++processed;
backupApp(app, app.manifest, function (error, backupId) {
backupApp(app, app.manifest, prefix, function (error, backupId) {
if (error && error.reason !== BackupsError.BAD_STATE) {
debugApp(app, 'Unable to backup', error);
return iteratorCallback(error);
}
progress.set(progress.BACKUP, step * processed, 'Backed up app at ' + app.location);
progress.set(progress.BACKUP, step * processed, 'Backed up ' + (app.altDomain || config.appFqdn(app.location)));
iteratorCallback(null, backupId || null); // clear backupId if is in BAD_STATE and never backed up
});
@@ -398,7 +377,9 @@ function backupBoxAndApps(auditSource, callback) {
backupIds = backupIds.filter(function (id) { return id !== null; }); // remove apps in bad state that were never backed up
backupBoxWithAppBackupIds(backupIds, function (error, filename) {
progress.set(progress.BACKUP, step * processed, 'Backing up system data');
backupBoxWithAppBackupIds(backupIds, prefix, function (error, filename) {
progress.set(progress.BACKUP, 100, error ? error.message : '');
eventlog.add(eventlog.ACTION_BACKUP_FINISH, auditSource, { errorMessage: error ? error.message : null, filename: filename });
@@ -421,7 +402,7 @@ function backup(auditSource, callback) {
backupBoxAndApps(auditSource, function (error) { // start the backup operation in the background
if (error) {
debug('backup failed.', error);
mailer.backupFailed(JSON.stringify(error));
mailer.backupFailed(error);
}
locker.unlock(locker.OP_FULL_BACKUP);
@@ -433,6 +414,8 @@ function backup(auditSource, callback) {
function ensureBackup(auditSource, callback) {
assert.strictEqual(typeof auditSource, 'object');
debug('ensureBackup: %j', auditSource);
getPaged(1, 1, function (error, backups) {
if (error) {
debug('Unable to list backups', error);
+6 -2
View File
@@ -352,12 +352,16 @@ Acme.prototype.createKeyAndCsr = function (domain, callback) {
Acme.prototype.downloadChain = function (linkHeader, callback) {
if (!linkHeader) return new AcmeError(AcmeError.EXTERNAL_ERROR, 'Empty link header when downloading certificate chain');
debug('downloadChain: linkHeader %s', linkHeader);
var linkInfo = parseLinks(linkHeader);
if (!linkInfo || !linkInfo.up) return new AcmeError(AcmeError.EXTERNAL_ERROR, 'Failed to parse link header when downloading certificate chain');
debug('downloadChain: downloading from %s', this.caOrigin + linkInfo.up);
var intermediateCertUrl = linkInfo.up.startsWith('https://') ? linkInfo.up : (this.caOrigin + linkInfo.up);
superagent.get(this.caOrigin + linkInfo.up).buffer().parse(function (res, done) {
debug('downloadChain: downloading from %s', intermediateCertUrl);
superagent.get(intermediateCertUrl).buffer().parse(function (res, done) {
var data = [ ];
res.on('data', function(chunk) { data.push(chunk); });
res.on('end', function () { res.text = Buffer.concat(data); done(); });
+124 -47
View File
@@ -1,14 +1,25 @@
'use strict';
exports = module.exports = {
installAdminCertificate: installAdminCertificate,
renewAll: renewAll,
setFallbackCertificate: setFallbackCertificate,
setAdminCertificate: setAdminCertificate,
CertificatesError: CertificatesError,
ensureFallbackCertificate: ensureFallbackCertificate,
setFallbackCertificate: setFallbackCertificate,
validateCertificate: validateCertificate,
ensureCertificate: ensureCertificate,
getAdminCertificatePath: getAdminCertificatePath,
setAdminCertificate: setAdminCertificate,
getAdminCertificate: getAdminCertificate,
renewAll: renewAll,
initialize: initialize,
uninitialize: uninitialize,
events: null,
EVENT_CERT_CHANGED: 'cert_changed',
// exported for testing
_getApi: getApi
@@ -31,11 +42,8 @@ var acme = require('./cert/acme.js'),
paths = require('./paths.js'),
safe = require('safetydance'),
settings = require('./settings.js'),
subdomains = require('./subdomains.js'),
sysinfo = require('./sysinfo.js'),
user = require('./user.js'),
util = require('util'),
x509 = require('x509');
util = require('util');
function CertificatesError(reason, errorOrMessage) {
assert.strictEqual(typeof reason, 'string');
@@ -60,6 +68,20 @@ CertificatesError.INTERNAL_ERROR = 'Internal Error';
CertificatesError.INVALID_CERT = 'Invalid certificate';
CertificatesError.NOT_FOUND = 'Not Found';
function initialize(callback) {
assert.strictEqual(typeof callback, 'function');
exports.events = new (require('events').EventEmitter)();
callback();
}
function uninitialize(callback) {
assert.strictEqual(typeof callback, 'function');
exports.events = null;
callback();
}
function getApi(app, callback) {
assert.strictEqual(typeof app, 'object');
assert.strictEqual(typeof callback, 'function');
@@ -84,34 +106,53 @@ function getApi(app, callback) {
// we simply update the account with the latest email we have each time when getting letsencrypt certs
// https://github.com/ietf-wg-acme/acme/issues/30
user.getOwner(function (error, owner) {
options.email = error ? 'support@cloudron.io' : owner.email; // can error if not activated yet
options.email = error ? 'support@cloudron.io' : (owner.alternateEmail || owner.email); // can error if not activated yet
callback(null, api, options);
});
});
}
function installAdminCertificate(callback) {
if (process.env.BOX_ENV === 'test') return callback();
function ensureFallbackCertificate(callback) {
// ensure a fallback certificate that much of our code requires
var certFilePath = path.join(paths.APP_CERTS_DIR, 'host.cert');
var keyFilePath = path.join(paths.APP_CERTS_DIR, 'host.key');
debug('installAdminCertificate');
var fallbackCertPath = path.join(paths.NGINX_CERT_DIR, 'host.cert');
var fallbackKeyPath = path.join(paths.NGINX_CERT_DIR, 'host.key');
sysinfo.getIp(function (error, ip) {
if (error) return callback(error);
if (fs.existsSync(certFilePath) && fs.existsSync(keyFilePath)) { // existing custom fallback certs (when restarting, restoring, updating)
debug('ensureFallbackCertificate: using fallback certs provided by user');
if (!safe.child_process.execSync('cp ' + certFilePath + ' ' + fallbackCertPath)) return callback(new CertificatesError(CertificatesError.INTERNAL_ERROR, safe.error.message));
if (!safe.child_process.execSync('cp ' + keyFilePath + ' ' + fallbackKeyPath)) return callback(new CertificatesError(CertificatesError.INTERNAL_ERROR, safe.error.message));
subdomains.waitForDns(config.adminFqdn(), ip, 'A', { interval: 30000, times: 50000 }, function (error) {
if (error) return callback(error);
return callback();
}
ensureCertificate({ location: constants.ADMIN_LOCATION }, function (error, certFilePath, keyFilePath) {
if (error) { // currently, this can never happen
debug('Error obtaining certificate. Proceed anyway', error);
return callback();
}
if (config.tlsCert() && config.tlsKey()) {
// cert from CaaS or cloudron-setup. these files should _not_ be part of the backup
debug('ensureFallbackCertificate: using CaaS/cloudron-setup fallback certs');
if (!safe.fs.writeFileSync(fallbackCertPath, config.tlsCert())) return callback(new CertificatesError(CertificatesError.INTERNAL_ERROR, safe.error.message));
if (!safe.fs.writeFileSync(fallbackKeyPath, config.tlsKey())) return callback(new CertificatesError(CertificatesError.INTERNAL_ERROR, safe.error.message));
nginx.configureAdmin(certFilePath, keyFilePath, callback);
});
});
});
return callback();
}
// generate a self-signed cert. it's in backup dir so that we don't create a new cert across restarts
// FIXME: this cert does not cover the naked domain. needs SAN
if (config.fqdn()) {
debug('ensureFallbackCertificate: generating self-signed certificate');
var certCommand = util.format('openssl req -x509 -newkey rsa:2048 -keyout %s -out %s -days 3650 -subj /CN=*.%s -nodes', keyFilePath, certFilePath, config.fqdn());
safe.child_process.execSync(certCommand);
if (!safe.child_process.execSync('cp ' + certFilePath + ' ' + fallbackCertPath)) return callback(new CertificatesError(CertificatesError.INTERNAL_ERROR, safe.error.message));
if (!safe.child_process.execSync('cp ' + keyFilePath + ' ' + fallbackKeyPath)) return callback(new CertificatesError(CertificatesError.INTERNAL_ERROR, safe.error.message));
return callback();
} else {
debug('ensureFallbackCertificate: cannot generate fallback certificate without domain');
return callback(new CertificatesError(CertificatesError.INTERNAL_ERROR, 'No domain set'));
}
}
function isExpiringSync(certFilePath, hours) {
@@ -199,12 +240,14 @@ function renewAll(auditSource, callback) {
// reconfigure and reload nginx. this is required for the case where we got a renewed cert after fallback
var configureFunc = app.location === constants.ADMIN_LOCATION ?
nginx.configureAdmin.bind(null, certFilePath, keyFilePath)
nginx.configureAdmin.bind(null, certFilePath, keyFilePath, constants.NGINX_ADMIN_CONFIG_FILE_NAME, config.adminFqdn())
: nginx.configureApp.bind(null, app, certFilePath, keyFilePath);
configureFunc(function (ignoredError) {
if (ignoredError) debug('fallbackExpiredCertificates: error reconfiguring app', ignoredError);
exports.events.emit(exports.EVENT_CERT_CHANGED, domain);
iteratorCallback(); // move to next app
});
});
@@ -224,25 +267,30 @@ function validateCertificate(cert, key, fqdn) {
if (!cert && key) return new Error('missing cert');
if (cert && !key) return new Error('missing key');
var content;
try {
content = x509.parseCert(cert);
} catch (e) {
return new Error('invalid cert: ' + e.message);
}
// check expiration
if (content.notAfter < new Date()) return new Error('cert expired');
function matchesDomain(domain) {
if (typeof domain !== 'string') return false;
if (domain === fqdn) return true;
if (domain.indexOf('*') === 0 && domain.slice(2) === fqdn.slice(fqdn.indexOf('.') + 1)) return true;
return false;
}
// check domain
var domains = content.altNames.concat(content.subject.commonName);
// get commonName (http://stackoverflow.com/questions/17353122/parsing-strings-crt-files)
var result = safe.child_process.execSync('openssl x509 -noout -subject | sed -r "s|.*CN=(.*)|\\1|; s|/[^/]*=.*$||"', { encoding: 'utf8', input: cert });
if (!result) return new Error(util.format('could not get CN'));
var commonName = result.trim();
debug('validateCertificate: detected commonName as %s', commonName);
// https://github.com/drwetter/testssl.sh/pull/383
var cmd = `openssl x509 -noout -text | grep -A3 "Subject Alternative Name" | \
grep "DNS:" | \
sed -e "s/DNS://g" -e "s/ //g" -e "s/,/ /g" -e "s/othername:<unsupported>//g"`;
result = safe.child_process.execSync(cmd, { encoding: 'utf8', input: cert });
var altNames = result ? [ ] : result.trim().split(' '); // might fail if cert has no SAN
debug('validateCertificate: detected altNames as %j', altNames);
// check altNames
var domains = altNames.concat(commonName);
if (!domains.some(matchesDomain)) return new Error(util.format('cert is not valid for this domain. Expecting %s in %j', fqdn, domains));
// http://httpd.apache.org/docs/2.0/ssl/ssl_faq.html#verify
@@ -250,6 +298,10 @@ function validateCertificate(cert, key, fqdn) {
var keyModulus = safe.child_process.execSync('openssl rsa -noout -modulus', { encoding: 'utf8', input: key });
if (certModulus !== keyModulus) return new Error('key does not match the cert');
// check expiration
result = safe.child_process.execSync('openssl x509 -checkend 0', { encoding: 'utf8', input: cert });
if (!result) return new Error('cert expired');
return null;
}
@@ -269,6 +321,8 @@ function setFallbackCertificate(cert, key, callback) {
if (!safe.fs.writeFileSync(path.join(paths.NGINX_CERT_DIR, 'host.cert'), cert)) return callback(new CertificatesError(CertificatesError.INTERNAL_ERROR, safe.error.message));
if (!safe.fs.writeFileSync(path.join(paths.NGINX_CERT_DIR, 'host.key'), key)) return callback(new CertificatesError(CertificatesError.INTERNAL_ERROR, safe.error.message));
exports.events.emit(exports.EVENT_CERT_CHANGED, '*.' + config.fqdn());
nginx.reload(function (error) {
if (error) return callback(new CertificatesError(CertificatesError.INTERNAL_ERROR, error));
@@ -283,15 +337,14 @@ function getFallbackCertificatePath(callback) {
callback(null, path.join(paths.NGINX_CERT_DIR, 'host.cert'), path.join(paths.NGINX_CERT_DIR, 'host.key'));
}
// FIXME: setting admin cert needs to restart the mail container because it uses admin cert
function setAdminCertificate(cert, key, callback) {
assert.strictEqual(typeof cert, 'string');
assert.strictEqual(typeof key, 'string');
assert.strictEqual(typeof callback, 'function');
var vhost = config.adminFqdn();
var certFilePath = path.join(paths.APP_CERTS_DIR, vhost + '.cert');
var keyFilePath = path.join(paths.APP_CERTS_DIR, vhost + '.key');
var certFilePath = path.join(paths.APP_CERTS_DIR, vhost + '.user.cert');
var keyFilePath = path.join(paths.APP_CERTS_DIR, vhost + '.user.key');
var error = validateCertificate(cert, key, vhost);
if (error) return callback(new CertificatesError(CertificatesError.INVALID_CERT, error.message));
@@ -300,21 +353,44 @@ function setAdminCertificate(cert, key, callback) {
if (!safe.fs.writeFileSync(certFilePath, cert)) return callback(new CertificatesError(CertificatesError.INTERNAL_ERROR, safe.error.message));
if (!safe.fs.writeFileSync(keyFilePath, key)) return callback(new CertificatesError(CertificatesError.INTERNAL_ERROR, safe.error.message));
nginx.configureAdmin(certFilePath, keyFilePath, callback);
exports.events.emit(exports.EVENT_CERT_CHANGED, vhost);
nginx.configureAdmin(certFilePath, keyFilePath, constants.NGINX_ADMIN_CONFIG_FILE_NAME, config.adminFqdn(), callback);
}
function getAdminCertificatePath(callback) {
assert.strictEqual(typeof callback, 'function');
var vhost = config.adminFqdn();
var certFilePath = path.join(paths.APP_CERTS_DIR, vhost + '.cert');
var keyFilePath = path.join(paths.APP_CERTS_DIR, vhost + '.key');
var certFilePath = path.join(paths.APP_CERTS_DIR, vhost + '.user.cert');
var keyFilePath = path.join(paths.APP_CERTS_DIR, vhost + '.user.key');
if (fs.existsSync(certFilePath) && fs.existsSync(keyFilePath)) return callback(null, certFilePath, keyFilePath);
certFilePath = path.join(paths.APP_CERTS_DIR, vhost + '.cert');
keyFilePath = path.join(paths.APP_CERTS_DIR, vhost + '.key');
if (fs.existsSync(certFilePath) && fs.existsSync(keyFilePath)) return callback(null, certFilePath, keyFilePath);
getFallbackCertificatePath(callback);
}
function getAdminCertificate(callback) {
assert.strictEqual(typeof callback, 'function');
getAdminCertificatePath(function (error, certFilePath, keyFilePath) {
if (error) return callback(error);
var cert = safe.fs.readFileSync(certFilePath);
if (!cert) return callback(new CertificatesError(CertificatesError.INTERNAL_ERROR, safe.error));
var key = safe.fs.readFileSync(keyFilePath);
if (!cert) return callback(new CertificatesError(CertificatesError.INTERNAL_ERROR, safe.error));
return callback(null, cert, key);
});
}
function ensureCertificate(app, callback) {
assert.strictEqual(typeof app, 'object');
assert.strictEqual(typeof callback, 'function');
@@ -336,10 +412,11 @@ function ensureCertificate(app, callback) {
debug('ensureCertificate: %s. certificate already exists at %s', domain, keyFilePath);
if (!isExpiringSync(certFilePath, 24 * 1)) return callback(null, certFilePath, keyFilePath);
debug('ensureCertificate: %s cert require renewal', domain);
} else {
debug('ensureCertificate: %s cert does not exist', domain);
}
debug('ensureCertificate: %s cert require renewal', domain);
getApi(app, function (error, api, apiOptions) {
if (error) return callback(error);
+21
View File
@@ -10,6 +10,8 @@ exports = module.exports = {
getByAppId: getByAppId,
getByAppIdAndType: getByAppIdAndType,
upsert: upsert,
delByAppId: delByAppId,
delByAppIdAndType: delByAppIdAndType,
@@ -112,6 +114,25 @@ function add(id, appId, type, clientSecret, redirectURI, scope, callback) {
});
}
function upsert(id, appId, type, clientSecret, redirectURI, scope, callback) {
assert.strictEqual(typeof id, 'string');
assert.strictEqual(typeof appId, 'string');
assert.strictEqual(typeof type, 'string');
assert.strictEqual(typeof clientSecret, 'string');
assert.strictEqual(typeof redirectURI, 'string');
assert.strictEqual(typeof scope, 'string');
assert.strictEqual(typeof callback, 'function');
var data = [ id, appId, type, clientSecret, redirectURI, scope ];
database.query('REPLACE INTO clients (id, appId, type, clientSecret, redirectURI, scope) VALUES (?, ?, ?, ?, ?, ?)', data, function (error, result) {
if (error && error.code === 'ER_DUP_ENTRY') return callback(new DatabaseError(DatabaseError.ALREADY_EXISTS));
if (error || result.affectedRows === 0) return callback(new DatabaseError(DatabaseError.INTERNAL_ERROR, error));
callback(null);
});
}
function del(id, callback) {
assert.strictEqual(typeof id, 'string');
assert.strictEqual(typeof callback, 'function');
+27 -8
View File
@@ -14,6 +14,8 @@ exports = module.exports = {
addClientTokenByUserId: addClientTokenByUserId,
delToken: delToken,
addDefaultClients: addDefaultClients,
// keep this in sync with start.sh ADMIN_SCOPES that generates the cid-webadmin
SCOPE_APPS: 'apps',
SCOPE_DEVELOPER: 'developer',
@@ -30,18 +32,19 @@ exports = module.exports = {
TYPE_EXTERNAL: 'external',
TYPE_BUILT_IN: 'built-in',
TYPE_OAUTH: 'addon-oauth',
TYPE_SIMPLE_AUTH: 'addon-simpleauth',
TYPE_PROXY: 'addon-proxy'
};
var assert = require('assert'),
util = require('util'),
hat = require('hat'),
appdb = require('./appdb.js'),
tokendb = require('./tokendb.js'),
var appdb = require('./appdb.js'),
assert = require('assert'),
async = require('async'),
clientdb = require('./clientdb.js'),
config = require('./config.js'),
DatabaseError = require('./databaseerror.js'),
debug = require('debug')('box:clients'),
hat = require('hat'),
tokendb = require('./tokendb.js'),
util = require('util'),
uuid = require('node-uuid');
function ClientsError(reason, errorOrMessage) {
@@ -188,7 +191,6 @@ function getAll(callback) {
if (record.type === exports.TYPE_PROXY) record.name = result.manifest.title + ' Website Proxy';
if (record.type === exports.TYPE_OAUTH) record.name = result.manifest.title + ' OAuth';
if (record.type === exports.TYPE_SIMPLE_AUTH) record.name = result.manifest.title + ' Simple Auth';
record.location = result.location;
@@ -304,7 +306,7 @@ function delToken(clientId, tokenId, callback) {
assert.strictEqual(typeof tokenId, 'string');
assert.strictEqual(typeof callback, 'function');
get(clientId, function (error, result) {
get(clientId, function (error) {
if (error) return callback(error);
tokendb.del(tokenId, function (error) {
@@ -315,3 +317,20 @@ function delToken(clientId, tokenId, callback) {
});
});
}
function addDefaultClients(callback) {
assert.strictEqual(typeof callback, 'function');
debug('Adding default clients');
// The domain might have changed, therefor we have to update the record
// !!! This needs to be in sync with the webadmin, specifically login_callback.js
const ADMIN_SCOPES="cloudron,developer,profile,users,apps,settings";
// id, appId, type, clientSecret, redirectURI, scope
async.series([
clientdb.upsert.bind(null, 'cid-webadmin', 'Settings', 'built-in', 'secret-webadmin', config.adminOrigin(), ADMIN_SCOPES),
clientdb.upsert.bind(null, 'cid-sdk', 'SDK', 'built-in', 'secret-sdk', config.adminOrigin(), '*,roleSdk'),
clientdb.upsert.bind(null, 'cid-cli', 'Cloudron Tool', 'built-in', 'secret-cli', config.adminOrigin(), '*, roleSdk')
], callback);
}
+289 -93
View File
@@ -8,6 +8,7 @@ exports = module.exports = {
activate: activate,
getConfig: getConfig,
getStatus: getStatus,
dnsSetup: dnsSetup,
sendHeartbeat: sendHeartbeat,
sendAliveStatus: sendAliveStatus,
@@ -17,34 +18,39 @@ exports = module.exports = {
retire: retire,
migrate: migrate,
isConfiguredSync: isConfiguredSync,
getConfigStateSync: getConfigStateSync,
checkDiskSpace: checkDiskSpace,
readDkimPublicKeySync: readDkimPublicKeySync,
refreshDNS: refreshDNS,
events: new (require('events').EventEmitter)(),
events: null,
EVENT_CONFIGURED: 'configured'
EVENT_ACTIVATED: 'activated'
};
var apps = require('./apps.js'),
assert = require('assert'),
async = require('async'),
backups = require('./backups.js'),
certificates = require('./certificates.js'),
child_process = require('child_process'),
clients = require('./clients.js'),
config = require('./config.js'),
constants = require('./constants.js'),
cron = require('./cron.js'),
debug = require('debug')('box:cloudron'),
df = require('node-df'),
eventlog = require('./eventlog.js'),
fs = require('fs'),
locker = require('./locker.js'),
mailer = require('./mailer.js'),
nginx = require('./nginx.js'),
os = require('os'),
path = require('path'),
paths = require('./paths.js'),
platform = require('./platform.js'),
progress = require('./progress.js'),
safe = require('safetydance'),
settings = require('./settings.js'),
@@ -53,6 +59,7 @@ var apps = require('./apps.js'),
subdomains = require('./subdomains.js'),
superagent = require('superagent'),
sysinfo = require('./sysinfo.js'),
taskmanager = require('./taskmanager.js'),
tokendb = require('./tokendb.js'),
updateChecker = require('./updatechecker.js'),
user = require('./user.js'),
@@ -82,7 +89,7 @@ const BOX_AND_USER_TEMPLATE = {
var gUpdatingDns = false, // flag for dns update reentrancy
gBoxAndUserDetails = null, // cached cloudron details like region,size...
gIsConfigured = null; // cached configured state so that return value is synchronous. null means we are not initialized yet
gConfigState = { dns: false, tls: false, configured: false };
function CloudronError(reason, errorOrMessage) {
assert.strictEqual(typeof reason, 'string');
@@ -107,6 +114,7 @@ CloudronError.BAD_FIELD = 'Field error';
CloudronError.INTERNAL_ERROR = 'Internal Error';
CloudronError.EXTERNAL_ERROR = 'External Error';
CloudronError.ALREADY_PROVISIONED = 'Already Provisioned';
CloudronError.ALREADY_SETUP = 'Already Setup';
CloudronError.BAD_STATE = 'Bad state';
CloudronError.ALREADY_UPTODATE = 'No Update Available';
CloudronError.NOT_FOUND = 'Not found';
@@ -115,67 +123,167 @@ CloudronError.SELF_UPGRADE_NOT_SUPPORTED = 'Self upgrade not supported';
function initialize(callback) {
assert.strictEqual(typeof callback, 'function');
ensureDkimKeySync();
exports.events = new (require('events').EventEmitter)();
exports.events.on(exports.EVENT_CONFIGURED, addDnsRecords);
gConfigState = { dns: false, tls: false, configured: false };
gUpdatingDns = false;
gBoxAndUserDetails = null;
if (!fs.existsSync(paths.FIRST_RUN_FILE)) {
debug('initialize: installing app bundle on first run');
process.nextTick(installAppBundle);
fs.writeFileSync(paths.FIRST_RUN_FILE, 'been there, done that', 'utf8');
}
syncConfigState(callback);
async.series([
certificates.initialize,
settings.initialize,
platform.initialize,
installAppBundle,
checkConfigState,
configureDefaultServer
], callback);
}
function uninitialize(callback) {
assert.strictEqual(typeof callback, 'function');
exports.events.removeListener(exports.EVENT_CONFIGURED, addDnsRecords);
exports.events.removeListener(exports.EVENT_FIRST_RUN, installAppBundle);
exports.events = null;
callback(null);
platform.events.removeListener(platform.EVENT_READY, onPlatformReady);
async.series([
cron.uninitialize,
taskmanager.pauseTasks,
mailer.stop,
platform.uninitialize,
certificates.uninitialize,
settings.uninitialize
], callback);
}
function isConfiguredSync() {
return gIsConfigured === true;
function onConfigured(callback) {
callback = callback || NOOP_CALLBACK;
// if we hit here, the domain has to be set, this is a logic issue if it isn't
assert(config.fqdn());
debug('onConfigured: current state: %j', gConfigState);
if (gConfigState.configured) return callback(); // re-entracy flag
gConfigState.configured = true;
platform.events.on(platform.EVENT_READY, onPlatformReady);
settings.events.on(settings.DNS_CONFIG_KEY, function () { refreshDNS(); });
async.series([
clients.addDefaultClients,
certificates.ensureFallbackCertificate,
platform.start, // requires fallback certs for mail container
ensureDkimKey,
addDnsRecords,
configureAdmin,
mailer.start,
cron.initialize // do not send heartbeats until we are "ready"
], callback);
}
function isConfigured(callback) {
// set of rules to see if we have the configs required for cloudron to function
// note this checks for missing configs and not invalid configs
function onPlatformReady(callback) {
callback = callback || NOOP_CALLBACK;
settings.getDnsConfig(function (error, dnsConfig) {
if (error) return callback(error);
debug('onPlatformReady');
if (!dnsConfig) return callback(null, false);
async.series([
taskmanager.resumeTasks
], callback);
}
var isConfigured = (config.isCustomDomain() && (dnsConfig.provider === 'route53' || dnsConfig.provider === 'digitalocean' || dnsConfig.provider === 'noop' || dnsConfig.provider === 'manual')) ||
(!config.isCustomDomain() && dnsConfig.provider === 'caas');
function getConfigStateSync() {
return gConfigState;
}
callback(null, isConfigured);
function checkConfigState(callback) {
callback = callback || NOOP_CALLBACK;
if (!config.fqdn()) {
settings.events.once(settings.DNS_CONFIG_KEY, function () { checkConfigState(); }); // check again later
return callback(null);
}
debug('checkConfigState: configured');
onConfigured(callback);
}
function dnsSetup(dnsConfig, domain, callback) {
assert.strictEqual(typeof dnsConfig, 'object');
assert.strictEqual(typeof domain, 'string');
assert.strictEqual(typeof callback, 'function');
if (config.fqdn()) return callback(new CloudronError(CloudronError.ALREADY_SETUP));
settings.setDnsConfig(dnsConfig, domain, function (error) {
if (error && error.reason === SettingsError.BAD_FIELD) return callback(new CloudronError(CloudronError.BAD_FIELD, error.message));
if (error) return callback(new CloudronError(CloudronError.INTERNAL_ERROR, error));
config.set('fqdn', domain); // set fqdn only after dns config is valid, otherwise cannot re-setup if we failed
onConfigured(); // do not block
callback();
});
}
function syncConfigState(callback) {
assert(!gIsConfigured);
function configureDefaultServer(callback) {
callback = callback || NOOP_CALLBACK;
isConfigured(function (error, configured) {
debug('configureDefaultServer: domain %s', config.fqdn());
if (process.env.BOX_ENV === 'test') return callback();
var certFilePath = path.join(paths.NGINX_CERT_DIR, 'default.cert');
var keyFilePath = path.join(paths.NGINX_CERT_DIR, 'default.key');
if (!fs.existsSync(certFilePath) || !fs.existsSync(keyFilePath)) {
debug('configureDefaultServer: create new cert');
var cn = 'cloudron-' + (new Date()).toISOString(); // randomize date a bit to keep firefox happy
var certCommand = util.format('openssl req -x509 -newkey rsa:2048 -keyout %s -out %s -days 3650 -subj /CN=%s -nodes', keyFilePath, certFilePath, cn);
safe.child_process.execSync(certCommand);
}
safe.fs.unlinkSync(path.join(paths.NGINX_APPCONFIG_DIR,'ip_based_setup.conf'));
nginx.configureAdmin(certFilePath, keyFilePath, 'default.conf', '', function (error) {
if (error) return callback(error);
debug('syncConfigState: configured = %s', configured);
debug('configureDefaultServer: done');
if (configured) {
exports.events.emit(exports.EVENT_CONFIGURED);
} else {
settings.events.once(settings.DNS_CONFIG_KEY, function () { syncConfigState(); }); // check again later
}
callback(null);
});
}
gIsConfigured = configured;
function configureAdmin(callback) {
callback = callback || NOOP_CALLBACK;
callback();
if (process.env.BOX_ENV === 'test') return callback();
debug('configureAdmin');
sysinfo.getPublicIp(function (error, ip) {
if (error) return callback(error);
subdomains.waitForDns(config.adminFqdn(), ip, 'A', { interval: 30000, times: 50000 }, function (error) {
if (error) return callback(error);
gConfigState.dns = true;
certificates.ensureCertificate({ location: constants.ADMIN_LOCATION }, function (error, certFilePath, keyFilePath) {
if (error) { // currently, this can never happen
debug('Error obtaining certificate. Proceed anyway', error);
return callback();
}
gConfigState.tls = true;
nginx.configureAdmin(certFilePath, keyFilePath, constants.NGINX_ADMIN_CONFIG_FILE_NAME, config.adminFqdn(), callback);
});
});
});
}
@@ -238,6 +346,8 @@ function activate(username, password, email, displayName, ip, auditSource, callb
eventlog.add(eventlog.ACTION_ACTIVATE, auditSource, { });
exports.events.emit(exports.EVENT_ACTIVATED);
callback(null, { token: token, expires: expires });
});
});
@@ -259,7 +369,9 @@ function getStatus(callback) {
boxVersionsUrl: config.get('boxVersionsUrl'),
apiServerOrigin: config.apiServerOrigin(), // used by CaaS tool
provider: config.provider(),
cloudronName: cloudronName
cloudronName: cloudronName,
adminFqdn: config.fqdn() ? config.adminFqdn() : null,
configState: gConfigState
});
});
});
@@ -327,7 +439,7 @@ function getConfig(callback) {
}
function sendHeartbeat() {
if (!config.token()) return;
if (config.provider() !== 'caas') return;
var url = config.apiServerOrigin() + '/api/v1/boxes/' + config.fqdn() + '/heartbeat';
superagent.post(url).query({ token: config.token(), version: config.version() }).timeout(30 * 1000).end(function (error, result) {
@@ -340,12 +452,13 @@ function sendHeartbeat() {
function sendAliveStatus(callback) {
if (typeof callback !== 'function') {
callback = function (error) {
if (error && error.reason !== CloudronError.INTERNAL_ERROR) console.error(error);
if (error && error.reason !== CloudronError.INTERNAL_ERROR) debug(error);
else if (error) debug(error);
};
}
function sendAliveStatusWithAppstoreConfig(appstoreConfig) {
function sendAliveStatusWithAppstoreConfig(backendSettings, appstoreConfig) {
assert.strictEqual(typeof backendSettings, 'object');
assert.strictEqual(typeof appstoreConfig.userId, 'string');
assert.strictEqual(typeof appstoreConfig.cloudronId, 'string');
assert.strictEqual(typeof appstoreConfig.token, 'string');
@@ -354,7 +467,12 @@ function sendAliveStatus(callback) {
var data = {
domain: config.fqdn(),
version: config.version(),
provider: config.provider()
provider: config.provider(),
backendSettings: backendSettings,
machine: {
cpus: os.cpus(),
totalmem: os.totalmem()
}
};
superagent.post(url).send(data).query({ accessToken: appstoreConfig.token }).timeout(30 * 1000).end(function (error, result) {
@@ -366,44 +484,82 @@ function sendAliveStatus(callback) {
});
}
// Caas Cloudrons do not store appstore credentials in their local database
if (config.provider() === 'caas') {
if (!config.token()) return callback(new CloudronError(CloudronError.INTERNAL_ERROR, 'no token set'));
settings.getAll(function (error, result) {
if (error) return callback(new CloudronError(CloudronError.INTERNAL_ERROR, error));
var url = config.apiServerOrigin() + '/api/v1/exchangeBoxTokenWithUserToken';
superagent.post(url).query({ token: config.token() }).timeout(30 * 1000).end(function (error, result) {
if (error && !error.response) return callback(new CloudronError(CloudronError.EXTERNAL_ERROR, error));
if (result.statusCode !== 201) return callback(new CloudronError(CloudronError.EXTERNAL_ERROR, util.format('App purchase failed. %s %j', result.status, result.body)));
var backendSettings = {
dnsConfig: {
provider: result[settings.DNS_CONFIG_KEY].provider,
wildcard: result[settings.DNS_CONFIG_KEY].provider === 'manual' ? result[settings.DNS_CONFIG_KEY].wildcard : undefined
},
tlsConfig: {
provider: result[settings.TLS_CONFIG_KEY].provider
},
backupConfig: {
provider: result[settings.BACKUP_CONFIG_KEY].provider
},
mailConfig: {
enabled: result[settings.MAIL_CONFIG_KEY].enabled
},
autoupdatePattern: result[settings.AUTOUPDATE_PATTERN_KEY],
timeZone: result[settings.TIME_ZONE_KEY]
};
sendAliveStatusWithAppstoreConfig(result.body);
});
} else {
settings.getAppstoreConfig(function (error, result) {
if (error) return callback(new CloudronError(CloudronError.INTERNAL_ERROR, error));
if (!result.token) return callback(new CloudronError(CloudronError.INTERNAL_ERROR, 'not registered yet'));
// Caas Cloudrons do not store appstore credentials in their local database
if (config.provider() === 'caas') {
var url = config.apiServerOrigin() + '/api/v1/exchangeBoxTokenWithUserToken';
superagent.post(url).query({ token: config.token() }).timeout(30 * 1000).end(function (error, result) {
if (error && !error.response) return callback(new CloudronError(CloudronError.EXTERNAL_ERROR, error));
if (result.statusCode !== 201) return callback(new CloudronError(CloudronError.EXTERNAL_ERROR, util.format('App purchase failed. %s %j', result.status, result.body)));
sendAliveStatusWithAppstoreConfig(result);
});
}
sendAliveStatusWithAppstoreConfig(backendSettings, result.body);
});
} else {
settings.getAppstoreConfig(function (error, result) {
if (error) return callback(new CloudronError(CloudronError.INTERNAL_ERROR, error));
if (!result.token) {
debug('sendAliveStatus: Cloudron not yet registered');
return callback(null);
}
sendAliveStatusWithAppstoreConfig(backendSettings, result);
});
}
});
}
function ensureDkimKeySync() {
var dkimPrivateKeyFile = path.join(paths.MAIL_DATA_DIR, 'dkim/' + config.fqdn() + '/private');
var dkimPublicKeyFile = path.join(paths.MAIL_DATA_DIR, 'dkim/' + config.fqdn() + '/public');
function ensureDkimKey(callback) {
var dkimPath = path.join(paths.MAIL_DATA_DIR, 'dkim/' + config.fqdn());
var dkimPrivateKeyFile = path.join(dkimPath, 'private');
var dkimPublicKeyFile = path.join(dkimPath, 'public');
if (fs.existsSync(dkimPrivateKeyFile) && fs.existsSync(dkimPublicKeyFile)) {
if (!fs.existsSync(dkimPrivateKeyFile) || !fs.existsSync(dkimPublicKeyFile)) {
debug('Generating new DKIM keys');
if (!safe.fs.mkdirSync(dkimPath) && safe.error.code !== 'EEXIST') {
debug('Error creating dkim.', safe.error);
return null;
}
child_process.execSync('openssl genrsa -out ' + dkimPrivateKeyFile + ' 1024');
child_process.execSync('openssl rsa -in ' + dkimPrivateKeyFile + ' -out ' + dkimPublicKeyFile + ' -pubout -outform PEM');
} else {
debug('DKIM keys already present');
return;
}
debug('Generating new DKIM keys');
child_process.execSync('openssl genrsa -out ' + dkimPrivateKeyFile + ' 1024');
child_process.execSync('openssl rsa -in ' + dkimPrivateKeyFile + ' -out ' + dkimPublicKeyFile + ' -pubout -outform PEM');
callback();
}
function readDkimPublicKeySync() {
var dkimPublicKeyFile = path.join(paths.MAIL_DATA_DIR, 'dkim/' + config.fqdn() + '/public');
if (!config.fqdn()) {
debug('Cannot read dkim public key without a domain.', safe.error);
return null;
}
var dkimPath = path.join(paths.MAIL_DATA_DIR, 'dkim/' + config.fqdn());
var dkimPublicKeyFile = path.join(dkimPath, 'public');
var publicKey = safe.fs.readFileSync(dkimPublicKeyFile, 'utf8');
if (publicKey === null) {
@@ -418,6 +574,7 @@ function readDkimPublicKeySync() {
}
// NOTE: if you change the SPF record here, be sure the wait check in mailer.js
// https://agari.zendesk.com/hc/en-us/articles/202952749-How-long-can-my-SPF-record-be-
function txtRecordsWithSpf(callback) {
assert.strictEqual(typeof callback, 'function');
@@ -426,29 +583,33 @@ function txtRecordsWithSpf(callback) {
debug('txtRecordsWithSpf: current txt records - %j', txtRecords);
var i, validSpf;
var i, matches, validSpf;
for (i = 0; i < txtRecords.length; i++) {
if (txtRecords[i].indexOf('"v=spf1 ') !== 0) continue; // not SPF
matches = txtRecords[i].match(/^("?v=spf1) /); // DO backend may return without quotes
if (matches === null) continue;
validSpf = txtRecords[i].indexOf(' a:' + config.adminFqdn() + ' ') !== -1;
break;
// this won't work if the entry is arbitrarily "split" across quoted strings
validSpf = txtRecords[i].indexOf('a:' + config.adminFqdn()) !== -1;
break; // there can only be one SPF record
}
if (validSpf) return callback(null, null);
if (i == txtRecords.length) {
txtRecords[i] = '"v=spf1 a:' + config.adminFqdn() + ' ~all"';
} else {
txtRecords[i] = '"v=spf1 a:' + config.adminFqdn() + ' ' + txtRecords[i].slice('"v=spf1 '.length);
if (!matches) { // no spf record was found, create one
txtRecords.push('"v=spf1 a:' + config.adminFqdn() + ' ~all"');
debug('txtRecordsWithSpf: adding txt record');
} else { // just add ourself
txtRecords[i] = matches[1] + ' a:' + config.adminFqdn() + txtRecords[i].slice(matches[1].length);
debug('txtRecordsWithSpf: inserting txt record');
}
return callback(null, txtRecords);
});
}
function addDnsRecords() {
var callback = NOOP_CALLBACK;
function addDnsRecords(callback) {
callback = callback || NOOP_CALLBACK;
if (process.env.BOX_ENV === 'test') return callback();
@@ -461,7 +622,7 @@ function addDnsRecords() {
var dkimKey = readDkimPublicKeySync();
if (!dkimKey) return callback(new CloudronError(CloudronError.INTERNAL_ERROR, new Error('Failed to read dkim public key')));
sysinfo.getIp(function (error, ip) {
sysinfo.getPublicIp(function (error, ip) {
if (error) return callback(new CloudronError(CloudronError.INTERNAL_ERROR, error));
var webadminRecord = { subdomain: constants.ADMIN_LOCATION, type: 'A', values: [ ip ] };
@@ -473,7 +634,7 @@ function addDnsRecords() {
records.push(webadminRecord);
records.push(dkimRecord);
} else {
// for non-custom domains, we show a nakeddomain.html page
// for non-custom domains, we show a noapp.html page
var nakedDomainRecord = { subdomain: '', type: 'A', values: [ ip ] };
records.push(nakedDomainRecord);
@@ -534,7 +695,7 @@ function update(boxUpdateInfo, auditSource, callback) {
debug('Starting upgrade');
doUpgrade(boxUpdateInfo, function (error) {
if (error) {
console.error('Upgrade failed with error:', error);
debug('Upgrade failed with error:', error);
locker.unlock(locker.OP_BOX_UPDATE);
}
});
@@ -542,7 +703,7 @@ function update(boxUpdateInfo, auditSource, callback) {
debug('Starting update');
doUpdate(boxUpdateInfo, function (error) {
if (error) {
console.error('Update failed with error:', error);
debug('Update failed with error:', error);
locker.unlock(locker.OP_BOX_UPDATE);
}
});
@@ -633,8 +794,8 @@ function doUpdate(boxUpdateInfo, callback) {
apiServerOrigin: config.apiServerOrigin(),
webServerOrigin: config.webServerOrigin(),
fqdn: config.fqdn(),
tlsCert: fs.readFileSync(path.join(paths.NGINX_CERT_DIR, 'host.cert'), 'utf8'),
tlsKey: fs.readFileSync(path.join(paths.NGINX_CERT_DIR, 'host.key'), 'utf8'),
tlsCert: config.tlsCert(),
tlsKey: config.tlsKey(),
isCustomDomain: config.isCustomDomain(),
isDemo: config.isDemo(),
@@ -654,6 +815,8 @@ function doUpdate(boxUpdateInfo, callback) {
debug('updating box %s %j', boxUpdateInfo.sourceTarballUrl, data);
progress.set(progress.UPDATE, 5, 'Downloading and extracting new version');
shell.sudo('update', [ UPDATE_CMD, boxUpdateInfo.sourceTarballUrl, JSON.stringify(data) ], function (error) {
if (error) return updateError(error);
@@ -663,14 +826,14 @@ function doUpdate(boxUpdateInfo, callback) {
}
function installAppBundle(callback) {
callback = callback || NOOP_CALLBACK;
assert.strictEqual(typeof callback, 'function');
if (fs.existsSync(paths.FIRST_RUN_FILE)) return callback();
var bundle = config.get('appBundle');
debug('initialize: installing app bundle on first run: %j', bundle);
if (!bundle || bundle.length === 0) {
debug('installAppBundle: no bundle set');
return callback();
}
if (!bundle || bundle.length === 0) return callback();
async.eachSeries(bundle, function (appInfo, iteratorCallback) {
debug('autoInstall: installing %s at %s', appInfo.appstoreId, appInfo.location);
@@ -686,6 +849,8 @@ function installAppBundle(callback) {
}, function (error) {
if (error) debug('autoInstallApps: ', error);
fs.writeFileSync(paths.FIRST_RUN_FILE, 'been there, done that', 'utf8');
callback();
});
}
@@ -779,12 +944,43 @@ function migrate(options, callback) {
if (!options.domain) return doMigrate(options, callback);
var dnsConfig = _.pick(options, 'domain', 'provider', 'accessKeyId', 'secretAccessKey', 'region', 'endpoint');
var dnsConfig = _.pick(options, 'domain', 'provider', 'accessKeyId', 'secretAccessKey', 'region', 'endpoint', 'token');
settings.setDnsConfig(dnsConfig, function (error) {
settings.setDnsConfig(dnsConfig, options.domain, function (error) {
if (error && error.reason === SettingsError.BAD_FIELD) return callback(new CloudronError(CloudronError.BAD_FIELD, error.message));
if (error) return callback(new CloudronError(CloudronError.INTERNAL_ERROR, error));
// TODO: should probably rollback dns config if migrate fails
doMigrate(options, callback);
});
}
function refreshDNS(callback) {
callback = callback || NOOP_CALLBACK;
sysinfo.getPublicIp(function (error, ip) {
if (error) return callback(new CloudronError(CloudronError.INTERNAL_ERROR, error));
debug('refreshDNS: current ip %s', ip);
addDnsRecords(function (error) {
if (error) return callback(error);
debug('refreshDNS: done for system records');
apps.getAll(function (error, result) {
if (error) return callback(error);
async.each(result, function (app, callback) {
subdomains.upsert(app.location, 'A', [ ip ], callback);
}, function (error) {
if (error) return callback(error);
debug('refreshDNS: done for apps');
callback();
});
});
});
});
}
+15 -6
View File
@@ -35,6 +35,9 @@ exports = module.exports = {
isDev: isDev,
isDemo: isDemo,
tlsCert: tlsCert,
tlsKey: tlsKey,
// for testing resets to defaults
_reset: _reset
};
@@ -61,7 +64,7 @@ function saveSync() {
fs.writeFileSync(cloudronConfigFileName, JSON.stringify(data, null, 4)); // functions are ignored by JSON.stringify
}
function _reset (callback) {
function _reset(callback) {
safe.fs.unlinkSync(cloudronConfigFileName);
initConfig();
@@ -76,12 +79,11 @@ function initConfig() {
data.token = null;
data.boxVersionsUrl = null;
data.version = null;
data.isCustomDomain = false;
data.isCustomDomain = true;
data.webServerOrigin = null;
data.smtpPort = 2525; // // this value comes from mail container
data.sysadminPort = 3001;
data.ldapPort = 3002;
data.simpleAuthPort = 3004;
data.provider = 'caas';
data.appBundle = [ ];
@@ -113,9 +115,6 @@ function initConfig() {
saveSync();
}
// cleanup any old config file we have for tests
if (exports.TEST) safe.fs.unlinkSync(cloudronConfigFileName);
initConfig();
// set(obj) or set(key, value)
@@ -216,3 +215,13 @@ function isDemo() {
function provider() {
return get('provider');
}
function tlsCert() {
var certFile = path.join(baseDir(), 'configs/host.cert');
return safe.fs.readFileSync(certFile, 'utf8');
}
function tlsKey() {
var keyFile = path.join(baseDir(), 'configs/host.key');
return safe.fs.readFileSync(keyFile, 'utf8');
}
+5 -1
View File
@@ -26,6 +26,8 @@ exports = module.exports = {
ADMIN_GROUP_ID: 'admin',
NGINX_ADMIN_CONFIG_FILE_NAME: 'admin.conf',
GHOST_USER_FILE: '/tmp/cloudron_ghost.json',
DEFAULT_TOKEN_EXPIRATION: 7 * 24 * 60 * 60 * 1000, // 1 week
@@ -34,6 +36,8 @@ exports = module.exports = {
DEMO_USERNAME: 'cloudron',
DKIM_SELECTOR: 'cloudron'
DKIM_SELECTOR: 'cloudron',
AUTOUPDATE_PATTERN_NEVER: 'never'
};
+38 -6
View File
@@ -11,6 +11,7 @@ var apps = require('./apps.js'),
certificates = require('./certificates.js'),
cloudron = require('./cloudron.js'),
config = require('./config.js'),
constants = require('./constants.js'),
CronJob = require('cron').CronJob,
debug = require('debug')('box:cron'),
eventlog = require('./eventlog.js'),
@@ -22,8 +23,8 @@ var apps = require('./apps.js'),
var gAutoupdaterJob = null,
gBoxUpdateCheckerJob = null,
gAppUpdateCheckerJob = null,
gHeartbeatJob = null,
gAliveJob = null,
gHeartbeatJob = null, // for CaaS health check
gAliveJob = null, // send periodic stats
gBackupJob = null,
gCleanupTokensJob = null,
gCleanupBackupsJob = null,
@@ -31,7 +32,8 @@ var gAutoupdaterJob = null,
gSchedulerSyncJob = null,
gCertificateRenewJob = null,
gCheckDiskSpaceJob = null,
gCleanupEventlogJob = null;
gCleanupEventlogJob = null,
gDynamicDNSJob = null;
var NOOP_CALLBACK = function (error) { if (error) console.error(error); };
var AUDIT_SOURCE = { userId: null, username: 'cron' };
@@ -50,9 +52,15 @@ function initialize(callback) {
gHeartbeatJob = new CronJob({
cronTime: '00 */1 * * * *', // every minute
onTick: cloudron.sendHeartbeat,
start: true
start: false
});
cloudron.sendHeartbeat(); // latest unpublished version of CronJob has runOnInit
// hack: send the first heartbeat only after we are running for 60 seconds
// required as we end up sending a heartbeat and then cloudron-setup reboots the server
setTimeout(function () {
if (!gHeartbeatJob) return; // already uninitalized
gHeartbeatJob.start();
cloudron.sendHeartbeat();
}, 1000 * 60);
var randomHourMinute = Math.floor(60*Math.random());
gAliveJob = new CronJob({
@@ -63,12 +71,14 @@ function initialize(callback) {
settings.events.on(settings.TIME_ZONE_KEY, recreateJobs);
settings.events.on(settings.AUTOUPDATE_PATTERN_KEY, autoupdatePatternChanged);
settings.events.on(settings.DYNAMIC_DNS_KEY, dynamicDNSChanged);
settings.getAll(function (error, allSettings) {
if (error) return callback(error);
recreateJobs(allSettings[settings.TIME_ZONE_KEY]);
autoupdatePatternChanged(allSettings[settings.AUTOUPDATE_PATTERN_KEY]);
dynamicDNSChanged(allSettings[settings.DYNAMIC_DNS_KEY]);
callback();
});
@@ -172,7 +182,7 @@ function autoupdatePatternChanged(pattern) {
if (gAutoupdaterJob) gAutoupdaterJob.stop();
if (pattern === 'never') return;
if (pattern === constants.AUTOUPDATE_PATTERN_NEVER) return;
gAutoupdaterJob = new CronJob({
cronTime: pattern,
@@ -193,6 +203,25 @@ function autoupdatePatternChanged(pattern) {
});
}
function dynamicDNSChanged(enabled) {
assert.strictEqual(typeof enabled, 'boolean');
assert(gBoxUpdateCheckerJob);
debug('Dynamic DNS setting changed to %s', enabled);
if (enabled) {
gDynamicDNSJob = new CronJob({
cronTime: '00 */10 * * * *',
onTick: cloudron.refreshDNS,
start: true,
timeZone: gBoxUpdateCheckerJob.cronTime.zone // hack
});
} else {
if (gDynamicDNSJob) gDynamicDNSJob.stop();
gDynamicDNSJob = null;
}
}
function uninitialize(callback) {
assert.strictEqual(typeof callback, 'function');
@@ -235,5 +264,8 @@ function uninitialize(callback) {
if (gCertificateRenewJob) gCertificateRenewJob.stop();
gCertificateRenewJob = null;
if (gDynamicDNSJob) gDynamicDNSJob.stop();
gDynamicDNSJob = null;
callback();
}
+14 -1
View File
@@ -4,7 +4,8 @@ exports = module.exports = {
upsert: upsert,
get: get,
del: del,
waitForDns: require('./waitfordns.js')
waitForDns: require('./waitfordns.js'),
verifyDnsConfig: verifyDnsConfig
};
var assert = require('assert'),
@@ -111,3 +112,15 @@ function del(dnsConfig, zoneName, subdomain, type, values, callback) {
});
}
function verifyDnsConfig(dnsConfig, domain, ip, callback) {
assert.strictEqual(typeof dnsConfig, 'object');
assert.strictEqual(typeof domain, 'string');
assert.strictEqual(typeof ip, 'string');
assert.strictEqual(typeof callback, 'function');
var credentials = {
provider: dnsConfig.provider
};
return callback(null, credentials);
}
+36 -1
View File
@@ -4,12 +4,14 @@ exports = module.exports = {
upsert: upsert,
get: get,
del: del,
waitForDns: require('./waitfordns.js')
waitForDns: require('./waitfordns.js'),
verifyDnsConfig: verifyDnsConfig
};
var assert = require('assert'),
async = require('async'),
debug = require('debug')('box:dns/digitalocean'),
dns = require('native-dns'),
SubdomainError = require('../subdomains.js').SubdomainError,
superagent = require('superagent'),
util = require('util');
@@ -83,6 +85,7 @@ function upsert(dnsConfig, zoneName, subdomain, type, values, callback) {
.end(function (error, result) {
if (error && !error.response) return callback(error);
if (result.statusCode === 403 || result.statusCode === 401) return callback(new SubdomainError(SubdomainError.ACCESS_DENIED, util.format('%s %j', result.statusCode, result.body)));
if (result.statusCode === 422) return callback(new SubdomainError(SubdomainError.BAD_FIELD, result.body.message));
if (result.statusCode !== 201) return callback(new SubdomainError(SubdomainError.EXTERNAL_ERROR, util.format('%s %j', result.statusCode, result.body)));
return callback(null);
@@ -98,6 +101,7 @@ function upsert(dnsConfig, zoneName, subdomain, type, values, callback) {
if (error && !error.response) return callback(error);
if (result.statusCode === 403 || result.statusCode === 401) return callback(new SubdomainError(SubdomainError.ACCESS_DENIED, util.format('%s %j', result.statusCode, result.body)));
if (result.statusCode === 422) return callback(new SubdomainError(SubdomainError.BAD_FIELD, result.body.message));
if (result.statusCode !== 200) return callback(new SubdomainError(SubdomainError.EXTERNAL_ERROR, util.format('%s %j', result.statusCode, result.body)));
return callback(null);
@@ -171,3 +175,34 @@ function del(dnsConfig, zoneName, subdomain, type, values, callback) {
});
}
function verifyDnsConfig(dnsConfig, domain, ip, callback) {
assert.strictEqual(typeof dnsConfig, 'object');
assert.strictEqual(typeof domain, 'string');
assert.strictEqual(typeof ip, 'string');
assert.strictEqual(typeof callback, 'function');
var credentials = {
provider: dnsConfig.provider,
token: dnsConfig.token
};
if (process.env.BOX_ENV === 'test') return callback(null, credentials); // this shouldn't be here
dns.resolveNs(domain, function (error, nameservers) {
if (error && error.code === 'ENOTFOUND') return callback(new SubdomainError(SubdomainError.BAD_FIELD, 'Unable to resolve nameservers for this domain'));
if (error || !nameservers) return callback(new SubdomainError(SubdomainError.BAD_FIELD, error ? error.message : 'Unable to get nameservers'));
if (nameservers.map(function (n) { return n.toLowerCase(); }).indexOf('ns1.digitalocean.com') === -1) {
debug('verifyDnsConfig: %j does not contains DO NS', nameservers);
return callback(new SubdomainError(SubdomainError.BAD_FIELD, 'Domain nameservers are not set to Digital Ocean'));
}
upsert(credentials, domain, 'my', 'A', [ ip ], function (error, changeId) {
if (error) return callback(error);
debug('verifyDnsConfig: A record added with change id %s', changeId);
callback(null, credentials);
});
});
}
+12 -1
View File
@@ -10,7 +10,8 @@ exports = module.exports = {
upsert: upsert,
get: get,
del: del,
waitForDns: require('./waitfordns.js')
waitForDns: require('./waitfordns.js'),
verifyDnsConfig: verifyDnsConfig
};
var assert = require('assert'),
@@ -55,3 +56,13 @@ function del(dnsConfig, zoneName, subdomain, type, values, callback) {
callback(new Error('not implemented'));
}
function verifyDnsConfig(dnsConfig, domain, ip, callback) {
assert.strictEqual(typeof dnsConfig, 'object');
assert.strictEqual(typeof domain, 'string');
assert.strictEqual(typeof ip, 'string');
assert.strictEqual(typeof callback, 'function');
// Result: dnsConfig object
callback(new Error('not implemented'));
}
+70 -3
View File
@@ -4,13 +4,15 @@ exports = module.exports = {
upsert: upsert,
get: get,
del: del,
waitForDns: require('./waitfordns.js')
waitForDns: require('./waitfordns.js'),
verifyDnsConfig: verifyDnsConfig
};
var assert = require('assert'),
debug = require('debug')('box:dns/noop'),
async = require('async'),
debug = require('debug')('box:dns/manual'),
dns = require('native-dns'),
SubdomainError = require('../subdomains.js').SubdomainError,
sysinfo = require('../sysinfo.js'),
util = require('util');
function upsert(dnsConfig, zoneName, subdomain, type, values, callback) {
@@ -47,3 +49,68 @@ function del(dnsConfig, zoneName, subdomain, type, values, callback) {
return callback();
}
function verifyDnsConfig(dnsConfig, domain, ip, callback) {
assert.strictEqual(typeof dnsConfig, 'object');
assert.strictEqual(typeof domain, 'string');
assert.strictEqual(typeof ip, 'string');
assert.strictEqual(typeof callback, 'function');
var adminDomain = 'my.' + domain;
dns.resolveNs(domain, function (error, nameservers) {
if (error || !nameservers) return callback(new SubdomainError(SubdomainError.BAD_FIELD, 'Unable to get nameservers'));
async.every(nameservers, function (nameserver, everyNsCallback) {
// ns records cannot have cname
dns.resolve4(nameserver, function (error, nsIps) {
if (error || !nsIps || nsIps.length === 0) {
return everyNsCallback(new SubdomainError(SubdomainError.BAD_FIELD, 'Unable to resolve nameservers for this domain'));
}
async.every(nsIps, function (nsIp, everyIpCallback) {
var req = dns.Request({
question: dns.Question({ name: adminDomain, type: 'A' }),
server: { address: nsIp },
timeout: 5000
});
req.on('timeout', function () {
debug('nameserver %s (%s) timed out when trying to resolve %s', nameserver, nsIp, adminDomain);
return everyIpCallback(null, true); // should be ok if dns server is down
});
req.on('message', function (error, message) {
if (error) {
debug('nameserver %s (%s) returned error trying to resolve %s: %s', nameserver, nsIp, adminDomain, error);
return everyIpCallback(null, false);
}
var answer = message.answer;
if (!answer || answer.length === 0) {
debug('bad answer from nameserver %s (%s) resolving %s (%s): %j', nameserver, nsIp, adminDomain, 'A', message);
return everyIpCallback(null, false);
}
debug('verifyDnsConfig: ns: %s (%s), name:%s Actual:%j Expecting:%s', nameserver, nsIp, adminDomain, answer, ip);
var match = answer.some(function (a) {
return a.address === ip;
});
if (match) return everyIpCallback(null, true); // done!
everyIpCallback(null, false);
});
req.send();
}, everyNsCallback);
});
}, function (error, success) {
if (error) return callback(error);
if (!success) return callback(new SubdomainError(SubdomainError.BAD_FIELD, 'The domain ' + adminDomain + ' does not resolve to the server\'s IP ' + ip));
callback(null, { provider: dnsConfig.provider, wildcard: !!dnsConfig.wildcard });
});
});
}
+16 -5
View File
@@ -4,13 +4,12 @@ exports = module.exports = {
upsert: upsert,
get: get,
del: del,
waitForDns: waitForDns
waitForDns: waitForDns,
verifyDnsConfig: verifyDnsConfig
};
var assert = require('assert'),
debug = require('debug')('box:dns/noop'),
SubdomainError = require('../subdomains.js').SubdomainError,
sysinfo = require('../sysinfo.js'),
util = require('util');
function upsert(dnsConfig, zoneName, subdomain, type, values, callback) {
@@ -49,11 +48,23 @@ function del(dnsConfig, zoneName, subdomain, type, values, callback) {
function waitForDns(domain, value, type, options, callback) {
assert.strictEqual(typeof domain, 'string');
assert.strictEqual(typeof value, 'string');
assert(type === 'A' || type === 'CNAME');
assert(typeof value === 'string' || util.isRegExp(value));
assert(type === 'A' || type === 'CNAME' || type === 'TXT');
assert(options && typeof options === 'object'); // { interval: 5000, times: 50000 }
assert.strictEqual(typeof callback, 'function');
callback();
}
function verifyDnsConfig(dnsConfig, domain, ip, callback) {
assert.strictEqual(typeof dnsConfig, 'object');
assert.strictEqual(typeof domain, 'string');
assert.strictEqual(typeof ip, 'string');
assert.strictEqual(typeof callback, 'function');
var credentials = {
provider: dnsConfig.provider
};
return callback(null, credentials);
}
+42 -1
View File
@@ -5,6 +5,7 @@ exports = module.exports = {
get: get,
del: del,
waitForDns: require('./waitfordns.js'),
verifyDnsConfig: verifyDnsConfig,
// not part of "dns" interface
getHostedZone: getHostedZone
@@ -13,8 +14,10 @@ exports = module.exports = {
var assert = require('assert'),
AWS = require('aws-sdk'),
debug = require('debug')('box:dns/route53'),
dns = require('native-dns'),
SubdomainError = require('../subdomains.js').SubdomainError,
util = require('util');
util = require('util'),
_ = require('underscore');
function getDnsCredentials(dnsConfig) {
assert.strictEqual(typeof dnsConfig, 'object');
@@ -209,3 +212,41 @@ function del(dnsConfig, zoneName, subdomain, type, values, callback) {
});
}
function verifyDnsConfig(dnsConfig, domain, ip, callback) {
assert.strictEqual(typeof dnsConfig, 'object');
assert.strictEqual(typeof domain, 'string');
assert.strictEqual(typeof ip, 'string');
assert.strictEqual(typeof callback, 'function');
var credentials = {
provider: dnsConfig.provider,
accessKeyId: dnsConfig.accessKeyId,
secretAccessKey: dnsConfig.secretAccessKey,
region: dnsConfig.region || 'us-east-1',
endpoint: dnsConfig.endpoint || null
};
if (process.env.BOX_ENV === 'test') return callback(null, credentials); // this shouldn't be here
dns.resolveNs(domain, function (error, nameservers) {
if (error && error.code === 'ENOTFOUND') return callback(new SubdomainError(SubdomainError.BAD_FIELD, 'Unable to resolve nameservers for this domain'));
if (error || !nameservers) return callback(new SubdomainError(SubdomainError.BAD_FIELD, error ? error.message : 'Unable to get nameservers'));
getHostedZone(credentials, domain, function (error, zone) {
if (error) return callback(error);
if (!_.isEqual(zone.DelegationSet.NameServers.sort(), nameservers.sort())) {
debug('verifyDnsConfig: %j and %j do not match', nameservers, zone.DelegationSet.NameServers);
return callback(new SubdomainError(SubdomainError.BAD_FIELD, 'Domain nameservers are not set to Route53'));
}
upsert(credentials, domain, 'my', 'A', [ ip ], function (error, changeId) {
if (error) return callback(error);
debug('verifyDnsConfig: A record added with change id %s', changeId);
callback(null, credentials);
});
});
});
}

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