Skip to content

Commit

Permalink
Systemd works
Browse files Browse the repository at this point in the history
  • Loading branch information
krystian-panek-vmltech committed Nov 10, 2023
1 parent 0ffc523 commit bfe3593
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 27 deletions.
3 changes: 0 additions & 3 deletions internal/provider/instance/bin.sh

This file was deleted.

3 changes: 2 additions & 1 deletion internal/provider/instance/create.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh

sh aemw instance create
sh aemw instance create && \
sh aemw instance init
3 changes: 0 additions & 3 deletions internal/provider/instance/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ var ConfigYML string
//go:embed systemd.conf
var ServiceConf string

//go:embed bin.sh
var BinScript string

//go:embed create.sh
var CreateScript string

Expand Down
13 changes: 0 additions & 13 deletions internal/provider/instance_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,31 +99,18 @@ func (ic *InstanceClient) saveProfileScript() error {
}

func (ic *InstanceClient) configureService() error {
binFile := fmt.Sprintf("/usr/sbin/%s", ServiceName)
user := ic.data.System.User.ValueString()
if user == "" {
user = ic.cl.Connection().User()
}
vars := map[string]string{
"DATA_DIR": ic.dataDir(),
"USER": user,
"BIN_FILE": binFile,
}

ic.cl.Sudo = true
defer func() { ic.cl.Sudo = false }()

binScriptTemplated, err := utils.TemplateString(ic.data.System.BinScript.ValueString(), vars)
if err != nil {
return fmt.Errorf("unable to template AEM system script: %w", err)
}
if err := ic.cl.FileWrite(binFile, binScriptTemplated); err != nil {
return fmt.Errorf("unable to write AEM system script '%s': %w", binFile, err)
}
if err := ic.cl.FileMakeExecutable(binFile); err != nil {
return fmt.Errorf("unable to make AEM system script '%s' executable: %w", binFile, err)
}

serviceTemplated, err := utils.TemplateString(ic.data.System.ServiceConfig.ValueString(), vars)
if err != nil {
return fmt.Errorf("unable to template AEM system service definition: %w", err)
Expand Down
7 changes: 0 additions & 7 deletions internal/provider/instance_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ type InstanceResourceModel struct {
DataDir types.String `tfsdk:"data_dir"`
WorkDir types.String `tfsdk:"work_dir"`
Env types.Map `tfsdk:"env"`
BinScript types.String `tfsdk:"bin_script"`
ServiceConfig types.String `tfsdk:"service_config"`
User types.String `tfsdk:"user"`
Bootstrap types.String `tfsdk:"bootstrap"`
Expand Down Expand Up @@ -117,12 +116,6 @@ func (r *InstanceResource) Schema(ctx context.Context, req resource.SchemaReques
Optional: true,
Default: stringdefault.StaticString("/tmp/aemc"),
},
"bin_script": schema.StringAttribute{
MarkdownDescription: "Contents of the system-wide binary script for controlling AEM instance.",
Optional: true,
Computed: true,
Default: stringdefault.StaticString(instance.BinScript),
},
"service_config": schema.StringAttribute{
MarkdownDescription: "Contents of the AEM 'systemd' service definition file",
Optional: true,
Expand Down

0 comments on commit bfe3593

Please sign in to comment.