@@ -2,18 +2,18 @@ module.exports = function(root){
22 var mesh = root . opt . mesh , cmd = { } , run = require ( 'child_process' ) . exec , fs = require ( 'fs' ) , home = require ( 'os' ) . homedir ( ) , examp = require ( 'path' ) . resolve ( __dirname , '../examples' ) ;
33 mesh . hear [ 'service' ] = function ( msg , peer ) {
44 if ( ! fs . existsSync ( '/lib/systemd/system/relay.service' ) ) {
5- mesh . say ( { dam : '!' , err : "Not serviced." } ) ;
5+ mesh . say ( { dam : '!' , err : "Not serviced." } , peer ) ;
66 return ;
77 }
8- try { ( cmd [ msg . try ] || cmd . any ) ( msg , peer ) ; } catch ( err ) { mesh . say ( { dam : '!' , err : "service error: " + err } ) }
8+ try { ( cmd [ msg . try ] || cmd . any ) ( msg , peer ) ; } catch ( err ) { mesh . say ( { dam : '!' , err : "service error: " + err } , peer ) }
99 }
1010 cmd . https = function ( msg , peer ) { var log ;
1111 if ( ! msg . email || ! msg . domain ) {
12- mesh . say ( { dam : '!' , err : 'Domain/email missing, use `location.hostname`!' } ) ;
12+ mesh . say ( { dam : '!' , err : 'Domain/email missing, use `location.hostname`!' } , peer ) ;
1313 return ;
1414 }
1515 if ( fs . existsSync ( home + '/cert.pem' ) ) {
16- mesh . say ( { dam : '!' , err : 'Cert already exists.' } ) ;
16+ mesh . say ( { dam : '!' , err : 'Cert already exists.' } , peer ) ;
1717 return ;
1818 }
1919 fs . writeFile ( examp + '/../email' , msg . email , function ( ) { } ) ;
@@ -33,15 +33,17 @@ module.exports = function(root){
3333 setTimeout ( function ( ) { process . exit ( ) } , 999 ) ;
3434 } ) ;
3535 }
36- ; ( function update ( ) { var last ;
36+ setTimeout ( function update ( ) { var last ;
3737 if ( ! fs . existsSync ( home + '/cert.pem' ) ) { return }
3838 setTimeout ( update , 1000 * 60 * 60 * 24 ) ;
3939 last = root . stats . stay . updated || 0 ;
40- if ( + new Date - last < 1000 * 60 * 60 * 24 * 15 ) { return }
40+ if ( + new Date - last < 1000 * 60 * 60 * 24 * 15 ) { return } // try to update every half month
4141 root . stats . stay . updated = + new Date ;
4242 run ( "bash " + examp + "/install.sh" , { } , function ( ) { } ) ;
43- } ( ) ) ;
43+ } , 999 ) ;
4444
4545 cmd . any = function ( ) { } ;
4646
47+ // list other modules here:
48+ require ( './tag' ) ( root ) ;
4749} ;
0 commit comments