This file is indexed.

postinst is in ampache 3.6~alpha1-0ubuntu6.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

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
#!/bin/sh
# postinst script for Ampache

set -e

#set our variables, placed them in conditional if statements so if apache2 is
#being used lighttpd vars are not created and vice versa.
log="/var/log/ampache"

if [ -e /etc/ampache ]; then
	AMP="/etc/ampache/ampache.conf"
	ELCAMP="/etc/ampache/lighttpd_ampache.conf"
	MAMP="/etc/ampache/mythbuntu.ampache.conf"
	ea=$(ls /etc/ampache)
fi

if [ -e /etc/apache2 ]; then
	APE="/etc/apache2/conf.d"
	APES="/etc/apache2/sites-enabled/mythweb.conf"
	APSA="/etc/apache2/sites-available"
	confd=$(ls $APE)
	sa=$(ls /etc/apache2/sites-available)
	se=$(ls /etc/apache2/sites-enabled)
	default_stock="b38ca5a963f52930ede3f4e1958f3275  /etc/apache2/sites-available/default"
	AA="b17b1eae00bd0ee2d716394ee28bbc62  /etc/apache2/sites-enabled/ApacheAmpache"
fi

if [ -e /etc/lighttpd ]; then
	ELCA="/etc/lighttpd/conf-available"
	EM="/usr/sbin/lighty-enable-mod"
fi

#read in the debconf module
. /usr/share/debconf/confmodule

#apache2 sanity checks
sc010_check() {
	#check to see if ampache.conf is present and enabled.
	sc010=1
	if [ "$ea" = "ampache.conf" ]; then
		if [ "$confd" = "ampache.conf" ]; then
				printf "ampache.conf is present and enabled.\n"
				sc010=enabled
		fi
	fi
}

sc101_check() {
	#check to see of ApacheAmpache is enabled
	sc101=1
	if [ "$se" = "ApacheAmpache" ]; then
		AA_user=$(md5sum /etc/apache2/sites-enabled/ApacheAmpache)
		if [ "$AA_user" = "$AA" ]; then
			printf "ApacheAmpache is enabled ampache vhost already exists.\n"
			sc101=enabled
		fi
	fi
}

sc102_check() {
	#check to see if ampvhadd has been created and is being used.
	sc102=1
	if [ "$se" = "ampvhadd" ]; then
		sc102=enabled
	fi
}

sc103_check() {
	#check to see if 000-default is enabled
	sc103=1
	if [ "$se" = "000-default" ]; then
		sc103=enabled
	fi
}

sc104_check() {
	#check to see if 000-default has been modified
	sc104=1
	if [ "$sc103" = "enabled" ]; then
		default_users=$(md5sum /etc/apache2/sites-available/default)
		if [ "$default_stock" = "$default_users" ]; then
			sc104=equal
		fi
	fi
}

apache_install() {
	#do our sanity checks and install ampache accordingly
	sc010_check
	sc101_check
	sc102_check
	sc103_check
	sc104_check
	printf "Our vars are:\n"
	printf "sc010 is $sc010\n"
	printf "sc101 is $sc101\n"
	printf "sc102 is $sc102\n"
	printf "sc103 is $sc103\n"
	printf "sc104 is $sc104\n"
	if [ "$sc010" = "enabled" ]; then
		printf "ampache.conf is enabled let's use it.\n"
		return 0
	elif [ "$sc010" = "1" ] && [ "$sc101" = "enabled" ]; then
		printf "ApacheAmpache is enabled ampache vhost already exists.\n"
		return 0
	elif [ "$sc010" = "1" ] && [ "$sc101" = "1" ] && [ "$sc102" = "enabled" ]; then
		printf "ampvhadd is enabled ampache vhost already exists.\n"
		return 0
	elif [ "$sc010" = "1" ] && [ "$sc101" = "1" ] && [ "$sc102" = "1" ] && \
		[ "$sc103" = "enabled" ] && [ "$sc104" = "equal" ]; then
		default_users=$(md5sum /etc/apache2/sites-available/default)
		printf "enabling ApacheAmpache.\n"
		if [ "$default_stock" = "$default_users" ]; then
			a2dissite default
			a2ensite ApacheAmpache
			rm -f $ELCAMP
			rm -f $MAMP
		fi
	elif [ "$sc010" = "1" ] && [ "$sc101" = "1" ] && [ "$sc102" = "1" ] && \
		[ "$sc103" = "enabled" ] && ["$sc104" = "1" ]; then
		printf "need to create ampvhadd\n"
		cp -p $APSA/default $APSA/default2
		if [ -f $APSA/default2 ]; then
			sed -e s'/<\/VirtualHost>//' $APSA/default2 > $APSA/default3
			cat $APSA/default3 /usr/share/ampache/vhost > $APSA/ampvhadd
			if [ -e $APSA/ampvhadd ]; then
				a2dissite default
				a2ensite ampvhadd
				rm -f $APSA/ApacheAmpache
				rm -f $APSA/default2
				rm -f $APSA/default3
			fi
		fi
	else
		printf "Something weird has happened,  unable to create ampache vhost.\n"
	fi
}

#Configure the lighttpd webserver.
lighttpd_install() {
    if [ ! -f $ELCA/50-ampache.conf ] ; then
        if [ ! -x $EM ] ; then
            printf "Lighttpd not installed, skipping.\n"
        else
            ln -s $ELCAMP $ELCA/50-ampache.conf
            $EM ampache
            rm -f $AMP
			rm -f $MAMP
        fi
    fi
}

#Configure the apache2 webserver on Mythbuntu.
mythbuntu_apache_install() {
    if [ -e $APE/mythbuntu.ampache.conf ]; then
		printf "mythbuntu symlink already exists"
	else
		ln -s $MAMP $APE/mythbuntu.ampache.conf
        rm -f $ELCAMP
        rm -f $AMP
    fi
}

if [ "$1" = "configure" ] || [ "1" = "upgrade" ]; then
	#find out what type of webserver we have
	db_get ampache/webserver_type || true
	webservers="$RET"
	#ask the user if we need to restart/reload the webserver
	db_get ampache/restart_webserver || true
	if [ "$RET" = "false" ]; then
        #if false install everything and DO NOT reload the webserver config
		if [ "$webservers" = "apache2" ]; then
			if [ -d /var/www/mythweb ] && [ -f $APES ]; then
				mythbuntu_apache_install
			else
				apache_install
			fi
		elif [ "$webservers" = "lighttpd" ] ; then
			lighttpd_install
		else
			printf "unable to configure ampache.\n"
		fi
		if [ -d $log ]; then
			chmod 755 $log
			chown www-data:www-data $log
		fi
		#exit gracefully and let the user restart the webserver
		exit 0
	elif [ "$RET" = "true" ]; then
        #if true install every thing AND reload the webserver config
		if [ "$webservers" = "apache2" ]; then
			if [ -d /var/www/mythweb ] && [ -f $APES ]; then
				mythbuntu_apache_install
			else
				apache_install
			fi
		elif [ "$webservers" = "lighttpd" ] ; then
				lighttpd_install
		else
			printf "unable to configure and reload $webservers config file\n"
		fi
		#reload the webserver config
		if [ -x /usr/sbin/invoke-rc.d ]; then
			invoke-rc.d $webservers reload 3>/dev/null || true
		else
			/etc/init.d/$webservers reload 3>/dev/null || true
		fi
		#set log file owner and permissions
		if [ -d $log ]; then
			chmod 755 $log
			chown www-data:www-data $log
		fi
	else
		printf "Something weird has happened, unable to configure ampache.\n"
	fi
fi



exit 0