The following is a part of our template. We export a path variable there. However, running from template, this does not work. If I SSH into the server and run the same line, it works and I can use gradle. But just from the template, it somehow doesn't get executed. The other chmod commands work, so the block is clearly execute. Any help is highly appreciated.
...
"LaunchConfiguration": {
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Metadata": {
"AWS::CloudFormation::Init": {
"config": {
"packages": {
"yum": {
"java-1.8.0-openjdk-devel": []
}
},
"sources": {
"/opt": "https://services.gradle.org/distributions/gradle-3.4.1-bin.zip",
"/home/ec2-user": "https://github.com/ABC/XYZ/archive/master.zip"
},
"files": {
"/tmp/gradle_config": {
"content": {
"Fn::Join": ["",
[
"#!/bin/bash -ex\n",
"chmod -R 755 gradle-3.4.1/\n",
"export PATH=$PATH:/opt/gradle-3.4.1/bin\n" //<<<< This does not work
]
]
},
"mode": "000500",
"owner": "root",
"group": "root"
},
"/tmp/app_config": {
"content": {
"Fn::Join": ["",
[
"#!/bin/bash -ex\n",
"chmod -R 777 XYZ-master/\n"
]
]
},
"mode": "000500",
"owner": "root",
"group": "root"
}
},
"commands": {
"01_config": {
"command": "/tmp/gradle_config",
"cwd" : "/opt"
},
"02_config": {
"command": "/tmp/app_config",
"cwd" : "/home/ec2-user"
}
}
}
}
}, ...
I found the solution. All those lines are executed as root user. The export PATH... therefore wasn't for my ec2-user. The way I handled is was by putting the path variable (globally) into the /etc/environment file.
In my code snippet, just replace
"export PATH=$PATH:/opt/gradle-3.4.1/bin\n",
with
"echo \"PATH=$PATH:/opt/gradle-3.4.1/bin\" >> /etc/environment"",
Related
An instance is created when a new file is uploaded to the storage. The startup runs a python script that generates a pdf file for the new file, uploads the pdf back to the storage and deletes the instance. Since the python script has pretty lengthy, I have stored the startup script and the python script in the same location (Cloud Storage). I have passed the paths are metadata while creating the instance. The input to the python script is the file name of the new file. I checked the logs of the instance, its throwing some errors there. Can someone point out what is it that I am doing wrong.
Edited
Error Message:
{
"cpuPlatform": "Intel Haswell",
"creationTimestamp": "2021-08-02T06:40:36.346-07:00",
"deletionProtection": false,
"disks": [
{
"autoDelete": true,
"boot": true,
"deviceName": "xyz",
"diskSizeGb": "10",
"guestOsFeatures": [
{
"type": "UEFI_COMPATIBLE"
},
{
"type": "VIRTIO_SCSI_MULTIQUEUE"
}
],
"index": 0,
"interface": "SCSI",
"kind": "compute#attachedDisk",
"licenses": [
"projects/debian-cloud/global/licenses/debian-10-buster"
],
"mode": "READ_WRITE",
"source": "projects/patch-us/zones/us-central1-a/disks/instance-name",
"type": "PERSISTENT"
}
],
"fingerprint": "XlZ7biyVpAI=",
"id": "3984870299667155772",
"kind": "compute#instance",
"labelFingerprint": "42WmSpB8rSM=",
"lastStartTimestamp": "2021-08-02T06:40:46.210-07:00",
"machineType": "projects/project-name/zones/us-central1-a/machineTypes/e2-medium",
"metadata": {
"fingerprint": "f5o3Pxed5VY=",
"items": [
{
"key": "startup-script-url",
"value": "https://storage.cloud.google.com/project-name.appspot.com/start-up-script/start-script.sh"
},
{
"key": "file_name",
"value": "123456"
},
{
"key": "python_script_name",
"value": "https://storage.cloud.google.com/project-name.appspot.com/start-up-script/generate_fd_report.py"
}
],
"kind": "compute#metadata"
},
"name": "instance-name",
"networkInterfaces": [
{
"accessConfigs": [
{
"kind": "compute#accessConfig",
"name": "External NAT",
"natIP": "35.202.255.222",
"networkTier": "PREMIUM",
"type": "ONE_TO_ONE_NAT"
}
],
"fingerprint": "565TD6a2Y2c=",
"kind": "compute#networkInterface",
"name": "nic0",
"network": "projects/project-name/global/networks/default",
"networkIP": "10.128.0.29",
"stackType": "IPV4_ONLY",
"subnetwork": "projects/project-name/regions/us-central1/subnetworks/default"
}
],
"scheduling": {
"automaticRestart": true,
"onHostMaintenance": "MIGRATE",
"preemptible": false
},
"selfLink": "projects/project-name/zones/us-central1-a/instances/instance-name",
"serviceAccounts": [
{
"email": "project-id-compute#developer.gserviceaccount.com",
"scopes": [
"https://www.googleapis.com/auth/cloud-platform"
]
}
],
"shieldedInstanceConfig": {
"enableIntegrityMonitoring": true,
"enableSecureBoot": false,
"enableVtpm": true
},
"shieldedInstanceIntegrityPolicy": {
"updateAutoLearnPolicy": true
},
"startRestricted": false,
"status": "RUNNING",
"tags": {
"fingerprint": "42WmSpB8rSM="
},
"zone": "projects/project-name/zones/us-central1-a"
}
start-script-sh
#! /bin/bash
ECG_FILE_PATH = $(curl http://metadata/computeMetadata/v1/instance/attributes/file_path -H "Metadata-Flavor: Google")
PYTHON_FILE_PATH = $(curl http://metadata/computeMetadata/v1/instance/attributes/python_script_name -H "Metadata-Flavor: Google")
ECG_FILE_NAME = $(curl http://metadata/computeMetadata/v1/instance/attributes/file_name -H "Metadata-Flavor: Google")
curl -s -o generate_fd.py PYTHON_FILE_PATH
chmod +x generate_fd.py
python3 generate_fd.py ECG_FILE_PATH &
generate_fd_report.py
#!/usr/bin/env python3
def main(file_name):
print("Hello")
main(file_name)
Logs
To download the script, URL path to which you've saved as the metadata value is as follows:
curl -s -o filename.txt $(curl -s http://metadata/computeMetadata/v1/instance/attributes/filename -H "Metadata-Flavor: Google")
Installed LSP server on Sublime Text 3, then enabled gopls from the LSP: Enable Language Server Globally > selected gopls.
Also executed below command on terminal.
GO111MODULE=on go get golang.org/x/tools/gopls#latest
Error shown:
LSP.sublime-settings
{
"clients":
{
"gopls":
{
"enabled": true
}
}
}
gopls command
❯ which gopls
/home/user/go/bin/gopls
I am using MX Linux. Please help !
Source
This solved the problem.
## LSP.sublime-settings -- User
{
"clients":
{
"gopls":
{
"command": [
"/home/rahulbali/go/bin/gopls",
"-v",
"-rpc.trace",
"-logfile=/home/rahulbali/gopls.log"
],
"enabled": true,
"env": {
"PATH": "home/rahulbali/go/bin:/usr/local/go/bin"
},
"scopes":["source.go"],
"syntaxes": [
"Packages/Go/Go.sublime-syntax",
"Packages/GoSublime/syntax/GoSublime-Go-Recommended.sublime-syntax",
],
"settings": {
"gopls.usePlaceholders": true,
"gopls.completeUnimported": true,
},
"languageId": "go"
}
}
}
Source: https://github.com/golang/go/issues/43746#issuecomment-761760279
Edit: Make 'gopls' is in your shell path.
What sublime text quotes is:
{
"clients": {
"gopls": {
"enabled": true,
"command": ["gopls"],
"selector": "source.go",
"initializationOptions": {
"experimentalWorkspaceModule": false
}
}
}
}
Giving the absolute path (which gopls) to gopls binary should solve the 'not found' problem.
{
"clients": {
"gopls": {
"enabled": true,
"command": ["/Users/xxx/go/bin/gopls"],
"selector": "source.go",
"initializationOptions": {
"experimentalWorkspaceModule": false
}
}
}
}
Today I was trying to create a confluence addon for my company and I've try following atlassian documents.
My problem comes trying to run the express app when adding a new customContent to the atlassian-connect.json, after running npm start I get the following error.
Failed to register with host https://admin:xxx#xxx.atlassian.net/wiki (200)
{"type":"INSTALL","pingAfter":300,"status":{"done":true,"statusCode":200,"con
tentType":"application/vnd.atl.plugins.task.install.err+json","subCode":"upm.
pluginInstall.error.descriptor.not.from.marketplace","source":"https://1a0adc
8f.ngrok.io/atlassian-connect.json","name":"https://1a0adc8f.ngrok.io/atlassi
an-connect.json"},"links":{"self":"/wiki/rest/plugins/1.0/pending/b88594d3-c3
c2-4760-b687-c8d860c0a377","alternate":"/wiki/rest/plugins/1.0/tasks/b88594d3
-c3c2-4760-b687-c8d860c0a377"},"timestamp":1502272147602,"userKey":"xxx","id":"xxx"}
Add-on not registered; no compatible hosts detected
This is my atlassian-connect.json file:
{
"key": "my-add-on",
"name": "Ping Pong",
"description": "My very first add-on",
"vendor": {
"name": "Angry Nerds",
"url": "https://www.atlassian.com/angrynerds"
},
"baseUrl": "{{localBaseUrl}}",
"links": {
"self": "{{localBaseUrl}}/atlassian-connect.json",
"homepage": "{{localBaseUrl}}/atlassian-connect.json"
},
"authentication": {
"type": "jwt"
},
"lifecycle": {
"installed": "/installed"
},
"scopes": [
"READ"
],
"modules": {
"generalPages": [
{
"key": "hello-world-page-jira",
"location": "system.top.navigation.bar",
"name": {
"value": "Hello World"
},
"url": "/hello-world",
"conditions": [{
"condition": "user_is_logged_in"
}]
},
{
"key": "customersViewer",
"location": "system.header/left",
"name": {
"value": "Hello World"
},
"url": "/hello-world",
"conditions": [{
"condition": "user_is_logged_in"
}]
}
],
"customContent": [
{
"key": "customer",
"name": {
"value": "Customers"
},
"uiSupport": {
"contentViewComponent": {
"moduleKey": "customersViewer"
},
"listViewComponent": {
"moduleKey": "customerList"
},
"icons": {
"item": {
"url": "/images/customers.png"
}
}
},
"apiSupport": {
"supportedContainerTypes": ["space"]
}
}
]
}
}
Does anybody has an idea on whats going on?
The contentViewComponent can't find the generalPage it is referencing in moduleKey.
From the docs:
In the snippet above, the moduleKey “customersViewer” maps to a
generalPage module we have defined in our add-on. This generalPage is
passed the context parameters we specify, and visualizes our content
accordingly.
If you change the generalPage with the key hello-world-page-confluence to customersVieweryou be able to install and get up and running.
I have a conf file as shown below
{
"files": [
{
"paths": ["/srv/log/*"],
"fields": { "type": "appLog", "app": "my_app", "env": "integration", "server": "" }
},
{
"paths": ["/srv/log/tomcat7/*"],
"fields": { "type": "tomcat", "app": "my_app", "env": "integration", "server": "" }
},
{
"paths": ["/srv/log/nginx/*"],
"fields": { "type": "nginxLog", "app": "my_app", "env": "integration", "server": "" }
}
]
}
I have to define the server explicitly through a shell script which is stored in a variable. Which means that i need to add the server in the "" after "server" to another script, For example: $host = my_machine.test.net , say this server address needs to be added into the conf file through my shell script . So when i run my script the above conf becomes
{
"files": [
{
"paths": ["/srv/log/*"],
"fields": { "type": "appLog", "app": "my_app", "env": "integration", "server": "my_machine.test.net" }
},
{
"paths": ["/srv/log/tomcat7/*"],
"fields": { "type": "tomcat", "app": "my_app", "env": "integration", "server": "my_machine.test.net" }
},
{
"paths": ["/srv/log/nginx/*"],
"fields": { "type": "nginxLog", "app": "my_app", "env": "integration", "server": "my_machine.test.net" }
}
]
}
I tried using "sed -i" but couldn't make it work. Can someone help.
The config file is a json document. Use jq to modify it:
jq --arg server 'my.server.net' '.files[].fields.server=$server' conf.json
To change the file in place:
mv conf.json conf.backup.json
jq --arg server 'my.server.net' '.files[].fields.server=$server' conf.json > new
mv new conf.json
Using sed:
sed -i 's/""/"my_machine.test.net"/' file
Or bash script:
$ cat script.sh
#!/bin/bash
sed -i "s/\"\"/\"$1\"/g" file
How to use:
$ ./script.sh my_machine.test.net
I'm creating a flatpak package for vlc. Since flatpak runs in sandbox and vlc depends on lua -> guile -> bdw-gc -> libunistring.
I have to first compile all these dependencies into flatpak sandbox. However bdw-gc and libunistring`` compile perfectly, butguilefails in last step ofmake` with error:
make[1]: Leaving directory '/run/build/guile'
stripping /home/ivansek/projects/vlc/flatpak/vlc-repo2/files/bin/guile to /home/ivansek/projects/vlc/flatpak/vlc-repo2/files/lib/debug/bin/guile.debug
stripping /home/ivansek/projects/vlc/flatpak/vlc-repo2/files/lib/libguile-2.0.so.22.8.1 to /home/ivansek/projects/vlc/flatpak/vlc-repo2/files/lib/debug/lib/libguile-2.0.so.22.8.1.debug
Error: module guile: Error opening file '/home/ivansek/projects/vlc/flatpak/vlc-repo2/files/lib/debug/source/guile/libguile/scmconfig.h': Permission denied
I'm using flatpak-builder for that using manifest file as:
{
"app-id": "org.gnome.vlc",
"runtime": "org.gnome.Platform",
"runtime-version": "3.22",
"sdk": "org.gnome.Sdk",
"command": "vlc",
"finish-args": [
"--socket=x11",
"--share=network",
"--share=ipc",
"--filesystems=host"
],
"modules": [
{
"name": "bdw-gc",
"sources": [
{
"type": "archive",
"url": "http://www.hboehm.info/gc/gc_source/gc-7.6.0.tar.gz",
"sha256": "a14a28b1129be90e55cd6f71127ffc5594e1091d5d54131528c24cd0c03b7d90"
}
]
},
{
"name": "libunistring",
"sources": [
{
"type": "archive",
"url": "http://ftp.gnu.org/gnu/libunistring/libunistring-0.9.6.tar.xz",
"sha256": "2df42eae46743e3f91201bf5c100041540a7704e8b9abfd57c972b2d544de41b"
}
]
},
{
"name": "guile",
"sources": [
{
"type": "archive",
"url": "https://ftp.gnu.org/gnu/guile/guile-2.0.13.tar.xz",
"sha256": "3744f2addc282a0de627aaef048f062982b44564d54ac31ff5217972529ed88b"
}
]
},
{
"name": "autogen",
"sources": [
{
"type": "archive",
"url": "https://ftp.gnu.org/gnu/autogen/rel5.18/autogen-5.18.tar.xz",
"sha256": "0c2dce22d4306ea29a01f6e54a35ea2b42dc7cf14f9818057b785e375bfbb784"
}
]
},
{
"name": "lua",
"sources": [
{
"type": "archive",
"url": "https://www.lua.org/ftp/lua-5.3.3.tar.gz",
"sha256": "5113c06884f7de453ce57702abaac1d618307f33f6789fa870e87a59d772aca2"
}
]
},
{
"name": "vlc",
"sources": [
{
"type": "archive",
"url": "http://get.videolan.org/vlc/2.2.4/vlc-2.2.4.tar.xz",
"sha256": "1632e91d2a0087e0ef4c3fb4c95c3c2890f7715a9d1d43ffd46329f428cf53be"
}
]
}
]
}
How can I solve this problem, or what is another approach to include vlc in flatpak?