Skip to content

Commit

Permalink
New: install.sh can preserve old configuration file (--keep-configu…
Browse files Browse the repository at this point in the history
…ration)
  • Loading branch information
petersulyok committed Aug 16, 2023
1 parent b10f345 commit c005e03
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,20 @@ if [[ $EUID -ne 0 ]]; then
exit 1
fi

# Display help text
if [ "$1" == "--help" ] || [ "$1" == "-h" ]; then
echo "usage: $(basename $0) -h --help --keep-config"
echo " -h, --help help text"
echo " --keep-config keep the original configuration file"
exit 0
fi

# Backup original files
if [ -f "$TARGET_DIR/smfc.py" ]; then
cp "$TARGET_DIR/smfc.py" "$TARGET_DIR/smfc.py.$POSTFIX"
cp "$TARGET_DIR/smfc.conf" "$TARGET_DIR/smfc.conf.$POSTFIX"
if [ "$1" != "--keep-config" ]; then
cp "$TARGET_DIR/smfc.conf" "$TARGET_DIR/smfc.conf.$POSTFIX"
fi
fi

# Create the target folder if does not exist
Expand All @@ -26,10 +36,13 @@ fi

# Copy new files to the target folders
cp ./src/smfc.py "$TARGET_DIR/"
cp ./src/smfc.conf "$TARGET_DIR/"
if [ "$1" != "--keep-config" ]; then
cp ./src/smfc.conf "$TARGET_DIR/"
chown root:root "$TARGET_DIR/smfc.py"
fi
cp ./src/smfc /etc/default/
cp ./src/smfc.service /etc/systemd/system/
chown root:root "$TARGET_DIR/smfc.py" "$TARGET_DIR/smfc.conf" /etc/default/smfc /etc/systemd/system/smfc.service
chown root:root "$TARGET_DIR/smfc.py" /etc/default/smfc /etc/systemd/system/smfc.service

# Generate a real hd_names= entry in the new 'smfc.conf'.
hd_name=$(ls -l /dev/disk/by-id/|grep .*ata-.*sda$|tr -s ' '|cut -d' ' -f 9)
Expand Down

0 comments on commit c005e03

Please sign in to comment.