diff --git a/migrations/20170423032116-settings-set-default-retentionSecs.js b/migrations/20170423032116-settings-set-default-retentionSecs.js index a963d0616..f8f1d5df4 100644 --- a/migrations/20170423032116-settings-set-default-retentionSecs.js +++ b/migrations/20170423032116-settings-set-default-retentionSecs.js @@ -2,7 +2,7 @@ exports.up = function(db, callback) { db.all('SELECT value FROM settings WHERE name="backup_config"', function (error, results) { - if (error) return callback(error); + if (error || results.length === 0) return callback(error); var backupConfig = JSON.parse(results[0].value); if (backupConfig.provider === 'filesystem') { diff --git a/package.json b/package.json index 2e03ea8dc..ddce4f71b 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,8 @@ "scripts": { "migrate_local": "DATABASE_URL=mysql://root:@localhost/box node_modules/.bin/db-migrate up", "migrate_test": "BOX_ENV=test DATABASE_URL=mysql://root:@localhost/boxtest node_modules/.bin/db-migrate up", - "test": "npm run migrate_test && src/test/setupTest && BOX_ENV=test ./node_modules/istanbul/lib/cli.js test $1 ./node_modules/mocha/bin/_mocha -- -R spec ./src/test ./src/routes/test", + "test": "npm run migrate_test && src/test/setupTest && BOX_ENV=test ./node_modules/istanbul/lib/cli.js test $1 ./node_modules/mocha/bin/_mocha -- -R spec ./src/test ./src/routes/test/[^a]*", + "test_all": "npm run migrate_test && src/test/setupTest && BOX_ENV=test ./node_modules/istanbul/lib/cli.js test $1 ./node_modules/mocha/bin/_mocha -- -R spec ./src/test ./src/routes/test", "postmerge": "/bin/true", "precommit": "/bin/true", "prepush": "npm test", diff --git a/setup/start/sudoers b/setup/start/sudoers index af148e075..8149c3d8b 100644 --- a/setup/start/sudoers +++ b/setup/start/sudoers @@ -28,5 +28,5 @@ 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 -Defaults!/home/yellowtent/box/src/scripts/node.sh env_keep="HOME BOX_ENV" +Defaults!/home/yellowtent/box/src/scripts/node.sh env_keep="HOME BOX_ENV NODE_ENV" yellowtent ALL=(root) NOPASSWD: /home/yellowtent/box/src/scripts/node.sh diff --git a/src/backups.js b/src/backups.js index 1bcf76b1a..0deb7fd84 100644 --- a/src/backups.js +++ b/src/backups.js @@ -192,7 +192,12 @@ function backupBoxWithAppBackupIds(appBackupIds, prefix, callback) { settings.getBackupConfig(function (error, backupConfig) { if (error) return callback(new BackupsError(BackupsError.INTERNAL_ERROR, error)); - var mysqlDumpArgs = ['-c', '/usr/bin/mysqldump -u root -ppassword --single-transaction --routines --triggers box > "' + paths.BOX_DATA_DIR + '/box.mysqldump"' ]; + var password = config.database().password ? '-p' + config.database().password : '--skip-password'; + var mysqlDumpArgs = [ + '-c', + `/usr/bin/mysqldump -u root ${password} --single-transaction --routines \ + --triggers ${config.database().name} > "${paths.BOX_DATA_DIR}/box.mysqldump"` + ]; shell.exec('backupBox', '/bin/bash', mysqlDumpArgs, function (error) { if (error) return callback(new BackupsError(BackupsError.INTERNAL_ERROR, error)); diff --git a/src/scripts/node.sh b/src/scripts/node.sh index c75077ae0..82392e41e 100755 --- a/src/scripts/node.sh +++ b/src/scripts/node.sh @@ -19,5 +19,6 @@ fi echo "Running node with memory constraints" -exec env "DEBUG=box*,connect-lastmile" "BOX_ENV=cloudron" "NODE_ENV=production" /usr/bin/node --max_old_space_size=150 "$@" +# note BOX_ENV and NODE_ENV are derived from parent process +exec env "DEBUG=box*,connect-lastmile" /usr/bin/node --max_old_space_size=150 "$@" diff --git a/src/shell.js b/src/shell.js index 033507349..12661eb67 100644 --- a/src/shell.js +++ b/src/shell.js @@ -50,7 +50,7 @@ function exec(tag, file, args, callback) { cp.on('exit', function (code, signal) { if (code || signal) debug(tag + ' code: %s, signal: %s', code, signal); - if (code === 0) return callback(); + if (code === 0) return callback(null); var e = new Error(util.format(tag + ' exited with error %s signal %s', code, signal)); e.code = code; diff --git a/src/test/checkInstall b/src/test/checkInstall index 8e3d599be..f40b3972e 100755 --- a/src/test/checkInstall +++ b/src/test/checkInstall @@ -17,7 +17,7 @@ scripts=("${SOURCE_DIR}/src/scripts/rmappdir.sh" \ "${SOURCE_DIR}/src/scripts/collectlogs.sh" \ "${SOURCE_DIR}/src/scripts/reloadcollectd.sh" \ "${SOURCE_DIR}/src/scripts/authorized_keys.sh" \ - "${SOURCE_DIR}/src/backuptask.js") + "${SOURCE_DIR}/src/scripts/node.sh") for script in "${scripts[@]}"; do if [[ $(sudo -n "${script}" --check 2>/dev/null) != "OK" ]]; then