packaging files for QtCreator added
[kitchenalert] / src / qtc_packaging / debian_fremantle / kitchenalert.postrm
1 #! /bin/sh
2
3 set -e
4
5 #This checks whether there is a newline at the end of the file and adds one if there was not.
6 #Needed because sed deletes the last line if it does not end with a newline 
7
8 perl -e 'use strict;' \
9 -e 'use warnings;' \
10 -e 'open(my $in,  "<",  "/usr/share/policy/etc/current/pulse/xpolicy.conf")  or die "Cannot open /usr/share/policy/etc/current/pulse/xpolicy.conf: $!";' \
11 -e 'my @lines = <$in>;' \
12 -e 'my $lastlineishere = $#lines;' \
13 -e 'my $lastline = $lines[$lastlineishere];' \
14 -e 'unless ($lastline =~ /\n$/){open(my $log, ">>", "/usr/share/policy/etc/current/pulse/xpolicy.conf") or die "Cannot open /usr/share/policy/etc/current/pulse/xpolicy.conf: $!"; print $log "\n"; }'
15  
16 #This removes three subsequent lines from xpolicy.conf if they all match (the lines added by the postinstall script)
17
18 sed -i '
19 /'[stream]'/ {
20 #append a line
21 N
22 #search for KitchenAlert on the second line
23 /\nexe\t= KitchenAlert/ {
24 N
25 #searh next line
26 /\ngroup\t= alarm/ {
27
28 #s/'[stream]'.*alarm//
29 d
30 }}}' /usr/share/policy/etc/current/pulse/xpolicy.conf 
31
32 exit 0
33
34