-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInit.fs
More file actions
35 lines (28 loc) · 950 Bytes
/
Init.fs
File metadata and controls
35 lines (28 loc) · 950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module RemoteDesktopAssistant.Init
open System.IO
open System.Text.Json
[<Literal>]
let config = "config.json"
type InitValues =
{ OpenVpnExecutable: string
VpnConnect: string
VpnDisconnect: string }
let def =
{ OpenVpnExecutable = @"C:\Program Files\OpenVPN\bin\openvpn-gui.exe"
VpnConnect = "--command connect VpnName --silent connection 1"
VpnDisconnect = "--command exit" }
let read () : InitValues =
if Path.Exists config then
try
match File.ReadAllText config |> JsonSerializer.Deserialize<InitValues> with
| Null -> def
| NonNull ini -> ini
with e ->
System.Diagnostics.Trace.WriteLine e
def
else
def
let write (init: InitValues) =
let opt = JsonSerializerOptions(JsonSerializerOptions.Default, WriteIndented = true)
JsonSerializer.Serialize(init, opt)
|> fun json -> File.WriteAllText(config, json)