This file is indexed.

/usr/bin/asterisk-config-custom is in asterisk 1:13.18.3~dfsg-1ubuntu4.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
#!/bin/sh
#
# asterisk-config-custom
# script to help creating a 'asterisk-config-custom' .deb package
#
#
# Created by: Geert Stappers <stappers@stappers.it>
# And distributed under the terms of the GPL
#
#
acc_usage ()
{
cat << HERE

asterisk-config-custom {command}

Where 'command' is 'init', 'next', 'sync' or 'help'

  init: Creates directory 'my-asterisk-config' with content

  next: Provides instruction for next step

  sync: Mostly \`rsync --archive /etc/asterisk etc_asterisk\`

  help: Prints _another_ help text

HERE
}

acc_help ()
{
cat << HERE

Program 'asterisk-config-custom' is for helping you making
your 'asterisk-config-custom' .deb package.

Typical work flow is running
 asterisk-config-custom init
only once.

Now you have a directory named
 my-asterisk-config
feel free to rename it
Important is that it has a debian/ directory
and an etc_asterisk/ directory

Change working directory with
 cd my-asterisk-config # or to what you renamed it.
Edit files in etc_asterisk. You may use
 asterisk-config-custom sync
to get you a starting point.
Create the actual package with
 dpkg-buildpackge -uc -us

And install with
 sudo dpkg -i ../asterisk-config-custom_*_all.deb

This package will be considered as an upgrade to the default
\`asterisk-config\` package and hence that package will will be removed
upon isntalling the custom package. However, it will not be purged and
hence all configuration files in \`/etc/asterisk\` from it will remain
installed. In order to remove them, you'll need to purge the package
\`asterisk-config\'.

Alternatively, you can install the custom package before installing
Asterisk.

HERE
}

acc_init ()
{
# Creates a diretory and puts files in it,
# including the Debian packaging files.

mkdir --parents my-asterisk-config/debian/source

cat << HERE > my-asterisk-config/README

In this directory you can / should run

  dpkg-buildpackage -uc -us

to get your 'asterisk-config-custom' package build.

If you don't have this package installed, install the package dpkg-dev .

HERE

cat << LastLine > my-asterisk-config/Makefile
#
# Makefile
#
all: etc_asterisk/asterisk.conf \
 usr/share/doc/asterisk-config/examples/configs/modules.conf.sample
	@echo "FYI: (minimal set of) configuration files are available"

etc_asterisk/asterisk.conf:
	@mkdir --parents etc_asterisk
	echo "; only a place holder" > etc_asterisk/asterisk.conf

usr/share/doc/asterisk-config/examples/configs/modules.conf.sample:
	@mkdir --parents usr/share/doc/asterisk-config/examples/configs
	echo "; place holder" \\
	> usr/share/doc/asterisk-config/examples/configs/modules.conf.sample


install:
	install --directory \$(DESTDIR)/usr
	install --directory \$(DESTDIR)/etc/asterisk
	rsync --archive --delete usr/* \$(DESTDIR)/usr
	rsync --archive --delete etc_asterisk/* \$(DESTDIR)/etc/asterisk

# l l
LastLine

cat << LastLine > my-asterisk-config/acc.config
# This file will be read during \`asterisk-config-custom sync\`
#
ACC_SYNC_CONFIG_EXAMPLES=Yes
# another value as 'Yes' wouldn't sync the configuration examples
#
#
# l l
LastLine

##--------------------------------------------

# Those who are familiar with Debian packaging
# can consider the rest of this function as a dedicated `dh_make`.

cat << LastLine > my-asterisk-config/debian/control
Source: asterisk-config-custom
Section: comm
Priority: optional
Maintainer: Me Myself <${LOGNAME}@$( hostname --fqdn )>
Build-Depends: debhelper (>= 9)
Standards-Version: 3.9.5
Homepage: <insert the upstream URL, if relevant>
#Vcs-Git: git://anonscm.debian.org/collab-maint/asterisk-config-custom.git
#Vcs-Browser: http://anonscm.debian.org/?p=collab-maint/asterisk-config-custom.git;a=summary

Package: asterisk-config-custom
Architecture: all
Depends: \${misc:Depends}
Recommends: asterisk
Conflicts: asterisk-config
Replaces: asterisk-config
Description: Custom configuration files for Asterisk
 Package that contains custom configuration files for Asterisk.
 .
 It is to keep _your_ config files while upgrading Asterisk.
 .
 The trick is that Asterisk depends
 on asterisk-config OR asterisk-config-custom
LastLine

cat << LastLine > my-asterisk-config/debian/changelog
asterisk-config-custom (0.6) unstable; urgency=medium

  * Created with \`asterisk-config-custom init\`

 -- Me Myself <${LOGNAME}@$( hostname --fqdn )>  $( date --rfc-2822 )

asterisk-config-custom (0.4) unstable; urgency=low

  * Initial release (Closes: #760032).

 -- Geert Stappers <stappers@stappers.it>  Fri, 29 Aug 2014 16:25:44 +0200
LastLine

cat << LastLine > my-asterisk-config/debian/copyright
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: asterisk-config-custom
Source: <url://example.com>

Files: *
Copyright: <years> <put author's name and email here>
           <years> <likewise for another author>
License: <special license>
 <Put the license of the package here indented by 1 space>
 <This follows the format of Description: lines in control file>
 .
 <Including paragraphs>
LastLine

cat << LastLine > my-asterisk-config/debian/rules
#!/usr/bin/make -f
# See debhelper(7)
#
# output every command that modifies files on the build system.
#DH_VERBOSE = 1

# main packaging script based on dh7 syntax
%:
	dh \$@

# l l
LastLine
chmod a+x my-asterisk-config/debian/rules

cat << LastLine > my-asterisk-config/debian/preinst
#! /bin/sh
# preinst script
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <new-preinst> \`install'
#        * <new-preinst> \`install' <old-version>
#        * <new-preinst> \`upgrade' <old-version>
#        * <old-preinst> \`abort-upgrade' <new-version>
#
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

case "\$1" in
    install|upgrade)
	# chan_modem was removed on 1.4+
    ;;

    abort-upgrade)
    ;;

    *)
        echo "preinst called with unknown argument \\\`\$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
LastLine

cat << LastLine > my-asterisk-config/debian/postinst
#! /bin/sh

set -e

# summary of how this script can be called:
#        * <postinst> \`configure' <most-recently-configured-version>
#        * <old-postinst> \`abort-upgrade' <new version>
#        * <conflictor's-postinst> \`abort-remove' \`in-favour' <package>
#          <new-version>
#        * <deconfigured's-postinst> \`abort-deconfigure' \`in-favour'
#          <failed-install-package> <version> \`removing'
#          <conflicting-package> <version>

case "\$1" in
    configure)
	set +e # ignore errors temporarily

	# find conffiles under /etc/asterisk belonging to asterisk-config-custom
	# and chown them to user asterisk.
	dpkg-query -W -f='\${Conffiles}\n' asterisk-config-custom 2>/dev/null | \\
	  sed -nr -e 's; (/etc/asterisk/.*) [0-9a-f]*;\1;p' | \\
	while read conffile; do
		chown asterisk: \${conffile} 2>/dev/null
	done

	# handle them in the end with a glob since it's way faster
	dpkg-statoverride --quiet --list '/etc/asterisk/*' | while read STAT; do
		chown \`echo \$STAT | cut -d' ' -f 1,2,4 | sed 's/ /:/'\` \\
			2>/dev/null
	done

	set -e
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \\\`\$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0

LastLine

cat << LastLine > my-asterisk-config/debian/lintian-overrides
asterisk-config-custom: non-standard-file-perm
LastLine

echo 9 > my-asterisk-config/debian/compat

echo '3.0 (native)' > my-asterisk-config/debian/source/format

}

acc_sync ()
{
  mkdir --parents etc_asterisk
  # assuming there are files in /etc/asterisk/
  rsync --archive --delete /etc/asterisk/* etc_asterisk/
  if [ -r ./acc.config ] ; then
    . ./acc.config
  else
    echo 'E: file "./acc.config" not readable'
    echo "I: Are you in the directory that \`${0} init\` created?"
    exit 1
  fi
  if [ x${ACC_SYNC_CONFIG_EXAMPLES} = xYes ] ; then
    ACC_EX=usr/share/doc/asterisk-config/examples
    # using asterisk-config directory
    mkdir --parents ${ACC_EX}
    rsync --archive --delete /${ACC_EX}/* ${ACC_EX}
  fi
}

acc_next ()
{
  if ! which dpkg-buildpackage > /dev/null ; then
    echo 'E: Program `dpkg-buildpackage` is not installed.'
    echo 'I: It is in the Debian package `dpkg-dev`.'
    echo 'I: Installing it with `apt-get install build-essential`,'
    echo 'I: will also install the program `make` that is also needed.'
    exit 1
  fi
  if grep --quiet 'Package: asterisk-config-custom' debian/control ; then
    echo 'dpkg-buildpackage -uc -us # Running this now'
    dpkg-buildpackage -uc -us
  else
    echo 'E: debian/control file for package asterisk-config-custom not found'
    echo "I: Are you in the directory that \`${0} init\` created?"
    exit 1
  fi
}


# main()

case $1 in
init)
  acc_init
  ;;
next)
  acc_next
  ;;
sync)
  acc_sync
  ;;
help)
  acc_help
  ;;
*)
  acc_usage
  ;;
esac

# l l