How does one set a proxy in lazybones? - groovy

I'm behind a firewall and lazybones can't reach its repository without a proxy.
I've searched the source and can't seem to find any reference to a proxy that seems to be relevant.

Support was officially added in version 0.8.1 of Lazybones, albeit via a general mechanism to add arbitrary system properties to the application in its configuration file, ~/.lazybones/config.groovy.
You can read about the details in the project README, but in essence, simply add the following to your config.groovy file:
systemProp {
http {
proxyHost = "localhost"
proxyPort = 8181
}
https {
proxyHost = "localhost"
proxyPort = 8181
}
}
You can use the systemProp. prefix to add any system properties to Lazybones, similar to the way it works in Gradle.

Is that what You're looking for? Basically You need to add some properties to gradle.properties file.

I am using Cygwin on Windows and I have modified the last line of
~/.gvm/lazybones/current/bin/lazybones
to say
exec "$JAVACMD" "${JVM_OPTS[#]}" -classpath "$CLASSPATH" "-Dhttp.proxyHost=127.0.0.1" "-Dhttp.proxyPort=8888" "-Dhttp.nonProxyHosts=localhost|127.0.0.1" uk.co.cacoethes.lazybones.LazybonesMain "$#"
Please note the quotes around the options. It works very well with my local Fiddler installation.
I have found no better way to enable proxy support due to the way the script is using eval. Maybe a more experienced shell script programmer can come up with a more elegant solution.

I was able to get out through the proxy setting the environment settings of
Picked up JAVA_TOOL_OPTIONS: -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8080
-Dhttp.nonProxyHosts="lmig.com" -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=8080
unfortunately my environment requires authentication so I couldn't provide the complete proxy this way. I first ran "OWASP Zed Attach Proxy (ZAP)" which allowed me to run a proxy on my own machine (at port 8080) which then provided the complete authentication required.
This was able to then run the complete "lazybones list" command which retrieved the contents of the respositories.
Unfortunately I was not able to create an application from those templates becuase bintray required a login (though an anonymous login would do) and couldn't seem to get an additional level of authentication (I received "Unauthorized" from bintray)

Related

Configuring Azure PostgreSQL in Gitlab EE

I am searching for some help in how to configure Azure PostgreSQL DB in a Docker Swarm based Gitlab instance.
Initially, I followed the documentation in https://docs.gitlab.com/13.6/ee/administration/postgresql/external.html. Yet I came to find out that the default provided user is in the form of username, whereas Azure requires it to be in the form of username#hostname. I tried passing the username in the gitlab.rb file (gitlab_rails['db_username'] = 'username#hostname') but it still failed, even after replacing the # with the %40 as URI encoded.
After some extensive searching, I found this documentation - https://docs.gitlab.com/13.6/ee/administration/environment_variables.html, which suggests using the DATABASE_URL environment variable to set the full connection string in the form postgresql://username:password#hostname:port/dbname, which I did and it did solve the issue for Gitlab itself communicating with Azure PostgreSQL (in this case I replaced the username with username%40hostname, according to Azure requirements).
Allas, the success was short lived since then I came to find out that neither Puma and Sidekiq can connect to the database, always throwing the following error:
==> /var/log/gitlab/sidekiq/current <==
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?
After some searching, I found that gitlab-ctl is generating the following file when starting the Gitlab instance:
# This file is managed by gitlab-ctl. Manual changes will be
# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
# and run `sudo gitlab-ctl reconfigure`.
production:
adapter: postgresql
encoding: unicode
collation:
database: <database>
username: "<username>"
password:
host: "/var/opt/gitlab/postgresql"
port: 5432
socket:
sslmode:
sslcompression: 0
sslrootcert:
sslca:
load_balancing: {"hosts":[]}
prepared_statements: false
statement_limit: 1000
connect_timeout:
variables:
statement_timeout:
(database and username where removed)
Pretty much it ignores the DATABASE_URL env variable and assumes the now non-existing configuration parameters in gitlab.rb.
So, right now, I'm a bit out of options and was wondering if anyone has had a similar issue and, if so, how where you able to overcome this.
Any help is appreciated.
Thanks in advance.
TL/DR: Pass the username#hostname string directly into the gitlab_rails['db_username'] in double quotes. The documentation for connecting to an Azure PostgreSQL in the official Gitlab page is not correct.
So, after some searching and going deep into the Gitlab configuration, I came to find out that the issue is very specific and related with the usage of docker secrets.
In my gitlab.rb configuration file, in the database configuration part, I'm using the following:
### GitLab database settings
###! Docs: https://docs.gitlab.com/omnibus/settings/database.html
###! **Only needed if you use an external database.**
gitlab_rails['db_adapter'] = "postgresql"
gitlab_rails['db_encoding'] = "unicode"
gitlab_rails['db_database'] = File.read('/run/secrets/postgresql_database')
gitlab_rails['db_username'] = File.read('/run/secrets/postgresql_user')
gitlab_rails['db_password'] = File.read('/run/secrets/postgresql_password')
gitlab_rails['db_host'] = File.read('/run/secrets/postgresql_host')
gitlab_rails['db_port'] = File.read('/run/secrets/postgresql_port')
gitlab_rails['db_sslmode'] = 'require'
Now, this exact configuration was used previously for testing purposes and worked (but without the usage of Azure PostgreSQL database). And I'm passing the correct secrets to docker and I've confirmed that the secrets in fact, do exist.
(Sidenote: Also, I've established that Gitlab uses the method ActiveRecord::Base.establish_connection from the Ruby ActiveRecord::Base library in order to connect to the database)
Yet, when using the username#hostname configuration for the user and passing that into the postgresql_user secret, suddenly the ActiveRecord::Base.establish_connection method assumes that the #hostname is the actual hostname to where I want to connect to. And I've confirmed that the secret is being generated correctly inside the docker container
Now, it gets even stranger because if I pass the username#hostname string directly to the gitlab.rb file - gitlab_rails['db_username'] parameter - in double quotes, it suddenly starts connecting without complaining.
So, in short, if using an Azure PostgreSQL database for a dockerized Gitlab instance and using secrets to pass the configuration to the gitlab.rb file, don't pass the username#hostame through a secret, but put it directly in the gitlab.rb file.
I don't know if this is a specific issue of Ruby or of Gitlab (I'm not a Ruby developer), but I did try converting the File.read output to a String, to a symbol, used the File.open('filepath', &:readline) and other shenanigans, but nothing worked. So, if anyone out there would care to add their reason for this, please feel free to do so.
Also, the tutorial provided by Azure - https://learn.microsoft.com/pt-pt/azure/postgresql/connect-ruby - doesn't work with Gitlab, since it complains about the %40.
Hope this can help anyone out there.

