Friday, September 29, 2017

du calculate totalsize of list of files

Reading list of files and calculate the total size cat /tmp/deletepurg.txt| tr \\n \\0 | du -skh --files0-from=- --total

Friday, September 1, 2017

reading 3 lines in one time in oneliner perl

  cat PDDV_hosts.txt | perl -e 'while (my $frs=<>) { chomp $frs; $sec=<>; chomp $sec; $th=<> ;printf "%s,%s,%s", $frs, $sec, $th; }'

Thursday, July 20, 2017

Sledgehammer with sudo over remote hosts

dsh ls /etc/bashrc | perl -ne 'BEGIN { printf "export ss=\${1};shift;export args=\$@;" }{ $_=~s/://g;@x=split /\s+/;printf "ssh -t %s \"echo \${ss} | sudo -S -u tibcosilver \${args} \"\n",$x[0], $x[2]}' | tee out
perl -i -pe "s/#/'/g" out
echo "Please run: . out [Password]"

Friday, June 2, 2017

TIBCO Obfuscate encypt and decrypt : how to ...

Decrypt.java
import com.tibco.security.ObfuscationEngine;
public class Decrypt {

  public static void main(String[] args) throws Exception {
try {
    System.out.println(ObfuscationEngine.decrypt(args[0]));
} catch (Exception e ) {
}
    System.out.println(ObfuscationEngine.encrypt(args[0].toCharArray()));
  }
}
Compile
javac -cp /opt/tibco/RA1.1/tra/5.9/lib/TIBCrypt.jar  Decrypt.java
Run
java -cp .:/opt/tibco/RA1.1/tra/5.9/lib/TIBCrypt.jar:/opt/tibco/RA1.1/tpcl/5.9/lib/slf4j-log4j12-1.5.2.jar:/opt/tibco/RA1.1/tpcl/5.9/lib/slf4j-api-1.5.2.jar:/opt/tibco/RA1.1/tpcl/5.9/lib/log4j-1.2.15.jar:.  Decrypt "$@"
$ ./run.sh HelloWorld
#!oUNDLWlfuOH60LsUdl/qjrkGRADiglWRuw5Z4mGaUFU=
$ ./run.sh '#!oUNDLWlfuOH60LsUdl/qjrkGRADiglWRuw5Z4mGaUFU='
HelloWorld
#!UsKsGea13VhSx9H+IRO9xrgqRjFQn4RC2n8LybKGyPtgss4cYLwXbKt/Clc++ljpVQsAqhsMJE3sJqk9JY4xJi3LnRXW7rCK/layTvt+xXxqpZB9sX8JjqQUxNn1FrjokjFAKrPTNGM=

Tuesday, May 16, 2017

reconstructing oracle connect string from userenv details

select sys_context('userenv','IP_ADDRESS') || '=' || sys_context('userenv','instance_name')  || '.' || sys_context('userenv','db_domain') from dual;

Wednesday, May 10, 2017

990 mvn versions:set -DnewVersion=1.0.0 997 next_version=1.0.0 999 svn copy . https://conexus.com:9443/subversion/sefs_common/fxs-deploy/tags/${next_version} $svn_opts -m "Tagged by SEFS shared-library. [artf1376420] Release ${next_version}"

Thursday, May 4, 2017

email all users that have exceeded their /home/ size quota with oneliner in du, perl

