<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How do I automatically package an App with some best practices applied?  I am using OS X. in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-automatically-package-an-App-with-some-best-practices/m-p/252875#M48630</link>
    <description>&lt;P&gt;I want to automate App creation, but I have a .git folder that does not meet Splunk requirements.  Do you have a script that I can use to automatically apply some best practices?  I am using OS X.&lt;/P&gt;</description>
    <pubDate>Sat, 30 Jan 2016 09:01:54 GMT</pubDate>
    <dc:creator>jdonn_splunk</dc:creator>
    <dc:date>2016-01-30T09:01:54Z</dc:date>
    <item>
      <title>How do I automatically package an App with some best practices applied?  I am using OS X.</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-automatically-package-an-App-with-some-best-practices/m-p/252875#M48630</link>
      <description>&lt;P&gt;I want to automate App creation, but I have a .git folder that does not meet Splunk requirements.  Do you have a script that I can use to automatically apply some best practices?  I am using OS X.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Jan 2016 09:01:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-automatically-package-an-App-with-some-best-practices/m-p/252875#M48630</guid>
      <dc:creator>jdonn_splunk</dc:creator>
      <dc:date>2016-01-30T09:01:54Z</dc:date>
    </item>
    <item>
      <title>Re: How do I automatically package an App with some best practices applied?  I am using OS X.</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-automatically-package-an-App-with-some-best-practices/m-p/252876#M48631</link>
      <description>&lt;P&gt;Adjust this script to your liking.  Please post any solutions for other OSs below.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#!/bin/bash

### SPLUNK_HOME
SPLUNK_HOME="/opt/splunk"
desktop="/Users/jdonn/Desktop/scripts"
permissions="jdonn:staff"

### Collect and test for App name
if [ "$#" -eq 0 ];then
  echo "Please state the name of the App"
  exit 0
elif [ "$#" -gt 1 ];then
  echo "Just ONE App at a time"
  exit 0
    else
      echo "on we go" 
      app=$BASH_ARGV
      echo "App = $app"
    fi

### Move .git out of the App dir
mv $SPLUNK_HOME/etc/apps/$app/.git /tmp/.

### Remove READMEs and metadata
rm -f $SPLUNK_HOME/etc/apps/$app/metadata/local.meta
rm -f $SPLUNK_HOME/etc/apps/$app/bin/README
rm -f $SPLUNK_HOME/etc/apps/$app/default/data/ui/views/README

### Remove the backup lookup file dir created by the lookup editor
rm -f $SPLUNK_HOME/etc/apps/$app/lookups/lookup_file_backups/

### Ensure permissions are correct
chmod -R 644 $SPLUNK_HOME/etc/apps/$app/*
chmod -R 744 $SPLUNK_HOME/etc/apps/$app/bin/*

### Package App
$SPLUNK_HOME/bin/splunk package app $app

### Mave .git back into the App
mv $SPLUNK_HOME/etc/system/static/app-packages/$app.spl $desktop/.
mv $app.spl $app.tar.gz
chown $permissions $app.tar.gz

### Move the file to the desktop, rename it and fix permissions
mv /tmp/.git $SPLUNK_HOME/etc/apps/$app/.git

### Run App inspect
splunk-appinspect inspect $app.tar.gz --mode precert --included-tags splunk_appinspect --included-tags cloud
### Cloud only - add switch
# splunk-appinspect inspect $app.tar.gz --mode precert --included-tags cloud

exit 0
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 30 Jan 2016 09:03:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-automatically-package-an-App-with-some-best-practices/m-p/252876#M48631</guid>
      <dc:creator>jdonn_splunk</dc:creator>
      <dc:date>2016-01-30T09:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I automatically package an App with some best practices applied?  I am using OS X.</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-automatically-package-an-App-with-some-best-practices/m-p/252877#M48632</link>
      <description>&lt;P&gt;Attempting this in the directory where the app is being developed did not work for me because the &lt;/P&gt;

&lt;P&gt;chmod -R 644 $SPLUNK_HOME/etc/apps/$app/*&lt;/P&gt;

&lt;P&gt;removes the x bit from all directories under the app folder &lt;/P&gt;

&lt;P&gt;As a result the app no longer runs.  In addition the subsequent recommended&lt;/P&gt;

&lt;P&gt;chmod -R 744 $SPLUNK_HOME/etc/apps/$app/bin/*&lt;/P&gt;

&lt;P&gt;to add the +x bit back to the files in the bin directory also fails since the bin directory no longer has the x bit set.&lt;/P&gt;

&lt;P&gt;As you can see&lt;/P&gt;

&lt;P&gt;chmod: $SPLUNK_HOME/etc/apps/$app/bin/README: Permission denied&lt;BR /&gt;
chmod: $SPLUNK_HOME/etc/apps/$app/bin/_DEBUG.sh: Permission denied&lt;BR /&gt;
chmod: $SPLUNK_HOME/etc/apps/$app/bin/delete.py: Permission denied&lt;BR /&gt;
chmod: $SPLUNK_HOME/etc/apps/$app/bin/package_app.sh: Permission denied&lt;BR /&gt;
chmod: $SPLUNK_HOME/etc/apps/$app/iRobotHBU/bin/utils: Permission denied&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:14:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-automatically-package-an-App-with-some-best-practices/m-p/252877#M48632</guid>
      <dc:creator>czervos</dc:creator>
      <dc:date>2020-09-29T23:14:52Z</dc:date>
    </item>
  </channel>
</rss>

