Removing config file entries

This commit is contained in:
Bob Mottram 2016-10-17 13:59:45 +01:00
parent d242b21900
commit 48cb40c2d3
2 changed files with 35 additions and 5 deletions

View File

@ -324,14 +324,13 @@ function remove_htmly {
if [ -d /var/www/$HTMLY_DOMAIN_NAME ]; then if [ -d /var/www/$HTMLY_DOMAIN_NAME ]; then
rm -rf /var/www/$HTMLY_DOMAIN_NAME rm -rf /var/www/$HTMLY_DOMAIN_NAME
fi fi
if [ $HTMLY_CODE ]; then remove_config_param HTMLY_DOMAIN_NAME
sed -i '/HTMLY_DOMAIN_NAME.*/d' $CONFIGURATION_FILE remove_config_param HTMLY_CODE
sed -i '/HTMLY_CODE.*/d' $CONFIGURATION_FILE
fi
function_check remove_onion_service function_check remove_onion_service
remove_onion_service htmly ${HTMLY_ONION_PORT} remove_onion_service htmly ${HTMLY_ONION_PORT}
sed -i '/install_htmly/d' $COMPLETION_FILE remove_completion_param install_htmly
sed -i '/Htmly .*/d' $COMPLETION_FILE sed -i '/Htmly .*/d' $COMPLETION_FILE
sed -i '/htmly .*/d' $COMPLETION_FILE
} }
function get_htmly_admin_password { function get_htmly_admin_password {

View File

@ -229,6 +229,37 @@ function write_config_param {
fi fi
} }
function remove_config_param {
param_name="$1"
if [ ${#param_name} -gt 0 ]; then
if [ $CONFIGURATION_FILE ]; then
if [ -f $CONFIGURATION_FILE ]; then
if grep -q "${param_name}=" $CONFIGURATION_FILE; then
sed -i "/${param_name}=/d" $CONFIGURATION_FILE
fi
fi
fi
fi
}
function remove_completion_param {
param_name="$1"
if [ ${#param_name} -gt 0 ]; then
if [ $COMPLETION_FILE ]; then
if [ -f $COMPLETION_FILE ]; then
if grep -Fxq "${param_name}" $COMPLETION_FILE; then
sed -i "/${param_name}/d" $COMPLETION_FILE
fi
if grep -q "${param_name}:" $COMPLETION_FILE; then
sed -i "/${param_name}:/d" $COMPLETION_FILE
fi
fi
fi
fi
}
function save_configuration_values { function save_configuration_values {
for v in "${configuration_variables[@]}" for v in "${configuration_variables[@]}"
do do