|
|
@@ -26,10 +26,33 @@ if [ ! -f /data/id_ed25519 ] && [ ! "$KEY_PRIV" = "" ] ; then
|
|
26
|
26
|
echo "Private key created from ENV variable"
|
|
27
|
27
|
fi
|
|
28
|
28
|
|
|
29
|
|
-# fix perms
|
|
30
|
|
-if [ -f /data/id_ed25519.pub ] ; then
|
|
31
|
|
- chmod 600 /data/id_ed25519.pub
|
|
|
29
|
+# check if both keys provided
|
|
|
30
|
+if [ -f /data/id_ed25519.pub ] && [ ! -f /data/id_ed25519 ] ; then
|
|
|
31
|
+ echo "Private key missing."
|
|
|
32
|
+ echo "You must provide BOTH the private and the public key."
|
|
|
33
|
+ /run/s6/basedir/bin/halt
|
|
|
34
|
+ exit 1
|
|
32
|
35
|
fi
|
|
33
|
|
-if [ -f /data/id_ed25519 ] ; then
|
|
34
|
|
- chmod 600 /data/id_ed25519
|
|
|
36
|
+
|
|
|
37
|
+if [ ! -f /data/id_ed25519.pub ] && [ -f /data/id_ed25519 ] ; then
|
|
|
38
|
+ echo "Public key missing."
|
|
|
39
|
+ echo "You must provide BOTH the private and the public key."
|
|
|
40
|
+ /run/s6/basedir/bin/halt
|
|
|
41
|
+ exit 1
|
|
35
|
42
|
fi
|
|
|
43
|
+
|
|
|
44
|
+# here we have either no keys or both
|
|
|
45
|
+
|
|
|
46
|
+# if we have both keys, we fix permissions and ownership
|
|
|
47
|
+# and check for keypair validation
|
|
|
48
|
+if [ -f /data/id_ed25519.pub ] && [ -f /data/id_ed25519 ] ; then
|
|
|
49
|
+ chmod 0600 /data/id_ed25519.pub /data/id_ed25519
|
|
|
50
|
+ chown root:root /data/id_ed25519.pub /data/id_ed25519
|
|
|
51
|
+ /usr/bin/rustdesk-utils validatekeypair "$(cat /data/id_ed25519.pub)" "$(cat /data/id_ed25519)" || {
|
|
|
52
|
+ echo "Key pair not valid"
|
|
|
53
|
+ /run/s6/basedir/bin/halt
|
|
|
54
|
+ exit 1
|
|
|
55
|
+ }
|
|
|
56
|
+fi
|
|
|
57
|
+
|
|
|
58
|
+# if we have no keypair, hbbs will generate one
|