This can modify all PRODUCT_BUNDLE_IDENTIFIER to abc. However, how can i modify for these two iOS identifier an watchOS identifier with a different values?
sed -i -e "s/PRODUCT_BUNDLE_IDENTIFIER =.*/PRODUCT_BUNDLE_IDENTIFIER" = abc;/g" text.txt
{
2D02E400000000001C7 /* iOS Identifier */ = {
isa = XCBuildConfiguration;
buildSettings = {
PRODUCT_BUNDLE_IDENTIFIER = "com.iOS";
};
name = Debug;
};
2D02E000000000051C7 /* Apple Watch OS Identifier */ = {
isa = XCBuildConfiguration;
buildSettings = {
PRODUCT_BUNDLE_IDENTIFIER = "com.watchOS";
};
name = Debug;
};
}
That would be a bit more involved. There might be only a way to do it only with sed, but this is the quick hack i could come up with:
id='2D02E400000000001C7'
repl='abc'
if grep -q "$id" file; then
id_lineno=$(cat -n file | grep "$id" | awk '{ print $1 }')
sed_lineno=$((id_lineno+3))
sed -i "${sed_lineno}s/PRODUCT_BUNDLE_IDENTIFIER =.*/PRODUCT_BUNDLE_IDENTIFIER = ${repl};/" file
fi
It assumes the whitespace is exactly the same as shown in your code block
Related
I've not been able to find article or tutorial described the topic.
Thus, my question is how to integrate AxoCover with Jenkins:
Mark build failed or secussefful in accordance of code coverage percentage
Sent email with notification to specific users
Thanks in advance
So, in general i founded out solution in creating powershell script and executing it during the jenkins job:
<#
.SYNOPSIS
Runs NUnit unit tests in given Visual Studio solution and provides code coverage result
Duplicate for CodeCoverageRunner fix for NUnit 3.
https://github.com/nunit/nunit-console/issues/117
.PARAMETER TestConfig
{
"SolutionFile": "\\project.sln",
"BuildConfiguration": "Debug",
"TestResultDirectory": "\\tempFolder",
"TestRunnerPath": "\\nunit3-console.exe",
"CodeCoverageToolPath" : "\\OpenCover.Console.exe",
"ReportGeneratorPath": "\\ReportGenerator.exe",
"AssemblyFilters": "+[*]*"
}
#>
$config = ConvertFrom-Json $TestConfig
$testRunnerArgs = GetTestProjects `
-SolutionFile $config.SolutionFile `
-BuildConfiguration $config.BuildConfiguration
$workingDirectory = $config.TestResultDirectory
$testRunner = $config.TestRunnerPath
$codeCoverageTool = $config.CodeCoverageToolPath
$reportGenerator = $config.ReportGeneratorPath
$filters = $config.AssemblyFilters
$coverageResult = Join-Path $workingDirectory "codecoverage.xml"
& $codeCoverageTool -target:"""$testRunner""" `
-targetargs:"""$testRunnerArgs --inprocess $("-result","test_result.xml")""" `
-register:Administrator `
-mergebyhash `
-skipautoprops `
-output:"""$coverageResult""" `
-filter:"""$filters""" `
-returntargetcode
if($LASTEXITCODE -ne 0){
exit $LASTEXITCODE
}
$targetDir = Join-Path $workingDirectory "CodeCoverage"
$historyDir = Join-Path $workingDirectory "CoverageHistory"
& $reportGenerator `
-reports:$coverageResult `
-targetDir:"""$targetDir""" `
-historydir:"""$historyDir"""
function GetTestProjects
{
param (
[Parameter(Mandatory=$true)]
[string]$SolutionFile,
[Parameter(Mandatory=$true)]
[string]$BuildConfiguration
)
$BaseDir = (get-item $solutionFile).Directory
$Projects = #()
Get-Content -Path $SolutionFile | % {
if ($_ -match '\s*Project.+=\s*.*,\s*\"\s*(.*Tests\.Unit.*proj)\s*\"\s*,\s*') {
$currentName = $matches[1].Split("\")[0]
$currentDll = $matches[1].Split("\")[1].Replace(".csproj",".dll")
#Write-Host "current $currentName"
$Projects += "`"", $(Join-Path -Path $BaseDir $currentName), "\bin\$BuildConfiguration\$currentDll" ,"`"" -join ""
}
}
return $Projects
}
I've just started playing with NixOS, and have so far managed to edit /etc/nixos/configuration.nix in my NixOS 18.09 VM to have PHP-FPM and the Caddy webserver enabled.
{ config, pkgs, ... }:
{
imports = [ <nixpkgs/nixos/modules/installer/virtualbox-demo.nix> ];
users = {
mutableUsers = false;
groups = {
caddy = { };
php-project = { };
};
users = {
hello = {
group = "php-project";
};
};
};
environment.systemPackages = [
pkgs.htop
pkgs.httpie
pkgs.php # for PHP CLI
];
services.caddy = {
enable = true;
email = "david#example.com";
agree = true;
config = ''
(common) {
gzip
header / -Server
header / -X-Powered-By
}
:8080 {
root /var/www/hello
fastcgi / /run/phpfpm/hello.sock php
log syslog
import common
}
'';
};
services.phpfpm = {
phpOptions = ''
date.timezone = "Europe/Berlin"
'';
poolConfigs = {
hello = ''
user = hello
listen = /run/phpfpm/hello.sock
; ...
pm.max_requests = 500
'';
};
};
}
A PHP-processed response is available at at localhost:8080. (Yay!)
To enable Caddy plugins when compiling from source, Go imports are added to caddy's run.go, e.g.:
_ "github.com/mholt/caddy/caddyhttp" // plug in the HTTP server type
// This is where other plugins get plugged in (imported)
_ "github.com/nicolasazrak/caddy-cache" // added to use another plugin
)
How can I set such line insertion to be performed after the source is downloaded and before the build takes place? (If this is a reasonable approach when using Nix?)
The NixOS 18.09 caddy package.
The NixOS 18.09 caddy service.
I believe that when writing a package a builder script (Bash or otherwise) can be assigned, and I'm thinking the line insertion could be done in it. But I'm lost as to how to assign a script to an existing package in this situation (override an attribute/use an overlay?) and where to put the script on the disk.
Status update
I've been doing some reading on customising packages in general and it sounds like overlays might be what I need. However, I don't seem to be able to get my overlay evaluated.
I'm using overriding of the package name as a test as it's simpler than patching code.
Overlay attempt 1
/etc/nixos/configuration.nix:
{ config, pkgs, options, ... }:
{
imports = [ <nixpkgs/nixos/modules/installer/virtualbox-demo.nix> ];
nix.nixPath = options.nix.nixPath.default ++ [
"nixpkgs-overlays=/etc/nixos/overlays-compat/"
];
# ...
}
/etc/nixos/overlays-compat/overlays.nix:
self: super:
with super.lib;
let
# Using the nixos plumbing that's used to evaluate the config...
eval = import <nixpkgs/nixos/lib/eval-config.nix>;
# Evaluate the config,
paths = (eval {modules = [(import <nixos-config>)];})
# then get the `nixpkgs.overlays` option.
.config.nixpkgs.overlays
;
in
foldl' (flip extends) (_: super) paths self
/etc/nixos/overlays-compat/caddy.nix:
self: super:
{
caddy = super.caddy.override {
name = "caddy-override";
};
}
Overlay attempt 2
/etc/nixos/configuration.nix:
nixpkgs.overlays = [ (self: super: {
caddy = super.caddy.override {
name = "caddy-override";
};
} ) ];
error: anonymous function at /nix/store/mr5sfmz6lm5952ch5q6v49563wzylrkx-nixos-18.09.2327.37694c8cc0e/nixos/pkgs/servers/caddy/default.nix:1:1 called with unexpected argument 'name', at /nix/store/mr5sfmz6lm5952ch5q6v49563wzylrkx-nixos-18.09.2327.37694c8cc0e/nixos/lib/customisation.nix:69:12
overrideAttrs
I previously managed to override the package name with this:
{ config, pkgs, options, ... }:
let
caddyOverride = pkgs.caddy.overrideAttrs (oldAttrs: rec {
name = "caddy-override-v${oldAttrs.version}";
});
in {
{
# ...
services.caddy = {
package = caddyOverride;
# ...
}
}
I could see in htop that the caddy binary was in a folder called /nix/store/...-caddy-override-v0.11.0-bin/. But I understand that overriding in this way has been superseded by overlays.
In order to add plugins to Caddy, it seems that the method is to modify the source.
You will need to adapt the Nixpkgs expression for Caddy to make that possible. That can be done outside the Nixpkgs tree, using services.caddy.package = callPackage ./my-caddy.nix {} for example, or by forking the Nixpkgs repository and pointing your NIX_PATH to your clone.
There is an issue for Caddy plugins: https://github.com/NixOS/nixpkgs/issues/14671
PR welcome!
In order to migrate from icinga1 to icinga2, I'm basically concerned about the NRPE custom checks, till the time i tried to add just the basic memory check using NRPE.
With command line everything seems to be fine and perfect.
/usr/lib64/nagios/plugins/check_nrpe -H 192.186.113.45 -p 5666 -c CheckMEM -a MaxWarn=80% MaxCrit=90% ShowAll=long type=physical
Output:
OK: physical memory: Total: 64G - Used: 4.69G (7%) - Free: 59.3G (93%)|'physical memory %'=7%;80;90 'physical memory'=4.687G;51.174;57.57;0;63.967
But when I tried to apply the same with ICINGAweb2 it doesn't work well.
It simply gives me the error there as
Unknown argument: -c
Below are the configurations for the command i tried to create as a beginner.
My command.conf file has certain part defined for the same specific check
object CheckCommand "nrpe-check-1arg" {
import "plugin-check-command"
command = [PluginDir + "/check_nrpe" ]
arguments = {
"-H" = "$host$"
"-p" = "$port$"
"-c" = "$check$"
"-a" = "$argument$"
}
}
and my hostfile.conf contains
object Host "RenamedHost" {
address = "192.186.113.45"
check_command = "hostalive"
vars.os = "windows"
}
object Service "NRPE check load" {
import "generic-service"
host_name = "RenamedHost"
check_command = "nrpe-check-1arg"
vars.host = "132.186.119.45"
vars.port = "5666"
vars.check = "CheckMem"
vars.argument = "MaxWarn=80% MaxCrit=90% ShowAll=long type=physical"
}
What am I doing wrong ??
You will be able to pass the argument into nrpe.cfg as
vars.arguments = "80%!90%!long!physical"
And in command CheckMEM in remote machine you can specify the argument as
MaxWarn=$ARG1$ MaxCrit=$ARG2$ ShowAll=$ARG3$ type=$ARG4$
Hi,
I have the following files in a directory called content: index.php, page1.php, page2.php and page3.php ONLY.
Then I have this code:
$column = scandir("content");
foreach ($column as $value) {
$stvalue = str_replace(".php", "", $value);
echo "<div>$stvalue</div>";
}
Nevertheless, this is what I get:
<div>.</div>
<div>..</div>
<div>index</div>
<div>page1</div>
<div>page2</div>
<div>page3</div>
Whats with the first 2 elements? I dont have files named like that so I dont get it.
Thank you.
. - is a special directory referencing the current directory.
.. - is also a special directory and its referencing the parent directory.
To remove the special directories I can think of some options:
1.
foreach(glob("*.php") as $filename) {
echo "<div>$filename</div>";
}
2.
$files = array_diff(scandir("content"), array('..', '.'));
foreach($files as $file) { ... }
3.
foreach ($files as $file) {
if($file != '.' and $file != '..') { ... }
}
All of the above are alternatives. You don't need to use scandir() if you use glob() and vice versa. glob() - expects a pattern. It is possible to also provide it with the path like this:
glob("[path]/*.php") - this will list any php file located in path. glob() documentation can be found here PHP - glob()
$column = scandir("content");
foreach ($column as $value) {
$stvalue = str_replace(".php", "", $value);
if($stvalue != '.' || $stvalue != '..') {
echo "<div>$stvalue</div>";
}
}
. refers to the current directory. .. refers to the parent directory.
This is why typing cd .. on a command prompt will change to the parent directory. It's been this way in DOS, every version of Windows, Mac OS X, it's not just Linux and UNIX variants.
If you don't want to display them on your page, just skip the first two entries using array_slice.
I would like to see all files that are locked. so far, I've only found to use tf.exe status and look for anything with '!' because they are not reported as "lock, edit" as they are in the UI. Any ideas? thanks.
If you have the power tools installed, it's a one-liner:
tfstatus . -r -user * | % { $_.pendingchanges } | ? { $_.islock } | select -unique serveritem
If you prefer GUIs to scripts, try TFS Sidekicks.
If you are trying to use TFS Sidekicks, and can't figure out how, it is under Tools, Team Foundation Sidekicks, Status Sidekick. You will need to expand that window, but you will then be able to search for locks for a username.
I don't think this is possible using tf.exe or even tfpt.exe (The Power Tool command line). You'll need to look through the pending changesets for changes that are locks. You could do this in powershell using the Power Tool commandlets or you could do it using the following bit of .NET code that exercises the TFS API:
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;
namespace TfsApiExample
{
class Program
{
static void Main(string[] args)
{
GetLockedFiles("http://tfsserver:8080","$/TeamProject");
}
private static void GetLockedFiles(string serverUrl, string serverPath)
{
TeamFoundationServer tfs = new TeamFoundationServer(serverUrl);
VersionControlServer vcServer = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
// Search for pending sets for all users in all
// workspaces under the passed path.
PendingSet[] pendingSets = vcServer.QueryPendingSets(
new string[] { serverPath },
RecursionType.Full,
null,
null);
Console.WriteLine(
"Found {0} pending sets under {1}. Searching for Locks...",
pendingSets.Length,
serverPath);
foreach (PendingSet changeset in pendingSets)
{
foreach(PendingChange change in changeset.PendingChanges)
{
if (change.IsLock)
{
// We have a lock, display details about it.
Console.WriteLine(
"{0} : Locked for {1} by {2}",
change.ServerItem,
change.LockLevelName,
changeset.OwnerName);
}
}
}
}
}
}
from your command prompt
>powershell
Then from powershell do:
PS > tf info * -recursive | &{
begin{
$out=#{}
$prefix = "loc"
}
process{
if ($_ -match "Local information"){
if ($out.Count -gt 0) {
[pscustomobject]$out
$out=#{}
$prefix = "loc"
}
} ElseIf ($_ -match "Server information"){
$prefix = "svr"
} else {
$parts = $_.Split(':')
if ($parts.Length -eq 2){
$out.Add($prefix + $parts[0].Trim(), $parts[1].Trim())
}
}
}
end{
if ($out.Count -gt 0) {
[pscustomobject]$out
}
}
} | where {!($_.svrLock -eq 'none')}
I've found a GUI option.
Start Visual Studio
Open file
Go to source control
Then workspaces
Enter your credentials
Check show remote workspaces
Remove all unwanted workspaces
That simple :)