Call backup_file when modify some conf file in 1.2 and 1.3

This commit is contained in:
Samson-W 2021-06-09 23:08:25 +08:00
parent d6fca32f10
commit 88983fe3a9
2 changed files with 9 additions and 4 deletions

View File

@ -65,8 +65,8 @@ apply_debian () {
warn "Set to enabled signature of packages option"
for CONFFILE in $(grep -i "${OPTION}" /etc/apt/ -Ir | grep -v "^#" | awk -F: '{print $1}')
do
sed -i "/${OPTION}/d" ${CONFFILE}
#sed -i "s/${OPTION}.*true.*/${OPTION} \"false\";/g" ${CONFFILE}
backup_file ${CONFFILE}
sed -i "s/^${OPTION}/#&/" ${CONFFILE}
done
fi
}
@ -75,9 +75,12 @@ apply_centos () {
ok "The signature of packages option is enable "
elif [ $FNRET = 1 ]; then
warn "Set to enabled signature of packages option"
backup_file $YUM_CONF
sed -i "s/$YUM_OPTION=.*/$YUM_OPTION=1/g" $YUM_CONF
else
warn "Add $YUM_OPTION option to $YUM_CONF"
backup_file $YUM_CONF
add_end_of_file $YUM_CONF "$YUM_OPTION=1"
fi
}

View File

@ -63,8 +63,8 @@ apply_debian () {
ok "The signature of local packages option is enable "
else
warn "Set to enabled signature of local packages option"
sed -i "/^${OPTION}/d" ${CONFFILE}
#sed -i "s/${OPTION}.*true.*/${OPTION} \"false\";/g" ${CONFFILE}
backup_file $CONFFILE
sed -i "s/^${OPTION}/#&/" ${CONFFILE}
fi
}
@ -72,9 +72,11 @@ apply_centos () {
if [ $FNRET = 0 ]; then
ok "The signature of packages option is enable "
elif [ $FNRET = 1 ]; then
backup_file $YUM_CONFFILE
warn "Set to enabled signature of packages option"
sed -i "s/$YUM_OPTION=.*/$YUM_OPTION=1/g" $YUM_CONFFILE
else
backup_file $YUM_CONFFILE
warn "Add $YUM_OPTION option to $YUM_CONFFILE"
add_end_of_file $YUM_CONFFILE "$YUM_OPTION=1"
fi