Class: SafeDb::Vpn
Overview
This vpn use case sets up vpn connection paraphernelia and can bring up a VPN connection and then tear it down.
safe vpn up
safe vpn down
Constant Summary
Constants inherited from UseCase
UseCase::APP_DIR_NAME, UseCase::COMMANDMENT, UseCase::ENV_VAR_KEY_NAME, UseCase::ENV_VAR_PREFIX_A, UseCase::ENV_VAR_PREFIX_B, UseCase::FILE_CONTENT_KEY, UseCase::FILE_KEY_PREFIX, UseCase::FILE_NAME_KEY
Instance Attribute Summary collapse
-
#command ⇒ Object
writeonly
Sets the attribute command.
Attributes inherited from UseCase
Instance Method Summary collapse
Methods inherited from UseCase
#check_post_conditions, #check_pre_conditions, #cleanup, #config_directory, #config_file, #flow_of_events, #get_master_database, #initialize, #post_validation, #pre_validation
Constructor Details
This class inherits a constructor from SafeDb::UseCase
Instance Attribute Details
#command=(value) ⇒ Object (writeonly)
Sets the attribute command
12 13 14 |
# File 'lib/usecase/vpn/vpn.rb', line 12 def command=(value) @command = value end |
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/usecase/vpn/vpn.rb', line 14 def execute if( @command && @command.eql?( "down" ) ) puts "" system @dictionary[ :nm_conn_off ]; sleep 2; system @dictionary[ :nm_conn_del ] puts "" return end puts "" system @dictionary[ :safe_write_cmd ] puts "[#{@dictionary[ :vpn_filename ]}] temporarily exported to [#{@dictionary[ :vpn_filepath ]}]." system @dictionary[ :nm_import_cmd ] File.delete( @dictionary[ :vpn_filepath ] ) puts "Exported file [#{@dictionary[ :vpn_filepath ]}] has now been deleted." system @dictionary[ :nm_default_cmd ] system @dictionary[ :nm_user_cmd ] system @dictionary[ :nm_reload_cmd ] system @dictionary[ :nm_flags_cmd ] system @dictionary[ :chown_cmd_1 ] vpn_data = IniFile.load( @dictionary[:nm_filepath] ) vpn_data['vpn-secrets'] = { 'password' => @dictionary[:vpn_password] } vpn_data.write() system @dictionary[ :chown_cmd_2 ] system @dictionary[ :nm_restart ]; sleep 2; system @dictionary[ :nm_conn_up ] puts "" end |