Add some sshfs config tests
This commit is contained in:
+19
-4
@@ -103,10 +103,25 @@ function testConfig(apiConfig, callback) {
|
||||
|
||||
// TODO check fstab entry
|
||||
// TODO check mountpoint
|
||||
// TODO check we can stat backup dir
|
||||
// TODO check backup dir is dir
|
||||
// TODO check we can create 'snapshot' folder
|
||||
// TODO check we can write to backup dir (create and remove test file)
|
||||
|
||||
const backupPath = path.join(apiConfig.mountPoint, apiConfig.prefix);
|
||||
|
||||
const stat = safe.fs.statSync(backupPath);
|
||||
if (!stat) return callback(new BoxError(BoxError.BAD_FIELD, 'Directory does not exist or cannot be accessed: ' + safe.error.message), { field: 'prefix' });
|
||||
if (!stat.isDirectory()) return callback(new BoxError(BoxError.BAD_FIELD, 'Backup location is not a directory', { field: 'prefix' }));
|
||||
|
||||
if (!safe.fs.mkdirSync(path.join(backupPath, 'snapshot')) && safe.error.code !== 'EEXIST') {
|
||||
if (safe.error && safe.error.code === 'EACCES') return callback(new BoxError(BoxError.BAD_FIELD, `Access denied. Run "chown yellowtent:yellowtent ${backupPath}" on the server`, { field: 'prefix' }));
|
||||
return callback(new BoxError(BoxError.BAD_FIELD, safe.error.message, { field: 'prefix' }));
|
||||
}
|
||||
|
||||
if (!safe.fs.writeFileSync(path.join(backupPath, 'cloudron-testfile'), 'testcontent')) {
|
||||
return callback(new BoxError(BoxError.BAD_FIELD, `Unable to create test file as 'yellowtent' user in ${backupPath}: ${safe.error.message}. Check dir/mount permissions`, { field: 'prefix' }));
|
||||
}
|
||||
|
||||
if (!safe.fs.unlinkSync(path.join(backupPath, 'cloudron-testfile'))) {
|
||||
return callback(new BoxError(BoxError.BAD_FIELD, `Unable to remove test file as 'yellowtent' user in ${backupPath}: ${safe.error.message}. Check dir/mount permissions`, { field: 'prefix' }));
|
||||
}
|
||||
|
||||
callback(null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user