@@ -2,6 +2,7 @@ package wot_relay
2
2
3
3
import (
4
4
"fmt"
5
+ "github.com/nodetec/rwz/pkg/network"
5
6
"github.com/nodetec/rwz/pkg/relays"
6
7
"github.com/nodetec/rwz/pkg/utils/configuration"
7
8
"github.com/nodetec/rwz/pkg/utils/directories"
@@ -26,37 +27,39 @@ func SetupRelayService(domain, pubKey, relayContact string, httpsEnabled bool) {
26
27
spinner .UpdateText ("Creating config directory..." )
27
28
directories .CreateDirectory (ConfigDirPath , 0755 )
28
29
29
- // Ensure the templates directory exists and set permissions
30
- spinner .UpdateText ("Creating templates directory..." )
31
- directories .CreateDirectory (TemplatesDirPath , 0755 )
30
+ // Path to the /var/www/domain directory
31
+ WWWDomainDirPath := fmt .Sprintf ("%s/%s" , network .WWWDirPath , domain )
32
32
33
- // Use chown command to set ownership of the config directory and its content to the nostr user
34
- directories . SetOwnerAndGroup ( relays . User , relays . User , ConfigDirPath )
33
+ // Path to the index.html file
34
+ IndexFilePath := fmt . Sprintf ( "%s/%s" , WWWDomainDirPath , IndexFile )
35
35
36
36
// Check if the index.html file exists and remove it if it does
37
37
files .RemoveFile (IndexFilePath )
38
38
39
- // Copy the index.html file to templates directory
40
- files .CopyFile (TmpIndexFilePath , TemplatesDirPath )
39
+ // Copy the index.html file to the /var/www/domain directory
40
+ files .CopyFile (TmpIndexFilePath , WWWDomainDirPath )
41
41
42
42
// Set permissions for the index.html file
43
43
files .SetPermissions (IndexFilePath , 0644 )
44
44
45
- // Use chown command to set ownership of the index.html file to the nostr user
46
- files .SetOwnerAndGroup (relays .User , relays .User , IndexFilePath )
45
+ // Use chown command to set ownership of the index.html file to the www-data user
46
+ files .SetOwnerAndGroup (relays .NginxUser , relays .NginxUser , IndexFilePath )
47
+
48
+ // Path to the static directory
49
+ StaticDirPath := fmt .Sprintf ("%s/%s" , WWWDomainDirPath , StaticDir )
47
50
48
51
// Remove the static directory and all of its content if it exists
49
52
spinner .UpdateText ("Removing static directory..." )
50
53
directories .RemoveDirectory (StaticDirPath )
51
54
52
- // Copy the static directory and all of its content to the templates directory
53
- directories .CopyDirectory (TmpStaticDirPath , TemplatesDirPath )
55
+ // Copy the static directory and all of its content to the /var/www/domain directory
56
+ directories .CopyDirectory (TmpStaticDirPath , WWWDomainDirPath )
54
57
55
58
// Set permissions for the static directory
56
59
directories .SetPermissions (StaticDirPath , 0755 )
57
60
58
- // Use chown command to set ownership of the static directory and its content to the nostr user
59
- directories .SetOwnerAndGroup (relays .User , relays .User , StaticDirPath )
61
+ // Use chown command to set ownership of the static directory and its content to the www-data user
62
+ directories .SetOwnerAndGroup (relays .NginxUser , relays .NginxUser , StaticDirPath )
60
63
61
64
// Check if the environment file exists and remove it if it does
62
65
files .RemoveFile (EnvFilePath )
@@ -72,9 +75,6 @@ func SetupRelayService(domain, pubKey, relayContact string, httpsEnabled bool) {
72
75
// Set permissions for the environment file
73
76
files .SetPermissions (EnvFilePath , 0644 )
74
77
75
- // Use chown command to set ownership of the environment file to the nostr user
76
- files .SetOwnerAndGroup (relays .User , relays .User , EnvFilePath )
77
-
78
78
// Create the systemd service file
79
79
spinner .UpdateText ("Creating service file..." )
80
80
serviceFileParams := systemd.ServiceFileParams {EnvFilePath : EnvFilePath , BinaryFilePath : BinaryFilePath }
0 commit comments