Commit Graph

223 Commits

Author SHA1 Message Date
Girish Ramakrishnan 2455975a46 bash scripts: merge the set lines 2015-01-23 15:01:10 -08:00
Girish Ramakrishnan a9fa5b37a4 Use sudo -k on Mac 2015-01-22 23:01:49 -08:00
Girish Ramakrishnan 3953b96626 set -u all the scripts 2015-01-22 17:04:37 -08:00
Girish Ramakrishnan 1f04a4f41c Add --revision 2015-01-22 16:24:20 -08:00
Johannes Zellner 7506746892 Remove .sh extension for executable shell scripts 2015-01-23 01:10:56 +01:00
Johannes Zellner 2a06533703 Fix the checkInstall.sh by checking the error 2015-01-23 01:08:02 +01:00
Girish Ramakrishnan 06f83b51ba Only mark constants as readonly
This is just a coding style thing because bash gets all worked up
if we reuse these variable names in functions as local

example:

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

    readonly VAR="deal"
    func
2015-01-21 15:52:14 -08:00
Girish Ramakrishnan 82d14bd1a5 Use double brackets 2015-01-21 14:33:41 -08:00
Girish Ramakrishnan feb748e9b5 checkInstall.sh - fix coding style 2015-01-21 14:32:45 -08:00
Girish Ramakrishnan d149519fc1 createSourceTarball: fix coding style 2015-01-21 14:29:45 -08:00
Girish Ramakrishnan 409f919d4d Ensure top level directory is readable by others
tar --list --verbose --file=box.tar now shows:
drwxr-xr-x girishra/staff    0 2015-01-17 16:57 ./

Without this change, mktemp was creating directories have no r,x for
others and group. This meant that nginx which was running www-user
was unable to access the website inside box code.
2015-01-17 13:59:58 -08:00
Girish Ramakrishnan 63d315ed32 Move image creation scripts to installer repo 2015-01-12 17:10:44 -08:00
Girish Ramakrishnan a87ad700bd Comment out set -x 2015-01-11 00:58:09 -08:00
Girish Ramakrishnan d561649f08 New release script: publish.sh
It takes arguments --image <image_id> or --code <source_code_url>

image_id is generated using scripts/createDigitalOceanImage.sh
source_code_url is generated using scripts/createSourceTarball.sh
2015-01-11 00:44:28 -08:00
Girish Ramakrishnan f193b889ab install server never dies
The install server is now always started by the init script.
When started up, it determines it's mode based on the exitence
of box srcdir. If it does not exist, it starts an external
listening provision/restore server. Once the appstore, provisions
the box, it switches to update mode.

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

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

Part of #115
2015-01-09 15:25:28 -08:00
Girish Ramakrishnan 259747fcdc Check exit status immediately because of set -e 2015-01-09 13:57:55 -08:00
Girish Ramakrishnan 1c71143dc5 Check if redis and test images are present 2015-01-07 22:31:17 -08:00
Girish Ramakrishnan 27364458a7 Fix typo 2015-01-07 13:45:55 -08:00
Girish Ramakrishnan f42c838c4a Pull in redis image 2015-01-07 13:43:53 -08:00
Johannes Zellner 2db84be8ee Sync image creation defaults with heroku config 2015-01-07 22:10:15 +01:00
Johannes Zellner a5d680fd0d Allow specify regions for cloudron images
This reuses the 'regions' argument to transfer the
new image to the list specified. The first entry is the
region, where the temporary droplet is being created.

eg. --regions="ams3 ny2 sfo1"

The image droplet is created in Amsterdam.

The script currently does not wait for all images to be
fully transferred, yet.
2015-01-07 15:57:47 +01:00
Girish Ramakrishnan 71e1efcd2b barf on error 2015-01-06 11:30:08 -08:00
Girish Ramakrishnan f4cfaeacb9 Use the GNU getopt on Mac
getopts - bash built-in that supports only short form
getopt - separate program and there are two variants - GNU and BSD. The BSD one
  does not support long options.
2015-01-06 11:27:36 -08:00
Girish Ramakrishnan 7d70c52863 createDigitalOceanImage: Add --revision, --size, --region args
Possible region slugs as of today are:
nyc1
ams1
sfo1
nyc2
ams2
sgp1

Possible size slugs are:
512mb
1gb
2gb
4gb
8gb
16gb
32gb
48gb
64gb
2015-01-06 11:02:03 -08:00
Girish Ramakrishnan ae2abd9162 Add postgresql to base image 2015-01-05 21:42:03 -08:00
Girish Ramakrishnan a572914231 Install pwgen in base image required by postinstall script 2014-11-26 17:09:27 -08:00
Girish Ramakrishnan 44ad297d15 Add hack to update installer as well
Otherwise it's painful to test installer changes
2014-11-26 16:33:43 -08:00
Girish Ramakrishnan 3ebaf951f2 Simplify log filename 2014-11-26 16:28:10 -08:00
Girish Ramakrishnan b28d64dc57 Install mysql addon image 2014-11-26 14:25:23 -08:00
Girish Ramakrishnan f4f24e7347 Make installer run across reboots
The installer is run in provision-mode in the init script

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

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

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

This also makes it clear that announce is a feature of the provision
mode.
2014-11-21 14:18:59 -08:00
Girish Ramakrishnan d4ee1c59f1 Use connect-lastmile in installer 2014-11-12 13:15:29 -08:00
Girish Ramakrishnan 0525ccc4a4 Disable metadata API access to non-root users
The only reason not to use the metadata completely for provisioning
is because many VPS providers do not provide it.

If we rely on a metadata API, we can pretty much remove the installer
server
2014-11-10 16:26:56 -08:00
Girish Ramakrishnan 9309c89a1a Appstore name is not part of image anymore 2014-11-09 10:06:23 -08:00
Girish Ramakrishnan bea71b35f6 Move to v2 api 2014-11-09 10:04:29 -08:00
Girish Ramakrishnan b039123daa Make updates to use the installer code 2014-10-31 17:50:32 -07:00
Girish Ramakrishnan cf3e98a3f6 Start supervisor by default in the base image
This is nice to have for the update case where we can just stop
all the apps
2014-10-31 16:59:02 -07:00
Girish Ramakrishnan bb646c3c89 APPSTORE_URL is not part of image anymore
The installer now gets the appStoreUrl from the droplet metadata
2014-10-30 14:02:12 -07:00
Girish Ramakrishnan 779c9c1392 Rework provisioning
The previous provisioning scheme had issues with updates. Because,
configuration was already part of the base bootstrap, providing an
update meant creating a new image.

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

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

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

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

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

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

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

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

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

Part of #108
2014-10-24 22:17:46 -07:00
Girish Ramakrishnan 80f82883cd Query snapshot id before destroying droplet
Allows us to work in parallel as the droplet is being destroyed
2014-10-24 19:57:28 -07:00
Girish Ramakrishnan 15df364c91 Move all configs to configs/
This makes it easy to delete them in a single shot
2014-10-24 17:45:55 -07:00
Girish Ramakrishnan 049912c096 Sleep a couple of minutes before retrying again 2014-10-24 17:26:14 -07:00
Girish Ramakrishnan bc24596d22 Fix typo 2014-10-22 00:27:12 -07:00
Girish Ramakrishnan 66e4a417d1 Fix scripts for new dir structure 2014-10-22 00:02:23 -07:00
Girish Ramakrishnan f11adb5e85 Run postinstall script on startup 2014-10-21 20:30:15 -07:00