@@ -12,6 +12,26 @@ const chalk = require('chalk')
1212
1313exports . command = 'setup'
1414exports . 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+ }
1535exports . handler = async function ( argv ) {
1636 if ( ! hyperfuse ) return onerror ( 'FUSE installation failed.' )
1737
@@ -28,7 +48,7 @@ exports.handler = async function (argv) {
2848 function configureFuse ( cb ) {
2949 hyperfuse . isConfigured ( ( err , fuseConfigured ) => {
3050 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.' )
3252 return configure ( cb )
3353 } )
3454
@@ -43,10 +63,10 @@ exports.handler = async function (argv) {
4363 function makeRootDrive ( cb ) {
4464 fs . stat ( '/hyperdrive' , ( err , stat ) => {
4565 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 => {
4868 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 => {
5070 if ( err ) return cb ( new Error ( 'Could not change the permissions on the /hyperdrive directory.' ) )
5171 return cb ( null , 'Successfully created the the root hyperdrive directory.' )
5272 } )
0 commit comments