@@ -12,6 +12,26 @@ const chalk = require('chalk')
12
12
13
13
exports . command = 'setup'
14
14
exports . desc = 'Run a one-time configuration step for FUSE.'
15
+ exports . builder = {
16
+ user : {
17
+ description : 'User that should own the /hyperdrive directory' ,
18
+ type : 'string' ,
19
+ default : process . geteuid ( ) ,
20
+ alias : 'U'
21
+ } ,
22
+ group : {
23
+ description : 'User that should own the /hyperdrive directory' ,
24
+ type : 'string' ,
25
+ default : process . getgid ( ) ,
26
+ alias : 'G'
27
+ } ,
28
+ force : {
29
+ description : 'Force' ,
30
+ type : 'boolean' ,
31
+ default : true ,
32
+ alias : 'f'
33
+ }
34
+ }
15
35
exports . handler = async function ( argv ) {
16
36
if ( ! hyperfuse ) return onerror ( 'FUSE installation failed.' )
17
37
@@ -28,7 +48,7 @@ exports.handler = async function (argv) {
28
48
function configureFuse ( cb ) {
29
49
hyperfuse . isConfigured ( ( err , fuseConfigured ) => {
30
50
if ( err ) return onerror ( err )
31
- if ( fuseConfigured ) return cb ( null , 'FUSE is already configured.' )
51
+ if ( argv . force === false && fuseConfigured ) return cb ( null , 'FUSE is already configured.' )
32
52
return configure ( cb )
33
53
} )
34
54
@@ -43,10 +63,10 @@ exports.handler = async function (argv) {
43
63
function makeRootDrive ( cb ) {
44
64
fs . stat ( '/hyperdrive' , ( err , stat ) => {
45
65
if ( err && err . errno !== - 2 ) return cb ( new Error ( 'Could not get the status of /hyperdrive.' ) )
46
- if ( ! err && stat ) return cb ( null , 'The root hyperdrive directory has already been created.' )
47
- exec ( 'sudo mkdir /hyperdrive' , err => {
66
+ if ( ! err && argv . force === false && stat ) return cb ( null , 'The root hyperdrive directory has already been created.' )
67
+ exec ( 'sudo mkdir -p /hyperdrive' , err => {
48
68
if ( err ) return cb ( new Error ( 'Could not create the /hyperdrive directory.' ) )
49
- exec ( `sudo chown ${ process . getuid ( ) } :${ process . getgid ( ) } /hyperdrive` , err => {
69
+ exec ( `sudo chown ${ argv . user } :${ argv . group } /hyperdrive` , err => {
50
70
if ( err ) return cb ( new Error ( 'Could not change the permissions on the /hyperdrive directory.' ) )
51
71
return cb ( null , 'Successfully created the the root hyperdrive directory.' )
52
72
} )
0 commit comments