All content currently on this blog will remain here and be maintained. New content will be posted to the new site.
These are useful for grabbing details from the user where necessary, but are annoying when trying to automate the installation of many packages, or when one needs to ensure the same details are used across multiple systems and the user does not make a mistake.
Luckily, one can preconfigure the answers to the prompts through the use of debconf. For example, if one wants to automatically install mysql server on debian without seeing any pompts, you simply run the following commands before running
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password $DATABASE_PASS" sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $DATABASE_PASS"
However, how does one know what to pass to debconf-set-selections? Here is the script that I use. Make sure to update the PACKAGE_NAME variable
PACKAGE_NAME="" cd /tmp aptitude download $PACKAGE_NAME mv $PACKAGE_NAME* $PACKAGE_NAME.deb mkdir control_files dpkg-deb -e $PACKAGE_NAME.deb control_files/ grep -e '^Template:' -e '^Type:' -e '^Default:' \ control_files/templates | xargs | sed \ -e 's/\s*Template: /\npackagename\t/g' \ -e 's/\s*Type: */\t/g' \ -e 's/\s*Default: */\t/g' # cleanup rm -rf control_files rm $PACKAGE_NAME.debExample output:
packagename glance/register-endpoint boolean false packagename glance/keystone-ip string packagename glance/keystone-auth-token password packagename glance/endpoint-ip string packagename glance/region-name string regionOne
If you ever remove a package, the debconf settings will still be there. This means that if you were to reinstall something like MySQL, it would re-use the original password settings rather than ask you for new ones!
To clear the debconf settings for a package, run the following command.
echo PURGE | sudo debconf-communicate $PACKAGE_NAMETo show any debconf settings for a package, use:
sudo debconf-show $PACKAGE_NAME
The following script changes the timeout for the Grub startup menu to just 1 second.
SEARCH="set timeout=.*" REPLACE="set timeout=1" FILEPATH="/boot/grub/grub.cfg" sudo sed -i "s;$SEARCH;$REPLACE;g" $FILEPATH
Alternatively, execute the command below:
curl -s https://scripts.programster.org/scripts/8?output=raw | bash