du -skh /home/* 2> /dev/null | sort -h | perl -pe 'if (/^\d{3}M/){ ($sz,$who) = $_=~ m!(\S+)\s\/home\/[a-z]{1,2}(75\d+)$!mxi;if ($who) {open(MAIL, "|/usr/sbin/sendmail -t");print MAIL "To: $who\@company.com\nFrom: mightymouse\@company.com\nSubject: homedir size exceeds: $sz; please remove items from your /home/ directory on uwb00078\n\nhomedir current size exceeds $sz > 99.9M; please remove items from your /home/ directory on uwb00078!";close(MAIL);print "$who $sz\n"}} $_=undef'

Monday, May 1, 2017

Syntax for Maven / Eclipse Lifecycle mapping

New syntax for specifying lifecycle mapping metadata

A new syntax has been introduced to simplify lifecycle mapping metadata for plugin executions, using processing instructions within plugin/executions/execution nodes.
processing instructions for lifecycle mapping
Supported syntax:
  • <?m2e ignore?> this execution will be ignored;
  • <?m2e execute?> this execution will be executed once on project import;
  • <?m2e execute onConfiguration?> this execution will be executed on every Project Configuration update;
  • <?m2e execute onIncremental?> this execution will be executed on every incremental build;
  • <?m2e execute onConfiguration,onIncremental?> this execution will be executed on every Project Configuration update and every incremental build;
  • <?m2e configurator configuratorId?> this execution will be delegated to the matching m2e configurator.
Each instruction can be placed in the <execution> node, this way it applies on this exact execution or on any execution of the same plugin with the same executionId in child pom. It can also be placed in a <plugin> node, this way it acts the same as a dedicated <pluginManagement> section which lists all goals of this plugin.
Please be aware there are currently no Quick Fixes available to automatically inject these new instructions when a “Plugin Execution Not Covered” error marker is found.

Monday, April 17, 2017

Tuesday, March 14, 2017

settings.xml mirrors repositories proxy

 <distributionManagement>
  <repository>
   <id>fxg-releases</id>
   <url>https://nexus.x.com:8443/nexus/content/repositories/fxg-releases</url>
  </repository>
  <snapshotRepository>
   <id>fxg-snapshots</id>
   <url>https://nexus.x.com:8443/nexus/content/repositories/fxg-snapshots</url>
  </snapshotRepository>
  <site>
   <id>mvnown</id>
   <url>scpexe://maven.x.com/var/fedex/scm/mvn/httproot/site/${project.artifactId}/${project.artifactId}-${project.version}</url>
  </site>
 </distributionManagement>


SETTINGS XML 


<settings>
 <!-- Switching to c:/temp for the "document and settings" spacing issues some projects have when stepping out of the java realm to perform 
  function by a plugin. -->
 <localRepository>${java.io.tmpdir}/${user.name}/repository</localRepository>
 <interactiveMode>true</interactiveMode>
 <proxies>
  <proxy>
   <active />
   <port>3128</port>
   <host>internet.proxy.fedex.com</host>
   <id>FedEx VPN Proxy</id>
  </proxy>
 </proxies>
 <servers>
  <server>
   <id>releases</id>
   <username>scm</username>
   <password>****</password>
  </server>
  <server>
   <id>snapshots</id>
   <username>dev</username>
   <password>LKLKLJLKJL</password>
  </server>
 </servers>
 <mirrors>
  <mirror>
   <id>proxy</id>
   <name>Maven Proxy</name>
   <url>http://maven.x.com:9999/nexus/content/groups/m2/</url>
   <mirrorOf>external:*,!my-nexus</mirrorOf>
  </mirror>
  <mirror>
   <id>my-nexus</id>
   <name>
    Maven Repository Manager running on 
   </name>
   <url>https://nexus.x.com:8443/nexus/content/groups/m2/</url>
   <mirrorOf>*</mirrorOf>
  </mirror>
 </mirrors>
 <profiles>
  <profile>
   <id>nexus</id>
   <repositories>
    <repository>
     <id>corp-nexus-snapshots</id>
     <url>https://nexus.x.com:8443/nexus/content/repositories/fxg-snapshots</url>
     <releases>
      <enabled>false</enabled>
     </releases>
     <snapshots>
      <enabled>true</enabled>
     </snapshots>
    </repository>
    <repository>
     <id>corp-nexus-releases</id>
     <url>https://nexus.x.com:8443/nexus/content/repositories/fxg-releases</url>
     <releases>
      <enabled>false</enabled>
     </releases>
     <snapshots>
      <enabled>true</enabled>
     </snapshots>
    </repository>
   </repositories>
  </profile>
 </profiles>
 <activeProfiles>
  <activeProfile>nexus</activeProfile>
 </activeProfiles>
</settings>



Monday, March 6, 2017

Jenkins/Cloudbees Available Environment Variables

Name  ↓Value   
_/usr/bin/java
ANDROID_HOME/opt/jenkins/tools/android-sdk-linux
BUILD_CAUSEMANUALTRIGGER
BUILD_CAUSE_MANUALTRIGGERtrue
BUILD_DISPLAY_NAME#39
BUILD_ID39
BUILD_NUMBER39
BUILD_TAGjenkins-EFS-SEFS_COMMON-6270-JOBS-EFS_DASHBOARD_RELEASE_CUT_JOB-39
BUILD_URLhttps://company.com:8443/jenkins/job/ShipmentEFS/job/SEFS_COMMON-6270/job/JOBS/job/SEFS_DASHBOARD_RELEASE_CUT_JOB/39/
DONT_DEPLOYfalse
EXECUTOR_NUMBER3
grunt/opt/jenkins/tools/node-v4.6.0-linux-x64/lib/node_modules/grunt-cli/bin
HOME/opt/jenkins
HUDSON_HOME/opt/jenkins
HUDSON_SERVER_COOKIE4b4586c89a3e8abe
HUDSON_URLhttps://company.com:8443/jenkins/
JAVA_HOME/opt/jenkins/tools/jdk1.7.0_79
JENKINS_HOME/opt/jenkins
JENKINS_SERVER_COOKIE4b4586c89a3e8abe
JENKINS_URLhttps://company.com:8443/jenkins/
JOB_BASE_NAMEEFS_DASHBOARD_RELEASE_CUT_JOB
JOB_NAMEEFS/EFS_COMMON-6270/JOBS/SEFS_DASHBOARD_RELEASE_CUT_JOB
JOB_URLhttps://company.com:8443/jenkins/job/EFS/job/EFS_COMMON-6270/job/JOBS/job/SEFS_DASHBOARD_RELEASE_CUT_JOB/
LOGNAMEjenkins
MAIL/var/mail/jenkins
NLSPATH/usr/dt/lib/nls/msg/%L/%N.cat
NODE_LABELS2144 Android Java7 Java8 Tomcat Tomcat (2144)
NODE_NAMETomcat (2144)
OLDPWD/opt/jenkins
PATH/usr/local/bin:/bin:/usr/bin
PATH+JDK/opt/jenkins/tools/jdk1.7.0_79/bin
PWD/opt/jenkins
RELEASE_TAG1.3.2.6
ROOT_BUILD_CAUSEMANUALTRIGGER
ROOT_BUILD_CAUSE_MANUALTRIGGERtrue
SHELL/bin/bash
SHLVL1
SOURCE_BRANCH1.3.0-SNAPSHOT
SSH_CLIENT10.236.10.51 60556 22
SSH_CONNECTION10.236.10.51 60556 10.236.14.54 22
USERjenkins
XFILESEARCHPATH/usr/dt/app-defaults/%L/Dt

Friday, February 24, 2017

Remove arbitrary columns from text lines with perl and splice

Probably not the shorted ... remove the 9th and 0th column from an ls with perl and splice
find . -type f -ls | sort -k11 | perl -ne '@x=split;splice @x,9,1;splice @x,0,1; print join("\t", @x), "\n";' | tail 

Friday, February 3, 2017

Moving one git repository to another git repository host

You can refer to the GitHub page "Duplicating a repository"
It uses:
That would give:
git clone --mirror https://bitbucket.org/exampleuser/repository-to-mirror.git
# Make a bare mirrored clone of the repository

cd repository-to-mirror.git
git remote set-url --push origin https://github.com/exampleuser/mirrored
# Set the push location to your mirror

git push --mirror

Wednesday, February 1, 2017

Jenkins / CloudBees : moving jobs between servers .... how ...

 curl -s https://USER:API_TOKEIN@jenkins.prod.com:8443/jenkins/job/SCM_SVN_MODEL/config.xml | curl -X POST 'http://USER:APITOKEN@jenkins-dev.test.com:8080/jenkins/createItem?name=JOBNAME' --header "Content-Type: application/xml" -d @-
Get the API token on the target machine (in this case jenkins-dev.test.com)
- Open browser and login on target machine
- http://jenkins-dev.test.com:8080/jenkins/user/USER/configure
- hit the API TOKEN button
If you want to directly copy to a folder do this ...
curl -s https://USER_SRC:APITOKEN_SRC@jenkins.prod.com:8443/jenkins/job/SCM_SVN_MODEL/config.xml | \
curl -X POST 'http://USER_TGT:APITOKEN_TGT@jenkins-dev.test.com:8080/jenkins/job/SANDBOX/createItem?name=JOBNAME' --header "Content-Type: application/xml" -d @-
or if you have a list of them ....
declare -a arr=(
"SEFS_ABSTRACT_ACTION_MODEL"
"SEFS_ABSTRACT_BUILD_ENV_MODEL"
"SEFS_ABSTRACT_BUILD_MODEL"
"SEFS_ABSTRACT_SCM_MODEL"
"SEFS_ABSTRACT_TEST_MODEL"
"SEFS_BASE_AUX_MODEL"
"SEFS_BUILDER_TMPL"
"SEFS_JAVA_BUILD_MODEL"
"SEFS_MASTER_BUILD_TMPL"
"SEFS_PROJECT_TMPL"
"SEFS_SCM_GIT_MODEL"
"SEFS_SCM_SVN_MODEL"
"SEFS_SILVER_FABRIC_DEPLOY_TMPLT"
"SEFS_STANDARD_BUILD_ENV_MODEL"
"SEFS_TEST_JUNIT_MODEL"
"SEFS_TIBCO_BUILD_MODEL"
"SEFS_UC_DEPLOY_MODEL")

## now loop through the above array
for i in "${arr[@]}"
do
    curl -s https://USERID_SRC:2615adec2asas558a20790eec2994096c3c455b43@jenkins.prod.com:8443/jenkins/job/$i/config.xml | curl -X POST "http://USERID_TGT:efd517beb69f2ca1sfasfd81371885a48a928cf565@jenkins-dev.test.com:8080/jenkins/job/SANDBOX/createItem?name=$i" --header "Content-Type: application/xml" -d @-
   # or do whatever with individual element of the array
done

Tuesday, January 31, 2017

Jenkins Pipeline Groovy Snippets.


Moved some of the examples to gist.github.com for organizational purposes.


Show all binding variables:

echo "${this.binding.variables}"

Change spaces in underscores for the workspace

def getWorkspace() {
    pwd().replace("%2F", "_")
}

def wipeWorkspace(String workspace) {
    if (workspace) {
        sh "find ${workspace} -mindepth 4 -depth -delete"
    }
}

Show all environment variables.

node {
    sh 'env | sort'
}



Getting absolute path to a Job: 
SCM_JOB is a template attribute with item -> Pipelines
[Pipeline] echo
[name:ASSEMBLY_DESCRIPTORS_BUILD,SCM_JOB:org.jenkinsci.plugins.workflow.job.WorkflowJob@3d71aee8[ShipmentEFS/COMMON/JOBS/Pipeline_leaf_caan], steps:org.jenkinsci.plugins.workflow.cps.DSL@dfb3e3d]

${SCM_JOB['fullName']} = 'ShipmentEFS/Common/Jobs/Pipeline_leaf_caan'

then we can do
node {
    build job: SCM_JOB['fullName']
}








AUXILARY MODELS AND GETTNG THERE CONTENT


// List all auxilary models for logging purpose
echo "${SEFS_CONTEXT}"
echo "${SCM_MODEL}"
echo "class:${BUILD_MODEL.metaClass.toString()}"
echo "methods:${BUILD_MODEL.metaClass.methods}"
echo "fields: ${BUILD_MODEL.metaClass.fields}"
echo "toSTring: ${BUILD_MODEL.toString()}"
echo "testmodel: ${BUILD_MODEL['BUILD_TEST_MODEL']}"

try {
echo "getbinding: ${BUILD_MODEL.getValue('BUILD_TEST_MODEL')}"
} catch (error) {
echo error
}
try {
echo "model:    ${BUILD_MODEL.model}"
def m=BUILD_MODEL.model
echo "meta:    ${m['BUILD_TEST_MODEL']}"
} catch (error) {
echo error
echo "model:    ${m.metaClass.methods}"
}
try {
echo "getmodel: ${BUILD_MODEL.getModel()}"
} catch (error) {
echo error


}

Thursday, January 5, 2017

Spring JPA Hibernate Annotated with custom orm.xml for testing against a HSQL database

Spring JPA Hibernate Annotated with custom orm.xml for testing against a HSQL database



}
DefaultPersistenceUnitManager spum = new DefaultPersistenceUnitManager();
spum.setMappingResources("META-INF/test-orm.xml");
spum.setDefaultDataSource(dataSource);
spum.setPackagesToScan("domain.entity");
spum.afterPropertiesSet();

HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
vendorAdapter.setDatabase(this.databaseVendor());

LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
factoryBean.setPersistenceUnitManager(spum);
factoryBean.setJpaVendorAdapter(vendorAdapter);
final HashMap<String, Object> properties = new HashMap<String, Object>();
properties.put("hibernate.hbm2ddl.auto",
      env.getProperty("domain.hibernate.hbm2ddl.auto"));
properties.put("hibernate.dialect",
      env.getProperty("domain.hibernate.dialect"));
properties.put("hibernate.show_sql",
      env.getProperty("domain.hibernate.show_sql"));
properties.put("hibernate.generate_statistics",
      env.getProperty("domain.hibernate.generate_statistics"));
properties.put("hibernate.format_sql",
      env.getProperty("domain.hibernate.format_sql"));
properties.put("hibernate.default_schema", "SEFS_DASHBOARD_SCHEMA");
Constants.log(properties);
factoryBean.setJpaPropertyMap(properties);
factoryBean.afterPropertiesSet();

return factoryBean.getObject();

}


For debugging use this

   <!-- enable trace for binding -->
   <logger name="org.hibernate.jpa">
      <level value="debug" />
      <appender-ref ref="stdout" />

   </logger>