System parser refactor
This commit is contained in:
parent
f7b736b101
commit
6fa438e81e
32
main.sh
32
main.sh
@ -6,12 +6,11 @@ echo "Backify is starting, looking for configuration file..." >&2
|
|||||||
config='backup.cfg'
|
config='backup.cfg'
|
||||||
config_secured='sbackup.cfg'
|
config_secured='sbackup.cfg'
|
||||||
|
|
||||||
if [ -f "$config" ]
|
if [ ! -f "$config" ]
|
||||||
then
|
then
|
||||||
echo "Configuration found." >&2
|
echo "Error: Config file not found: $config" >&2
|
||||||
else
|
echo "Please create a config file or specify the location of an existing file." >&2
|
||||||
echo "Configuration not found" >&2
|
exit 1
|
||||||
exit
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if grep -E -q -v '^#|^[^ ]*=[^;]*' "$config"; then
|
if grep -E -q -v '^#|^[^ ]*=[^;]*' "$config"; then
|
||||||
@ -32,15 +31,18 @@ fi
|
|||||||
|
|
||||||
function system {
|
function system {
|
||||||
|
|
||||||
if [ -f /etc/redhat-release ]
|
if [ -f /etc/redhat-release ]
|
||||||
then
|
then
|
||||||
system='rhel'
|
echo "Discovered Red Hat-based OS..."
|
||||||
fi
|
system='rhel'
|
||||||
|
elif [ -f /etc/lsb-release ]
|
||||||
if [ -f /etc/lsb-release ]
|
then
|
||||||
then
|
echo "Discovered Ubuntu-based OS..."
|
||||||
system='ubuntu'
|
system='ubuntu'
|
||||||
fi
|
else
|
||||||
|
echo "Error: Unable to detect OS type."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Discovered $system based OS..." >&2
|
echo "Discovered $system based OS..." >&2
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user