mirror of
https://github.com/mrworf/plexupdate.git
synced 2025-08-19 04:49:34 -07:00
remove duplicated code for saving config
This commit is contained in:
parent
35fea18230
commit
e9cecfcc96
1 changed files with 7 additions and 13 deletions
|
@ -316,17 +316,7 @@ save_cronjob() {
|
||||||
echo "#minute hour mday month wday who command" >> $CONFIGTEMP
|
echo "#minute hour mday month wday who command" >> $CONFIGTEMP
|
||||||
echo "$1" >> $CONFIGTEMP
|
echo "$1" >> $CONFIGTEMP
|
||||||
|
|
||||||
echo
|
save_config_tmp "$CONFIGTEMP" "$2"
|
||||||
echo -n "Writing cron job file '$2'... "
|
|
||||||
|
|
||||||
# most likely writing to /etc, so we need sudo
|
|
||||||
sudo tee "$2" > /dev/null < "$CONFIGTEMP"
|
|
||||||
sudo chmod 640 "$2"
|
|
||||||
# only root can modify the config, but the user can still read it
|
|
||||||
sudo chown 0:$(id -g) "$2"
|
|
||||||
rm "$CONFIGTEMP"
|
|
||||||
|
|
||||||
echo "done"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
save_config() {
|
save_config() {
|
||||||
|
@ -337,15 +327,19 @@ save_config() {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
save_config_tmp "$CONFIGTEMP" "$2"
|
||||||
|
}
|
||||||
|
|
||||||
|
save_config_tmp() {
|
||||||
echo
|
echo
|
||||||
echo -n "Writing configuration file '$2'... "
|
echo -n "Writing configuration file '$2'... "
|
||||||
|
|
||||||
# most likely writing to /etc, so we need sudo
|
# most likely writing to /etc, so we need sudo
|
||||||
sudo tee "$2" > /dev/null < "$CONFIGTEMP"
|
sudo tee "$2" > /dev/null < "$1"
|
||||||
sudo chmod 640 "$2"
|
sudo chmod 640 "$2"
|
||||||
# only root can modify the config, but the user can still read it
|
# only root can modify the config, but the user can still read it
|
||||||
sudo chown 0:$(id -g) "$2"
|
sudo chown 0:$(id -g) "$2"
|
||||||
rm "$CONFIGTEMP"
|
rm "$1"
|
||||||
|
|
||||||
echo "done"
|
echo "done"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue