I found that there is support for sublime for nixos : https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/sublime/default.nix .
I cannot figure it out how to install it though.
I was following these instructions without success : https://nixos.org/wiki/Nix_Installing_Packages
I also tried this :
git remote add channels git://github.com/NixOS/nixpkgs-channels.git
but it did not help.
Using nix without NixOS
cat ~/.nixpkgs/config.nix
{
allowUnfree = true;
}
nix-env -i sublime
On NixOS
cat /etc/nixos/configuration.nix
...
{ config, pkgs, ... }:
{
# ...
environment.systemPackages = with pkgs; [
sublime
];
nixpkgs.config = {
allowUnfree = true;
};
}
sudo nixos-rebuild switch --upgrade
I hope you have done this.
$ nix-channel --add http://nixos.org/channels/nixpkgs-unstable
$ nix-channel --update
or just
nix-env --install sublime
and please let me if it works? if it doesn't
then I have tried searching here https://nixos.org/nixos/packages.html
I'm not able to find sublime there.
I would suggest you follow this to install sublime.
Related
This question already has answers here:
if statement and calling function in if using bash
(2 answers)
Closed 3 years ago.
I have a the function is_mysql_db() to identify if the installed database in the server is a mysql server. So ideally the code in main body should call the function to determine whether I should consider this server a mysql server or not.
I tried at the end of the function to put double brackets, single "=", using or not variable for comparison. I am honestly out of ideas and I would like this code to look as clear as possible as this is only a small part of it.
Below my sample code:
#!/bin/bash
is_mysql_db(){
yum_mysql_out=$(yum list installed | grep mysql-community | awk '{ print $1 }' | tail -n1)
[ $yum_mysql_out == "mysql-community-server.x86_64" ]
}
if [ is_mysql_db ]
then
echo "Installed"
else
echo "Not Installed"
fi
I would expect if the MySQL yum package is installed to detect it and return the package is installed and if its not to return Not Installed. Simple but not that much apparently.
It's not the shell function that is wrong, it's your call to it.
Putting a string inside square brackets does not run that command, it just tests that the string itself is non-empty.
Don't put the function in the square brackets, and it will run it as a command.
Example:
$ if [ false ] ; then echo "false is true??"; else echo "false is false as expected" ; fi
false is true??
$ if false ; then echo "false is true??"; else echo "false is false as expected" ; fi
false is false as expected
By the way, your function could be simpler:
is_mysql_db(){
yum list installed | grep -q mysql-community-server
}
Or even use rpm directly, so yum doesn't re-load its package indexes:
is_mysql_db(){
rpm --quiet -q mysql-community-server
}
I'm working on Fedora x86_64. It uses /lib64, /usr/lib64 and friends. I have the following *.pc.in file:
$ cat libcryptopp.pc.in
prefix=#prefix#
exec_prefix=#exec_prefix#
libdir=#libdir#
includedir=#includedir#
...
My config.site has the following. It was copied from Fedora's config.site at /usr/share/config.site. The copy was used because of config.site for vendor libs on Fedora x86_64.
$ cat /usr/local/share/config.site
...
# Note: This file includes also RHEL/Fedora fix for installing libraries into
# "/lib/lib64" on 64bit systems.
if test -n "$host"; then
# skip when cross-compiling
return 0
fi
if test "$prefix" = /usr \
|| { test "$prefix" = NONE && test "$ac_default_prefix" = /usr ; }
then
test "$sysconfdir" = '${prefix}/etc' && sysconfdir=/etc
test "$sharedstatedir" = '${prefix}/com' && sharedstatedir=/var
test "$localstatedir" = '${prefix}/var' && localstatedir=/var
ARCH=`uname -m`
for i in x86_64 ppc64 s390x aarch64; do
if test $ARCH = $i; then
test libdir='${exec_prefix}/lib64'
break
fi
done
fi
However, after Autoconf processes my *.pc.in file:
$ autoreconf --install --force
...
$ ./configure
...
$ cat libcryptopp.pc
prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
...
Notice libdir=${exec_prefix}/lib, and not libdir=${exec_prefix}/lib64.
GCC is definitely building 64-bit binaries for the package. I did not add -mx32 or -m32:
$ gcc -dumpmachine
x86_64-redhat-linux
Why is the wrong lib/ directory being used, and how do I fix it?
The /usr/local/share/config.site is wrong. Though it was copied from Fedora's config.site and placed in /usr/local/share, the prefix directories are wrong. The prefix test should use /usr/local and not /usr.
Below is the corrected one.
$ cat /usr/local/share/config.site
...
if test -n "$host"; then
# skip when cross-compiling
return 0
fi
if test "$prefix" = /usr/local \
|| { test "$prefix" = NONE && test "$ac_default_prefix" = /usr/local ; }
then
test "$sysconfdir" = '${prefix}/etc' && sysconfdir=/etc
test "$sharedstatedir" = '${prefix}/com' && sharedstatedir=/var
test "$localstatedir" = '${prefix}/var' && localstatedir=/var
ARCH=`uname -m`
for i in x86_64 ppc64 s390x aarch64; do
if test $ARCH = $i; then
test "$libdir" = '${exec_prefix}/lib' && libdir='${exec_prefix}/lib64'
break
fi
done
fi
Now, the next question is, why Fedora's /usr/share/config.site is not handling prefix=/usr/local properly. That's an open question at Issue 1510073 : Autoconf does not honor libdir in config.site for "libdir=#libdir#" in *.pc file, which has been closed as NOT A BUG.
We have ambari cluster , and clients are installed on Linux redhat machines ,
yum list | grep ambari-server
ambari-server.x86_64 2.5.0.3-7 #ambari-2.5.0.3
We found a nice way to set a update a value's in ambari cluster as the following:
Update a parameter ( from Ambari server machine )
/var/lib/ambari-server/resources/scripts/configs.sh set localhost c1 mapred-site "mapreduce.map.memory.mb" "512"
While:
CONFIG_TYPE = mapred-site
CONFIG_KEY = mapreduce.map.memory.mb
But we have a little problem here.....:
From my example - mapred-site is a “CONFIG-TYPE”
According to the script –help:
<CONFIG_TYPE>: One of the various configuration types in Ambari. Ex:global, core-site, hdfs-site, mapred-queue-acls, etc.
So how to know the right CONFIG_TYPE value for the CONFIG_KEY value ?,
For more info about the script:
https://cwiki.apache.org/confluence/display/AMBARI/Modify+configurations “Edit configuration using configs.sh” paragraph
remark - in order to see all CONFIG-TYPE values and CONFIG_KEY values I generated the following blueprint.json file:
curl -u admin:admin -H "X-Requested-By: ambari" -X GET http://101.16.235.2:8080/api/v1/clusters/HDP01?format=blueprint -o /tmp/blueprint.json
.
grep "\-site" /tmp/blueprint.json
"tez-interactive-site" : {
"hdfs-site" : {
"yarn-site" : {
"hiveserver2-site" : {
"ams-hbase-security-site" : {
"ams-site" : {
"mapred-site" : {
"hive-site" : {
"tez-site" : {
"webhcat-site" : {
You may also clone Ambari repo, and grep/parse configuration files like
https://github.com/apache/ambari/blob/trunk/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/configuration/core-site.xml
Per-stack configurations like https://github.com/apache/ambari/blob/trunk/ambari-server/src/main/resources/stacks/HDP/2.6/services/HDFS/configuration/core-site.xml inherit/override values from common-services and previous stack versions.
Hope this helps
I want to add the contents of a shell script into the body of pkg_preinst_${PN} or pkg_postinst_${PN} function (BitBake recipe of a software package).
For example, let's consider this "PREINST" shell script:
$ cat PREINST
#! /bin/sh
chmod +x /usr/bin/mybin
Executing a simple 'cat' command inside pkg_preinst function doesn't work:
pkg_preinst_${PN}() {
cat ${S}/path/to/PREINST
}
In this way, the contents for the .spec file for the generated rpm package are not the expected:
%pre
cat /Full/Path/To/Variable/S/path/to/PREINST
As you can see, %pre section doesn't include real contents of PREINST file, just includes the 'cat' command.
Is it possible to include the contents of PREINST file into the generated .spec file in some way?
Thank you in advance!
Finally I solved this issue by prepending this code to the do_package task:
do_package_prepend() {
PREINST_path = "${S}/${MYMODULE}/PREINST"
POSTINST_path = "${S}/${MYMODULE}/POSTINST"
PREINST = open(PREINST_path, "r")
POSTINST = open(POSTINST_path, "r")
d.setVar("pkg_preinst", PREINST.read())
d.setVar("pkg_postinst", POSTINST.read())
}
It modifies "pkg_preinst" and "pkg_postinst" keys in 'd' global dictionary with the content of each PREINST and POSTINST file as value. Now it works! :)
I have 2 environments variables :
echo $FRONT1_PORT_8080_TCP_ADDR # 172.17.1.80
echo $FRONT2_PORT_8081_TCP_ADDR # 172.17.1.77
I want to inject them in a my default.vcl like :
backend front1 {
.host = $FRONT1_PORT_8080_TCP_ADDR;
}
But I got an syntax error on the $ char.
I've also tried with user variables but I can't define them outside vcl_recv.
How can I retrieve my 2 values in the VCL ?
I've managed to parse my vcl
backend front1 {
.host = ${FRONT1_PORT_8080_TCP_ADDR};
}
With a script:
envs=`printenv`
for env in $envs
do
IFS== read name value <<< "$env"
sed -i "s|\${${name}}|${value}|g" /etc/varnish/default.vcl
done
Now you can use the VMOD Varnish Standard Module (std) to get environment variables in the VCL, for example:
set req.backend_hint = app.backend(std.getenv("VARNISH_BACKEND_HOSTNAME"));
See documentation: https://varnish-cache.org/docs/trunk/reference/vmod_std.html#std-getenv
Note: it doesn't work for backend configuration, but could work elsewhere. Apparently backends are expecting constant strings and if you try, you'll get Expected CSTR got 'std.fileread'.
You can use the fileread function of the std module, and create a file for each of your environment variables.
before running varnishd, you can run:
mkdir -p /env; \
env | while read envline; do \
k=${envline%%=*}; \
v=${envline#*=}; \
echo -n "$v" >"/env/$k"; \
done
And then, within your varnish configuration:
import std;
...
backend front1 {
.host = std.fileread("/env/FRONT1_PORT_8080_TCP_ADDR");
.port = std.fileread("/env/FRONT1_PORT_8080_TCP_PORT");
}
I haven't tested it yet. Also, I don't know if giving a string to the port configuration of the backend would work. In that case, converting to an integer should work:
.port = std.integer(std.fileread("/env/FRONT1_PORT_8080_TCP_PORT"), 0);
You can use use echo to eval strings.
Usually you can do something like:
VAR=test # Define variables
echo "my $VAR string" # Eval string
But, If you have the text in a file, you can use "eval" to have the same behaviour:
VAR=test # Define variables
eval echo $(cat file.vcl) # Eval string from the given file
Sounds like a job for envsubst.
Just use standard env var syntax in your config $MY_VAR and ...
envsubst < myconfig.tmpl > myconfig.vcl
You can install with apt get install gettext in Ubuntu.