FreeBSD and HTTP Basic Authorization request for pkg install/update

I set up a host for custom FreeBSD ports and I keep it HTTP Basic Auth and the problem associated with it.
You can see my pkg conf below, the question is: How do I add a user name and password to it for HTTP Basic Auth?
I already know username:password#hostname.tld usage but I'm looking for something more like
Header("Authorization", "Basic YWRtaW46YWRtaW4zMjE")
how can I do that ? or you can suggest a better way to keep custom ports away from prying eyes :)
FreeBSD: {
url: "pkg+http://pkg.MyCustomHost.tld/${ABI}/latest",
mirror_type: "srv",
priority: 11,
enabled: yes
}
Thank you.
pkg uses fetch(3) for fetching as documented in the manpage you can use ENVIRONMENT variables like HTTP_AUTH and HTTP_PROXY_AUTH

How to use the ChromeApp to connect to a node.js server?

I have a Node.js server and I'd like to know how I could do for the ChromeApp to work with it. I tried putting "http://localhost:3000" (server address) on the runtime:
chrome.app.runtime.onLaunched.addListener(function () {
chrome.app.window.create('http://localhost:3000');
});
But it doesn't even launch. Does someone have an idea on what I could do?
Thanks.
You cannot launch external URLs with chrome.app.window.create. In fact if you check the chrome.runtime.lastError property you will see the following error:
The URL used for window creation must be local for security reasons.
I suggest you look into using the <webview> tag as it is much more appropriate for your use-case.

Localization file path error when using tap-i18n with meteor

I am running meteor inside a folder, like this
ROOT_URL="http://localhost:3000/registration" meteor
Also, i am using tap:i18n package for internationalisation support. The problem is that tap_i18n doesn't update the url for the localisation files and still makes request to http://localhost:3000/tap-i18n/en-US.json which is not a valid address, and hence throws 404 error. It should make request to http://localhost:3000/registration/tap-i18n/en-US.json. Notice the registration folder that was passed via ROOT_URL while starting meteor.
How can i tell tap_i18n package to honor ROOT_URL?
Ranjan,
I've setup a small demo project with some explanations on how to achieve your configuration. Please let me know if you could solve your issue.
How to configure tap:i18n with custom ROOT_URL
Check the configuration, you can set the i18n_files_route parameter
Configuring tap-i18n
To configure tap-i18n add to it a file named project-tap.i18n.
This JSON can have the following properties. All of them are optional.
The values bellow are the defaults.
project-root/project-tap.i18n
----------------------------- {
"helper_name": "_",
"supported_languages": null,
"i18n_files_route": "/tap-i18n",
"cdn_path": null
}
Source link for configuration

