pkgr 1.3.2 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cc9860507ebe18fd497f6cd0c2eafb4b43fa3e84
4
+ data.tar.gz: d1bc91d07dcab8e62cf382dd6b1317cbe6866065
5
+ SHA512:
6
+ metadata.gz: 34286f726b3d4dc61931239d8ffd3570ea524ceddcf3b0d5a06635123904b6fc31af1be63b8a5e9a937766da79c888748f4b9eec49b51235905a863ec0cf9700
7
+ data.tar.gz: 56ea0451c22d005d56852efeb0c87ff231de587e4d833b6658fc10a102372c53098e23b9f0aa89a02af9be14453846d46307ef953537bff3a9d1803d02e05c5d
data/README.md CHANGED
@@ -2,21 +2,29 @@
2
2
 
3
3
  ## Goal
4
4
 
5
- Make debian packages out of any Ruby or NodeJS app that can run on Heroku. Hosted service available at <https://pkgr.io/>.
5
+ Make debian or rpm packages out of any app, including init script, logrotate, etc. Excellent way to distribute apps or command line tools without complicated installation instructions.
6
6
 
7
- More languages and target distributions will be added after thorough testing, though nothing prevents you from specifying a specific buildpack (see Usage).
7
+ Hosted service available at <https://packager.io/>.
8
+
9
+ ## Officially supported languages
10
+
11
+ * Ruby
12
+ * NodeJS
13
+ * Go
14
+
15
+ You can also point to other buildpacks ([doc](https://packager.io/documentation/reference/the-pkgryml-file.html#buildpack)). They may just work.
8
16
 
9
17
  ## Supported distributions (64bits only)
10
18
 
11
- * Ubuntu 14.04 ("Trusty")
12
- * Ubuntu 12.04 ("Precise")
13
- * Debian 7.4 ("Wheezy")
14
- * Ubuntu 10.04 ("Lucid")
15
- * Debian 6 ("Squeeze")
19
+ * Ubuntu 14.04 ("trusty")
20
+ * Ubuntu 12.04 ("precise")
21
+ * Debian 7 ("wheezy")
22
+ * Centos 6
23
+ * Fedora 20
16
24
 
17
25
  ## Examples
18
26
 
19
- See <https://pkgr.io/showcase> for examples of apps packaged with `pkgr` (Gitlab, Redmine, Discourse, Ghost, etc.).
27
+ See <https://packager.io/> for examples of apps packaged with `pkgr` (Gitlab, OpenProject, Discourse, etc.).
20
28
 
21
29
  ## Installation
22
30
 
@@ -32,17 +40,13 @@ To package your app, you can either execute `pkgr` locally if your app repositor
32
40
 
33
41
  pkgr package path/to/app/repo
34
42
 
35
- Or, assuming your build machine is accessible via SSH by doing `ssh pkgr-build-machine` (set this in your `~/.ssh/config` file), you can do as follows:
36
-
37
- pkgr package path/to/app/repo --host pkgr-build-machine
38
-
39
43
  The resulting .deb package will be in your current working directory.
40
44
 
41
45
  Full command line options are given below:
42
46
 
43
47
  $ pkgr help package
44
48
  Usage:
45
- pkgr package TARBALL
49
+ pkgr package TARBALL|DIRECTORY
46
50
 
47
51
  Options:
48
52
  [--buildpack=BUILDPACK] # Custom buildpack to use
@@ -56,7 +60,7 @@ Full command line options are given below:
56
60
  [--description=DESCRIPTION] # Project description
57
61
  [--version=VERSION] # Package version (if git directory given, it will use the latest git tag available)
58
62
  [--iteration=ITERATION] # Package iteration (you should keep the default here)
59
- # Default: 20140502095614
63
+ # Default: 20141015024539
60
64
  [--license=LICENSE] # The license of your package (see <https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/#license-short-name>)
61
65
  [--user=USER] # User to run the app under (defaults to your app name)
62
66
  [--group=GROUP] # Group to run the app under (defaults to your app name)
@@ -75,13 +79,13 @@ Full command line options are given below:
75
79
  # Default: true
76
80
  [--env=one two three] # Specify environment variables for buildpack (--env "CURL_TIMEOUT=2" "BUNDLE_WITHOUT=development test")
77
81
  [--force-os=FORCE_OS] # Force a specific distribution to build for (e.g. --force-os "ubuntu-12.04"). This may result in a broken package.
82
+ [--store-cache], [--no-store-cache] # Output a tarball of the cache in the current directory (name: cache.tar.gz)
78
83
  [--verbose], [--no-verbose] # Run verbosely
79
84
  [--debug], [--no-debug] # Run very verbosely
80
85
  [--name=NAME] # Application name (if directory given, it will default to the directory name)
81
86
  [--buildpacks-cache-dir=BUILDPACKS_CACHE_DIR] # Directory where to store the buildpacks
82
87
  # Default: /home/vagrant/.pkgr/buildpacks
83
88
 
84
-
85
89
  ## Why?
86
90
 
87
91
  Tools such as [Capistrano](http://capify.org/) are great for deploying
@@ -101,7 +105,7 @@ Finally, it's a great way to share your open source software with your users and
101
105
 
102
106
  * Uses Heroku buildpacks to embed all the dependencies related to your application runtime within the debian package. For a Rails app for instance, this means that `pkgr` will embed the specific ruby runtime you asked for, along with all the gems specified in your Gemfile. However, all other dependencies you may need must be specified as additional system dependencies (see Usage). This avoids the 'packaging-the-world' approach used by other tools such as omnibus (with the pros and cons that come with it), but it still allows you to use the latest and greatest libraries for your language of choice. See this [blog post][background-pkgr] for more background.
103
107
 
104
- [background-pkgr]: http://blog.pkgr.io/post/81988994454/why-i-made-pkgr-io-digressions-on-software-packaging
108
+ [background-pkgr]: http://blog.packager.io/post/81988994454/why-i-made-pkgr-io-digressions-on-software-packaging
105
109
 
106
110
  * Gives you a nice executable, which closely replicates the Heroku toolbelt utility. For instance, assuming you're packaging an app called `my-app`, you can do the following:
107
111
 
@@ -110,6 +114,7 @@ Finally, it's a great way to share your open source software with your users and
110
114
  my-app run [procfile process] # e.g. my-app run rake db:migrate; my-app run console; etc.
111
115
  my-app run [arbitrary process] # e.g. my-app run ruby -v; my-app run bundle install; etc.
112
116
  my-app scale web=1 worker=1
117
+ my-app logs [--tail]
113
118
  ...
114
119
 
115
120
  * Your app will reside in `/opt/app-name`.
@@ -126,7 +131,7 @@ Finally, it's a great way to share your open source software with your users and
126
131
 
127
132
  * You must have a Procfile.
128
133
 
129
- * Your application must be Heroku compatible, meaning you should be able to set your main app's configuration via environment variables.
134
+ * Your application should be Heroku compatible, meaning you should be able to set your main app's configuration via environment variables.
130
135
 
131
136
  ## Troubleshooting
132
137
 
@@ -143,7 +148,7 @@ If you get the following error `ERROR: While executing gem ... (ArgumentError)
143
148
 
144
149
  ## Authors
145
150
 
146
- * Cyril Rohr <cyril.rohr@gmail.com> - <http://crohr.me>
151
+ * Cyril Rohr <cyril.rohr@gmail.com> - <http://crohr.me>, <https://packager.io>
147
152
 
148
153
  ## Copyright
149
154
 
@@ -0,0 +1,13 @@
1
+ default:
2
+ - curl
3
+ - gcc
4
+ - gcc-c++
5
+ - kernel-devel
6
+ - openssl-devel
7
+ - readline-devel
8
+ - libxml2-devel
9
+ - libxslt-devel
10
+ - libevent-devel
11
+ - postgresql-devel
12
+ - mariadb-devel
13
+ - sqlite-devel
@@ -1,2 +1,3 @@
1
- https://github.com/pkgr/heroku-buildpack-ruby.git#487c79e8cc3ab038ac13fef82d1e59a9c6ac39e6,BUILDPACK_VENDOR_URL="https://s3-external-1.amazonaws.com/pkgr-buildpack-ruby/20140408175240-centos-6.4",BUILDPACK_NODE_VERSION="0.6.8",CURL_CONNECT_TIMEOUT=60,CURL_TIMEOUT=300
2
- https://github.com/heroku/heroku-buildpack-nodejs.git#v58
1
+ https://github.com/pkgr/heroku-buildpack-ruby.git#universal,BUILDPACK_NODE_VERSION="0.6.8",CURL_CONNECT_TIMEOUT=60,CURL_TIMEOUT=300
2
+ https://github.com/heroku/heroku-buildpack-nodejs.git#v58
3
+ https://github.com/kr/heroku-buildpack-go.git
@@ -1,2 +1,3 @@
1
- https://github.com/pkgr/heroku-buildpack-ruby.git#487c79e8cc3ab038ac13fef82d1e59a9c6ac39e6,BUILDPACK_VENDOR_URL="https://s3-external-1.amazonaws.com/pkgr-buildpack-ruby/20140408175240-debian-7.4",BUILDPACK_NODE_VERSION="0.6.8",CURL_CONNECT_TIMEOUT=60,CURL_TIMEOUT=300
2
- https://github.com/heroku/heroku-buildpack-nodejs.git#v58
1
+ https://github.com/pkgr/heroku-buildpack-ruby.git#universal,BUILDPACK_NODE_VERSION="0.6.8",CURL_CONNECT_TIMEOUT=60,CURL_TIMEOUT=300
2
+ https://github.com/heroku/heroku-buildpack-nodejs.git#v58
3
+ https://github.com/kr/heroku-buildpack-go.git
@@ -0,0 +1,2 @@
1
+ https://github.com/pkgr/heroku-buildpack-ruby.git#universal,BUILDPACK_NODE_VERSION="0.6.8",CURL_CONNECT_TIMEOUT=60,CURL_TIMEOUT=300
2
+ https://github.com/heroku/heroku-buildpack-nodejs.git#v58
@@ -1,2 +1,3 @@
1
- https://github.com/pkgr/heroku-buildpack-ruby.git#487c79e8cc3ab038ac13fef82d1e59a9c6ac39e6,BUILDPACK_VENDOR_URL="https://s3-external-1.amazonaws.com/pkgr-buildpack-ruby/20140408175240-ubuntu-12.04",BUILDPACK_NODE_VERSION="0.6.8",CURL_CONNECT_TIMEOUT=60,CURL_TIMEOUT=300
2
- https://github.com/heroku/heroku-buildpack-nodejs.git#v58
1
+ https://github.com/pkgr/heroku-buildpack-ruby.git#universal,BUILDPACK_NODE_VERSION="0.6.8",CURL_CONNECT_TIMEOUT=60,CURL_TIMEOUT=300
2
+ https://github.com/heroku/heroku-buildpack-nodejs.git#v58
3
+ https://github.com/kr/heroku-buildpack-go.git
@@ -1,2 +1,3 @@
1
- https://github.com/pkgr/heroku-buildpack-ruby.git#487c79e8cc3ab038ac13fef82d1e59a9c6ac39e6,BUILDPACK_VENDOR_URL="https://s3-external-1.amazonaws.com/pkgr-buildpack-ruby/20140408175240-ubuntu-14.04",BUILDPACK_NODE_VERSION="0.6.8",CURL_CONNECT_TIMEOUT=60,CURL_TIMEOUT=300
2
- https://github.com/heroku/heroku-buildpack-nodejs.git#v58
1
+ https://github.com/pkgr/heroku-buildpack-ruby.git#universal,BUILDPACK_NODE_VERSION="0.6.8",CURL_CONNECT_TIMEOUT=60,CURL_TIMEOUT=300
2
+ https://github.com/heroku/heroku-buildpack-nodejs.git#v58
3
+ https://github.com/kr/heroku-buildpack-go.git
@@ -7,6 +7,10 @@ set -o pipefail
7
7
  APP_NAME=$(basename $0)
8
8
  # useful for testing
9
9
  ROOT_PATH=${ROOT_PATH:="/"}
10
+ # store original pwd
11
+ export ORIGINAL_PWD=$(pwd)
12
+ # required for chroot on fedora
13
+ PATH="$PATH:/usr/sbin"
10
14
 
11
15
  # Helper function that returns the real path, based on the given ROOT_PATH
12
16
  _p() {
@@ -20,22 +24,32 @@ usage() {
20
24
  echo " $APP_NAME logs [--tail|-n NUMBER]"
21
25
  echo " $APP_NAME config:get VAR"
22
26
  echo " $APP_NAME config:set VAR=VALUE"
27
+ echo " $APP_NAME reconfigure"
23
28
  }
24
29
 
25
30
 
26
31
  # Returns the type of process manager supported by the current distribution.
27
- runner() {
32
+ setup_runner() {
28
33
  if [ -f $(_p /etc/debian_version) ]; then
29
34
  case "$(cat $(_p /etc/debian_version))" in
30
35
  wheezy*|squeeze*|jessie*)
31
- echo "upstart"
36
+ APP_RUNNER="upstart"
32
37
  ;;
33
38
  *)
34
- echo "sysv"
39
+ APP_RUNNER="sysv"
40
+ SYSV_MANAGER="update-rc.d"
35
41
  ;;
36
42
  esac
37
43
  elif [ -f $(_p /etc/redhat-release) ]; then
38
- echo "upstart"
44
+ case "$(cat $(_p /etc/redhat-release))" in
45
+ CentOS*)
46
+ APP_RUNNER="upstart"
47
+ ;;
48
+ *)
49
+ APP_RUNNER="sysv"
50
+ SYSV_MANAGER="chkconfig"
51
+ ;;
52
+ esac
39
53
  fi
40
54
  }
41
55
 
@@ -45,6 +59,7 @@ if [ ! 0 -eq ${EUID} ]; then
45
59
  exit 1
46
60
  fi
47
61
 
62
+ setup_runner
48
63
  DEFAULT_FILE=$(_p "/etc/default/${APP_NAME}")
49
64
 
50
65
  # Source all environment variables for the app. This must be done as
@@ -60,10 +75,6 @@ for file in $(_p "${APP_HOME}/.profile.d")/*.sh; do
60
75
  if [ -f $file ]; then HOME=${APP_HOME} . $file; fi
61
76
  done
62
77
 
63
- # You can force a specific process manager by setting the PROCESS_MANAGER
64
- # environment variable.
65
- PROCESS_MANAGER=${PROCESS_MANAGER:=$(runner)}
66
-
67
78
  # Return all the environment variables accessible to the app.
68
79
  show_env() {
69
80
  env -i ROOT_PATH=${ROOT_PATH} ${0} run env | sort
@@ -86,7 +97,7 @@ tail_logs() {
86
97
 
87
98
  current_number_of_processes() {
88
99
  PROCESS_NAME="$1"
89
- if [ "${PROCESS_MANAGER}" = "upstart" ]; then
100
+ if [ "${APP_RUNNER}" = "upstart" ]; then
90
101
  echo $(ls -rv1 $(_p /etc/init/)${APP_NAME}-${PROCESS_NAME}-*.conf 2>/dev/null | head -1 | sed -r 's/.*\-([0-9]+)\.conf/\1/g')
91
102
  else
92
103
  echo $(ls -rv1 $(_p /etc/init.d/)${APP_NAME}-${PROCESS_NAME}-* 2>/dev/null | head -1 | sed -r 's/.*\-([0-9]+)/\1/g')
@@ -110,6 +121,24 @@ update_port() {
110
121
  fi
111
122
  }
112
123
 
124
+ sysv_enable() {
125
+ local name="$1"
126
+ if [ "$SYSV_MANAGER" = "chkconfig" ] ; then
127
+ $SYSV_MANAGER "$name" on
128
+ elif [ "$SYSV_MANAGER" = "update-rc.d" ] ; then
129
+ $SYSV_MANAGER "$name" defaults
130
+ fi
131
+ }
132
+
133
+ sysv_disable() {
134
+ local name="$1"
135
+ if [ "$SYSV_MANAGER" = "chkconfig" ] ; then
136
+ $SYSV_MANAGER "$name" off
137
+ elif [ "$SYSV_MANAGER" = "update-rc.d" ] ; then
138
+ $SYSV_MANAGER -f "$name" remove
139
+ fi
140
+ }
141
+
113
142
  scale_up() {
114
143
  PROCESS_NAME="${1}"
115
144
  CURRENT_SCALE=${2}
@@ -118,7 +147,10 @@ scale_up() {
118
147
 
119
148
  echo "Scaling up..."
120
149
 
121
- if [ "${PROCESS_MANAGER}" = "upstart" ]; then
150
+ if [ "${APP_RUNNER}" = "upstart" ]; then
151
+ # copy initd
152
+ cp $(_p "${APP_HOME}/vendor/pkgr/scaling/upstart/${APP_NAME}") $(_p "/etc/init.d/")
153
+ chmod 0755 $(_p "/etc/init.d/${APP_NAME}")
122
154
  # copy master
123
155
  cp $(_p "${APP_HOME}/vendor/pkgr/scaling/upstart/${APP_NAME}.conf") $(_p "/etc/init/")
124
156
  # copy master process
@@ -132,18 +164,19 @@ scale_up() {
132
164
 
133
165
  update_port $(_p "/etc/init/${PROCESS_ID}.conf") "${PROCESS_NAME}" $port $index
134
166
 
135
- service "${PROCESS_ID}" start
167
+ # directly call initctl instead of service, otherwise CentOS 6.x does not understand.
168
+ initctl start "${PROCESS_ID}"
136
169
  done
137
170
 
138
- service ${APP_NAME}-${PROCESS_NAME} start || true
139
- service ${APP_NAME} start || true
171
+ initctl start ${APP_NAME}-${PROCESS_NAME} || true
172
+ initctl start ${APP_NAME} || true
140
173
  else
141
174
  cp $(_p "${APP_HOME}/vendor/pkgr/scaling/sysv/${APP_NAME}") $(_p /etc/init.d/)
142
175
  chmod a+x $(_p "/etc/init.d/${APP_NAME}")
143
- update-rc.d ${APP_NAME} defaults
176
+ sysv_enable ${APP_NAME}
144
177
  cp $(_p "${APP_HOME}/vendor/pkgr/scaling/sysv/${APP_NAME}-${PROCESS_NAME}") $(_p /etc/init.d/)
145
178
  chmod a+x $(_p "/etc/init.d/${APP_NAME}-${PROCESS_NAME}")
146
- update-rc.d ${APP_NAME}-${PROCESS_NAME} defaults
179
+ sysv_enable ${APP_NAME}-${PROCESS_NAME}
147
180
  for i in $(seq ${SCALE_DELTA}); do
148
181
  index=$((${i} + ${CURRENT_SCALE}))
149
182
  PROCESS_ID="${APP_NAME}-${PROCESS_NAME}-${index}"
@@ -153,7 +186,7 @@ scale_up() {
153
186
  update_port $(_p "/etc/init.d/${PROCESS_ID}") "${PROCESS_NAME}" $port $index
154
187
 
155
188
  chmod a+x $(_p "/etc/init.d/${PROCESS_ID}")
156
- update-rc.d ${PROCESS_ID} defaults
189
+ sysv_enable ${PROCESS_ID}
157
190
  $(_p "/etc/init.d/${PROCESS_ID}") start
158
191
  done
159
192
  fi
@@ -171,12 +204,12 @@ scale_down() {
171
204
  index=$((${i} + ${NEW_SCALE}))
172
205
  PROCESS_ID="${APP_NAME}-${PROCESS_NAME}-${index}"
173
206
 
174
- if [ "${PROCESS_MANAGER}" = "upstart" ]; then
175
- service "${PROCESS_ID}" stop
207
+ if [ "${APP_RUNNER}" = "upstart" ]; then
208
+ initctl stop "${PROCESS_ID}"
176
209
  rm -f $(_p "/etc/init/${PROCESS_ID}.conf")
177
210
  else
178
211
  $(_p "/etc/init.d/${PROCESS_ID}") stop
179
- update-rc.d -f ${PROCESS_ID} remove
212
+ sysv_disable ${PROCESS_ID}
180
213
  rm -f $(_p "/etc/init.d/${PROCESS_ID}")
181
214
  fi
182
215
  done
@@ -201,6 +234,29 @@ scale() {
201
234
  fi
202
235
  }
203
236
 
237
+ configure() {
238
+ local installer_dir="$(_p "/usr/share/${APP_NAME}/installer")"
239
+ if [ -d "$installer_dir" ] ; then
240
+ ${installer_dir}/bin/run $@
241
+ else
242
+ echo "No installer has been configured for ${APP_NAME}"
243
+ fi
244
+ }
245
+
246
+ reconfigure() {
247
+ if [ "$APP_ADDONS" = "" ] ; then
248
+ configure --reconfigure
249
+ else
250
+ # only available for debian for now
251
+ if which dpkg-reconfigure &>/dev/null ; then
252
+ for addon in ${APP_ADDONS}; do
253
+ dpkg-reconfigure "${APP_NAME}-${addon}"
254
+ done
255
+ # always reconfigure main package as well
256
+ dpkg-reconfigure "${APP_NAME}"
257
+ fi
258
+ fi
259
+ }
204
260
 
205
261
  while : ; do
206
262
  case "$1" in
@@ -278,6 +334,14 @@ while : ; do
278
334
  show_env | grep -e "^${2}=" | sed -r "s/^${2}=//"
279
335
  break;;
280
336
 
337
+ configure)
338
+ configure $@
339
+ break;;
340
+
341
+ reconfigure)
342
+ reconfigure $@
343
+ break;;
344
+
281
345
  *)
282
346
  usage
283
347
  break ;;
@@ -0,0 +1,9 @@
1
+ default:
2
+ - openssl
3
+ - readline
4
+ - libxml2
5
+ - libxslt
6
+ - libevent
7
+ - postgresql-libs
8
+ - mysql-libs
9
+ - sqlite
@@ -1,9 +1,14 @@
1
1
  # Generated by pkgr
2
2
  export APP_HOME="<%= home %>"
3
3
  export APP_NAME="<%= name %>"
4
+ export APP_SAFE_NAME="<%= safe_name %>"
4
5
  export APP_GROUP="<%= group %>"
5
6
  export APP_USER="<%= user %>"
7
+ export APP_WIZARDS="<%= wizards.map{|wizard_group| wizard_group.map{|w| w.name}.join("|")}.join(",") %>"
8
+ # Legacy addons
9
+ export APP_ADDONS="<%= addons.map{|addon| addon.name}.join(" ") %>"
6
10
  export HOME="/home/<%= user %>"
11
+ export PORT=${PORT:=6000}
7
12
  <% if runner %>
8
13
  export PROCESS_MANAGER="<%= runner.split("-").first %>"
9
14
  <% end %>
@@ -18,18 +18,27 @@ ln -fs ${LOGS} ${HOME_LOGS}
18
18
  chown -R ${APP_USER}.${APP_GROUP} ${LOGS}
19
19
 
20
20
  # Add default conf.d file
21
- [ -f /etc/${APP_NAME}/conf.d/other ] || cat > /etc/${APP_NAME}/conf.d/other <<CONF
22
- # This file contains variables set via \`${APP_NAME} config:set\`
23
- # Database URL. E.g. : mysql2://root:pass@127.0.0.1/my-app-db
24
- export DATABASE_URL=db_adapter://db_user:db_password@db_host/db_name
25
- export PORT=\${PORT:=6000}
26
- CONF
21
+ [ -f /etc/${APP_NAME}/conf.d/other ] || touch /etc/${APP_NAME}/conf.d/other
27
22
 
28
23
  chown -R ${APP_USER}.${APP_GROUP} /etc/${APP_NAME}
24
+ chown ${APP_USER}.${APP_GROUP} /var/db/${APP_NAME}
29
25
 
30
26
  chmod 0750 /etc/${APP_NAME} /etc/${APP_NAME}/conf.d
31
27
  find /etc/${APP_NAME} -type f -exec chmod 0640 {} +
32
28
 
29
+ <% crons.each do |cron| %>
30
+ rm -f <%= cron.destination %>
31
+ cp <%= cron.source %> <%= cron.destination %>
32
+ chmod 0640 <%= cron.destination %>
33
+ <% end %>
34
+
35
+ <% if installer %>
36
+ echo "=============="
37
+ echo "The ${APP_NAME} package provides an installer. Please run the following command to finish the installation:"
38
+ echo "sudo ${APP_NAME} configure"
39
+ echo "=============="
40
+ <% end %>
41
+
33
42
  <% if after_install && File.readable?(after_install) %>
34
43
  # Call custom postinstall script.
35
44
  CUSTOM_POSTINSTALL_SCRIPT="<%= Base64.encode64 File.read(after_install) %>"
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ export APP_NAME="<%= name %>"
6
+ export APP_USER="<%= user %>"
7
+ export APP_GROUP="<%= group %>"
8
+ export APP_HOME="<%= home %>"
9
+
10
+ <% crons.each do |cron| %>
11
+ # delete cron if original file no longer exists
12
+ if [ ! -f <%= cron.source %> ] ; then
13
+ rm -f <%= cron.destination %>
14
+ fi
15
+ <% end %>
16
+
17
+ <% if after_remove && File.readable?(after_remove) %>
18
+ # Call custom postuninstall script.
19
+ CUSTOM_POSTUNINSTALL_SCRIPT="<%= Base64.encode64 File.read(after_remove) %>"
20
+
21
+ tmpfile=$(mktemp)
22
+ chmod a+x "${tmpfile}"
23
+ echo "${CUSTOM_POSTUNINSTALL_SCRIPT}" | base64 -d - > ${tmpfile}
24
+
25
+ "${tmpfile}" "$@"
26
+ <% end %>