-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
package: Add Debian postinst script (#13)
- Loading branch information
Showing
5 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
if [ -e /usr/share/debconf/confmodule ]; then | ||
. /usr/share/debconf/confmodule | ||
db_version 2.0 | ||
db_capb | ||
db_settitle qcp/title | ||
fi | ||
|
||
# We cannot meaningfully preconfigure as postinst checks the filesystem at runtime. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
# By Debian policy, packages must not ask unnecessary questions. | ||
# | ||
# Therefore, we examine the persistent sysctl directories to see | ||
# if there are any mentions of the sysctls we want to set. | ||
# If not, we presume that the system has no special requirements | ||
# (this is expected to be the general case). | ||
|
||
SYSCTL_FILE=20-qcp.conf | ||
SYSCTL_PATH=/etc/sysctl.d/${SYSCTL_FILE} | ||
|
||
. /usr/share/debconf/confmodule | ||
db_version 2.0 | ||
db_capb | ||
db_settitle qcp/title | ||
|
||
#when testing this script, this line resets the db: | ||
#db_fset qcp/sysctl_clash seen false | ||
|
||
check_for_clashing_sysctls() { | ||
for DIR in /etc/sysctl.d /usr/lib/sysctl.d; do | ||
if grep -qcr -e net.core.rmem_max -e net.core.wmem_max --exclude "*${SYSCTL_FILE}*" ${DIR}; then | ||
return 0 | ||
fi | ||
done | ||
return 1 | ||
} | ||
|
||
activate_our_sysctls() { | ||
sysctl -w -p ${SYSCTL_PATH} | ||
} | ||
|
||
disable_our_file() { | ||
if [ -e ${SYSCTL_PATH} ]; then | ||
mv -f ${SYSCTL_PATH} ${SYSCTL_PATH}.disabled | ||
fi | ||
} | ||
|
||
try_to_enable_our_file() { | ||
if [ -e ${SYSCTL_PATH}.disabled ]; then | ||
mv -f ${SYSCTL_PATH}.disabled ${SYSCTL_PATH} | ||
fi | ||
} | ||
|
||
alert_sysadmin() { | ||
db_input high qcp/sysctl_clash || true | ||
db_go || true | ||
|
||
db_get qcp/sysctl_clash || true | ||
case "$RET" in | ||
"install and activate now") | ||
try_to_enable_our_file | ||
activate_our_sysctls | ||
;; | ||
"install but do NOT activate") | ||
try_to_enable_our_file | ||
# do nothing | ||
;; | ||
"do not install") | ||
# they don't want it, OK | ||
disable_our_file | ||
;; | ||
esac | ||
} | ||
|
||
if check_for_clashing_sysctls; then | ||
alert_sysadmin | ||
else | ||
# No clashes; proceed quietly. | ||
activate_our_sysctls | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
if [ -e /usr/share/debconf/confmodule ]; then | ||
. /usr/share/debconf/confmodule | ||
db_version 2 | ||
|
||
case "$1" in | ||
purge) | ||
# Remove my changes to the db. | ||
if [ -e /usr/share/debconf/confmodule ]; then | ||
. /usr/share/debconf/confmodule | ||
db_version 2 | ||
db_purge | ||
fi | ||
;; | ||
esac | ||
|
||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Template: qcp/title | ||
Type: title | ||
Description: qcp sysctl files | ||
|
||
Template: qcp/sysctl_clash | ||
Type: select | ||
Choices: install and activate now, install but do NOT activate, do not install | ||
Default: install and activate now | ||
Description: Install sysctl files for qcp? | ||
qcp has detected a possible sysctl clash! | ||
. | ||
qcp would like to install sysctl files to configure the kernel for good performance. | ||
. | ||
The sysctls used by qcp are: net.core.rmem_max net.core.wmem_max | ||
. | ||
sysctl config files may be found in: /etc/sysctl.d /usr/lib/sysctl.d |