How to change Hybris server's port

The default port is http://localhost:9001.
How do I run the hybris platform using another port?
Edit your {HYBRIS_ROOT_DIR}/config/local.properties file and use the following properties to configure the various ports:
tomcat.http.port=9001
tomcat.ssl.port=9002
tomcat.ajp.port=8009
tomcat.jmx.port=9003
tomcat.jmx.server.port=9004
You can find the complete configuration reference on the Hybris wiki here: https://wiki.hybris.com/display/release5/Configuration+Properties+Reference
In order for the changes to be applied you must run ant and restart Hybris.
You can run ant all, but if you have only changed the configuration you can deploy these changes without having to re-compile by using ant deploy which is much faster.
Create a /config/local.properties file with this content:
tomcat.http.port=9101
tomcat.ssl.port=9102
tomcat.ajp.port=8109
tomcat.jmx.port=9103
tomcat.jmx.server.port=9104
Then you'll get Hybris server to run on http://localhost:9101.
If you change the port, make sure you update the spring security port-mappings (should be already using the configuration service and these properties via Spring EL to do this if you're on a recent version of hybris), and, for local development, the site URL resolution (website.<x>.http(s), media.<x>.http(s)) properties and the CMS Site URL mapping regular expressions (ImpEx or hMC). There's also a property for jvdbc I think.
You can change these in the config/local.properties, platform/project.properties or a custom extension's project.properties. The local.properties file has the highest priority (if the property is defined in multiple places), then the custom extension's project.properties, and finally in the platform's project.properties.
In addition to the above configuration provided by Zathrus Writer. You might have to add the solr port configuration to have say two instances of hybris running in the same server.
solrserver.instances.default.port=8986
Full configuration:
tomcat.http.port=9201
tomcat.ssl.port=9202
tomcat.ajp.port=8209
tomcat.jmx.port=9203
tomcat.jmx.server.port=9204
solrserver.instances.default.port=8986
You can use this as well
hybris.instance.id=60
tomcat.http.port=9${hybris.instance.id}1
tomcat.ssl.port=9${hybris.instance.id}2
tomcat.jmx.port=9${hybris.instance.id}3
tomcat.debug.port=9${hybris.instance.id}0
tomcat.jmx.server.port=9${hybris.instance.id}4
tomcat.ajp.port=9${hybris.instance.id}5
Override port configurations in {HYBRIS_ROOT_DIR}/config/local.properties file.
tomcat.http.port=9011
tomcat.ssl.port=9012
tomcat.ajp.port=8019
tomcat.jmx.port=9013
tomcat.jmx.server.port=9014
In addition to the port we can also override xmx values of JVM in tomcat.generaloptions configurations in config/local.properties as listed below.
tomcat.generaloptions=-Xmx6G -XX:MaxPermSize=300M -ea -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dorg.tanukisoftware.wrapper.WrapperManager.mbean=true -Djava.endorsed.dirs="%CATALINA_HOME%/lib/endorsed" -Dcatalina.base=%CATALINA_BASE% -Dcatalina.home=%CATALINA_HOME% -Dfile.encoding=UTF-8 -Dlog4j.configuration=log4j_init_tomcat.properties -Djava.util.logging.config.file=jdk_logging.properties -Djava.io.tmpdir="${HYBRIS_TEMP_DIR}"
In addition, you may face with another port issue cause debug port.
You should also change it.
Please use;
tomcat.debugjavaoptions=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=8001,suspend=n
As SAP Hybris runs on tomcat server, we can run as many servers as needed simultaneously based on our memory.
We need to configure in config/local.properties
To run tomcat in different port
tomcat.http.port=6001
tomcat.ssl.port=6002
tomcat.ajp.port=6009
tomcat.jmx.port=6003
tomcat.jmx.server.port=6004
os.rmiregistry.port=3198
website.electronics.http=http://electronics.local:6001/yacceleratorstorefront
website.electronics.https=https://electronics.local:6002/yacceleratorstorefront
website.apparel-de.http=http://apparel-de.local:6001/yacceleratorstorefront
website.apparel-de.https=https://apparel-de.local:6002/yacceleratorstorefront
website.apparel-uk.http=http://apparel-uk.local:6001/yacceleratorstorefront
website.apparel-uk.https=https://apparel-uk.local:6002/yacceleratorstorefront
website.powertools.http=http://powertools.local:6001/yb2bacceleratorstorefront
website.powertools.https=https://powertools.local:6002/yb2bacceleratorstorefront
To Run Solr in separate port
solrserver.instances.default.port=6983
To have debug in separate port
tomcat.debugjavaoptions=-Djava.locale.providers=COMPAT,CLDR -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=6000,suspend=n

Resources