Apply update script changes (#328)

Applies #327

Signed-off-by: Wouter Born <github@maindrain.net>
pull/329/head
Wouter Born 2020-12-16 11:32:31 +01:00 committed by GitHub
parent 596ce8a3b3
commit 45ad19b417
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 360 additions and 100 deletions

View File

@ -40,9 +40,12 @@ run_command() {
case $command in case $command in
'DEFAULT') 'DEFAULT')
# Just rename the file, the update process adds back the new version if [ -f "$param1" ]; then
echo " Adding '.bak' to $param1" echo " Adding '.bak' to $param1"
mv "$param1" "$param1.bak" mv "$param1" "$param1.bak"
fi
echo " Using default file $param1"
cp "$(echo "$param1" | sed "s:${OPENHAB_HOME}:${OPENHAB_HOME}/dist:g")" "$param1"
;; ;;
'DELETE') 'DELETE')
# We should be strict and specific here, i.e only delete one file. # We should be strict and specific here, i.e only delete one file.
@ -59,8 +62,18 @@ run_command() {
fi fi
;; ;;
'MOVE') 'MOVE')
echo " Moving: From $param1 to $param2" # Avoid error if file or directory does not exist
mv "$param1" "$param2" if [ -e "$param1" ]; then
echo " Moving: From $param1 to $param2"
file_dir=$(dirname "$param2")
# Create directory with same ownership as file
if [ ! -d file_dir ]; then
mkdir -p "$file_dir"
prev_user_group=$(ls -ld "$param1" | awk '{print $3 ":" $4}')
chown -R "$prev_user_group" "$file_dir"
fi
mv "$param1" "$param2"
fi
;; ;;
'REPLACE') 'REPLACE')
# Avoid error if file does not exist # Avoid error if file does not exist

View File

@ -40,9 +40,12 @@ run_command() {
case $command in case $command in
'DEFAULT') 'DEFAULT')
# Just rename the file, the update process adds back the new version if [ -f "$param1" ]; then
echo " Adding '.bak' to $param1" echo " Adding '.bak' to $param1"
mv "$param1" "$param1.bak" mv "$param1" "$param1.bak"
fi
echo " Using default file $param1"
cp "$(echo "$param1" | sed "s:${OPENHAB_HOME}:${OPENHAB_HOME}/dist:g")" "$param1"
;; ;;
'DELETE') 'DELETE')
# We should be strict and specific here, i.e only delete one file. # We should be strict and specific here, i.e only delete one file.
@ -59,8 +62,18 @@ run_command() {
fi fi
;; ;;
'MOVE') 'MOVE')
echo " Moving: From $param1 to $param2" # Avoid error if file or directory does not exist
mv "$param1" "$param2" if [ -e "$param1" ]; then
echo " Moving: From $param1 to $param2"
file_dir=$(dirname "$param2")
# Create directory with same ownership as file
if [ ! -d file_dir ]; then
mkdir -p "$file_dir"
prev_user_group=$(ls -ld "$param1" | awk '{print $3 ":" $4}')
chown -R "$prev_user_group" "$file_dir"
fi
mv "$param1" "$param2"
fi
;; ;;
'REPLACE') 'REPLACE')
# Avoid error if file does not exist # Avoid error if file does not exist

View File

@ -40,9 +40,12 @@ run_command() {
case $command in case $command in
'DEFAULT') 'DEFAULT')
# Just rename the file, the update process adds back the new version if [ -f "$param1" ]; then
echo " Adding '.bak' to $param1" echo " Adding '.bak' to $param1"
mv "$param1" "$param1.bak" mv "$param1" "$param1.bak"
fi
echo " Using default file $param1"
cp "$(echo "$param1" | sed "s:${OPENHAB_HOME}:${OPENHAB_HOME}/dist:g")" "$param1"
;; ;;
'DELETE') 'DELETE')
# We should be strict and specific here, i.e only delete one file. # We should be strict and specific here, i.e only delete one file.
@ -59,8 +62,18 @@ run_command() {
fi fi
;; ;;
'MOVE') 'MOVE')
echo " Moving: From $param1 to $param2" # Avoid error if file or directory does not exist
mv "$param1" "$param2" if [ -e "$param1" ]; then
echo " Moving: From $param1 to $param2"
file_dir=$(dirname "$param2")
# Create directory with same ownership as file
if [ ! -d file_dir ]; then
mkdir -p "$file_dir"
prev_user_group=$(ls -ld "$param1" | awk '{print $3 ":" $4}')
chown -R "$prev_user_group" "$file_dir"
fi
mv "$param1" "$param2"
fi
;; ;;
'REPLACE') 'REPLACE')
# Avoid error if file does not exist # Avoid error if file does not exist

View File

@ -40,9 +40,12 @@ run_command() {
case $command in case $command in
'DEFAULT') 'DEFAULT')
# Just rename the file, the update process adds back the new version if [ -f "$param1" ]; then
echo " Adding '.bak' to $param1" echo " Adding '.bak' to $param1"
mv "$param1" "$param1.bak" mv "$param1" "$param1.bak"
fi
echo " Using default file $param1"
cp "$(echo "$param1" | sed "s:${OPENHAB_HOME}:${OPENHAB_HOME}/dist:g")" "$param1"
;; ;;
'DELETE') 'DELETE')
# We should be strict and specific here, i.e only delete one file. # We should be strict and specific here, i.e only delete one file.
@ -59,8 +62,18 @@ run_command() {
fi fi
;; ;;
'MOVE') 'MOVE')
echo " Moving: From $param1 to $param2" # Avoid error if file or directory does not exist
mv "$param1" "$param2" if [ -e "$param1" ]; then
echo " Moving: From $param1 to $param2"
file_dir=$(dirname "$param2")
# Create directory with same ownership as file
if [ ! -d file_dir ]; then
mkdir -p "$file_dir"
prev_user_group=$(ls -ld "$param1" | awk '{print $3 ":" $4}')
chown -R "$prev_user_group" "$file_dir"
fi
mv "$param1" "$param2"
fi
;; ;;
'REPLACE') 'REPLACE')
# Avoid error if file does not exist # Avoid error if file does not exist

View File

@ -40,9 +40,12 @@ run_command() {
case $command in case $command in
'DEFAULT') 'DEFAULT')
# Just rename the file, the update process adds back the new version if [ -f "$param1" ]; then
echo " Adding '.bak' to $param1" echo " Adding '.bak' to $param1"
mv "$param1" "$param1.bak" mv "$param1" "$param1.bak"
fi
echo " Using default file $param1"
cp "$(echo "$param1" | sed "s:${OPENHAB_HOME}:${OPENHAB_HOME}/dist:g")" "$param1"
;; ;;
'DELETE') 'DELETE')
# We should be strict and specific here, i.e only delete one file. # We should be strict and specific here, i.e only delete one file.
@ -59,8 +62,18 @@ run_command() {
fi fi
;; ;;
'MOVE') 'MOVE')
echo " Moving: From $param1 to $param2" # Avoid error if file or directory does not exist
mv "$param1" "$param2" if [ -e "$param1" ]; then
echo " Moving: From $param1 to $param2"
file_dir=$(dirname "$param2")
# Create directory with same ownership as file
if [ ! -d file_dir ]; then
mkdir -p "$file_dir"
prev_user_group=$(ls -ld "$param1" | awk '{print $3 ":" $4}')
chown -R "$prev_user_group" "$file_dir"
fi
mv "$param1" "$param2"
fi
;; ;;
'REPLACE') 'REPLACE')
# Avoid error if file does not exist # Avoid error if file does not exist

View File

@ -40,9 +40,12 @@ run_command() {
case $command in case $command in
'DEFAULT') 'DEFAULT')
# Just rename the file, the update process adds back the new version if [ -f "$param1" ]; then
echo " Adding '.bak' to $param1" echo " Adding '.bak' to $param1"
mv "$param1" "$param1.bak" mv "$param1" "$param1.bak"
fi
echo " Using default file $param1"
cp "$(echo "$param1" | sed "s:${OPENHAB_HOME}:${OPENHAB_HOME}/dist:g")" "$param1"
;; ;;
'DELETE') 'DELETE')
# We should be strict and specific here, i.e only delete one file. # We should be strict and specific here, i.e only delete one file.
@ -59,8 +62,18 @@ run_command() {
fi fi
;; ;;
'MOVE') 'MOVE')
echo " Moving: From $param1 to $param2" # Avoid error if file or directory does not exist
mv "$param1" "$param2" if [ -e "$param1" ]; then
echo " Moving: From $param1 to $param2"
file_dir=$(dirname "$param2")
# Create directory with same ownership as file
if [ ! -d file_dir ]; then
mkdir -p "$file_dir"
prev_user_group=$(ls -ld "$param1" | awk '{print $3 ":" $4}')
chown -R "$prev_user_group" "$file_dir"
fi
mv "$param1" "$param2"
fi
;; ;;
'REPLACE') 'REPLACE')
# Avoid error if file does not exist # Avoid error if file does not exist

View File

@ -40,9 +40,12 @@ run_command() {
case $command in case $command in
'DEFAULT') 'DEFAULT')
# Just rename the file, the update process adds back the new version if [ -f "$param1" ]; then
echo " Adding '.bak' to $param1" echo " Adding '.bak' to $param1"
mv "$param1" "$param1.bak" mv "$param1" "$param1.bak"
fi
echo " Using default file $param1"
cp "$(echo "$param1" | sed "s:${OPENHAB_HOME}:${OPENHAB_HOME}/dist:g")" "$param1"
;; ;;
'DELETE') 'DELETE')
# We should be strict and specific here, i.e only delete one file. # We should be strict and specific here, i.e only delete one file.
@ -59,8 +62,18 @@ run_command() {
fi fi
;; ;;
'MOVE') 'MOVE')
echo " Moving: From $param1 to $param2" # Avoid error if file or directory does not exist
mv "$param1" "$param2" if [ -e "$param1" ]; then
echo " Moving: From $param1 to $param2"
file_dir=$(dirname "$param2")
# Create directory with same ownership as file
if [ ! -d file_dir ]; then
mkdir -p "$file_dir"
prev_user_group=$(ls -ld "$param1" | awk '{print $3 ":" $4}')
chown -R "$prev_user_group" "$file_dir"
fi
mv "$param1" "$param2"
fi
;; ;;
'REPLACE') 'REPLACE')
# Avoid error if file does not exist # Avoid error if file does not exist

View File

@ -40,9 +40,12 @@ run_command() {
case $command in case $command in
'DEFAULT') 'DEFAULT')
# Just rename the file, the update process adds back the new version if [ -f "$param1" ]; then
echo " Adding '.bak' to $param1" echo " Adding '.bak' to $param1"
mv "$param1" "$param1.bak" mv "$param1" "$param1.bak"
fi
echo " Using default file $param1"
cp "$(echo "$param1" | sed "s:${OPENHAB_HOME}:${OPENHAB_HOME}/dist:g")" "$param1"
;; ;;
'DELETE') 'DELETE')
# We should be strict and specific here, i.e only delete one file. # We should be strict and specific here, i.e only delete one file.
@ -59,8 +62,18 @@ run_command() {
fi fi
;; ;;
'MOVE') 'MOVE')
echo " Moving: From $param1 to $param2" # Avoid error if file or directory does not exist
mv "$param1" "$param2" if [ -e "$param1" ]; then
echo " Moving: From $param1 to $param2"
file_dir=$(dirname "$param2")
# Create directory with same ownership as file
if [ ! -d file_dir ]; then
mkdir -p "$file_dir"
prev_user_group=$(ls -ld "$param1" | awk '{print $3 ":" $4}')
chown -R "$prev_user_group" "$file_dir"
fi
mv "$param1" "$param2"
fi
;; ;;
'REPLACE') 'REPLACE')
# Avoid error if file does not exist # Avoid error if file does not exist

View File

@ -40,9 +40,12 @@ run_command() {
case $command in case $command in
'DEFAULT') 'DEFAULT')
# Just rename the file, the update process adds back the new version if [ -f "$param1" ]; then
echo " Adding '.bak' to $param1" echo " Adding '.bak' to $param1"
mv "$param1" "$param1.bak" mv "$param1" "$param1.bak"
fi
echo " Using default file $param1"
cp "$(echo "$param1" | sed "s:${OPENHAB_HOME}:${OPENHAB_HOME}/dist:g")" "$param1"
;; ;;
'DELETE') 'DELETE')
# We should be strict and specific here, i.e only delete one file. # We should be strict and specific here, i.e only delete one file.
@ -59,8 +62,18 @@ run_command() {
fi fi
;; ;;
'MOVE') 'MOVE')
echo " Moving: From $param1 to $param2" # Avoid error if file or directory does not exist
mv "$param1" "$param2" if [ -e "$param1" ]; then
echo " Moving: From $param1 to $param2"
file_dir=$(dirname "$param2")
# Create directory with same ownership as file
if [ ! -d file_dir ]; then
mkdir -p "$file_dir"
prev_user_group=$(ls -ld "$param1" | awk '{print $3 ":" $4}')
chown -R "$prev_user_group" "$file_dir"
fi
mv "$param1" "$param2"
fi
;; ;;
'REPLACE') 'REPLACE')
# Avoid error if file does not exist # Avoid error if file does not exist

View File

@ -40,9 +40,12 @@ run_command() {
case $command in case $command in
'DEFAULT') 'DEFAULT')
# Just rename the file, the update process adds back the new version if [ -f "$param1" ]; then
echo " Adding '.bak' to $param1" echo " Adding '.bak' to $param1"
mv "$param1" "$param1.bak" mv "$param1" "$param1.bak"
fi
echo " Using default file $param1"
cp "$(echo "$param1" | sed "s:${OPENHAB_HOME}:${OPENHAB_HOME}/dist:g")" "$param1"
;; ;;
'DELETE') 'DELETE')
# We should be strict and specific here, i.e only delete one file. # We should be strict and specific here, i.e only delete one file.
@ -59,8 +62,18 @@ run_command() {
fi fi
;; ;;
'MOVE') 'MOVE')
echo " Moving: From $param1 to $param2" # Avoid error if file or directory does not exist
mv "$param1" "$param2" if [ -e "$param1" ]; then
echo " Moving: From $param1 to $param2"
file_dir=$(dirname "$param2")
# Create directory with same ownership as file
if [ ! -d file_dir ]; then
mkdir -p "$file_dir"
prev_user_group=$(ls -ld "$param1" | awk '{print $3 ":" $4}')
chown -R "$prev_user_group" "$file_dir"
fi
mv "$param1" "$param2"
fi
;; ;;
'REPLACE') 'REPLACE')
# Avoid error if file does not exist # Avoid error if file does not exist

View File

@ -40,9 +40,12 @@ run_command() {
case $command in case $command in
'DEFAULT') 'DEFAULT')
# Just rename the file, the update process adds back the new version if [ -f "$param1" ]; then
echo " Adding '.bak' to $param1" echo " Adding '.bak' to $param1"
mv "$param1" "$param1.bak" mv "$param1" "$param1.bak"
fi
echo " Using default file $param1"
cp "$(echo "$param1" | sed "s:${OPENHAB_HOME}:${OPENHAB_HOME}/dist:g")" "$param1"
;; ;;
'DELETE') 'DELETE')
# We should be strict and specific here, i.e only delete one file. # We should be strict and specific here, i.e only delete one file.
@ -59,8 +62,18 @@ run_command() {
fi fi
;; ;;
'MOVE') 'MOVE')
echo " Moving: From $param1 to $param2" # Avoid error if file or directory does not exist
mv "$param1" "$param2" if [ -e "$param1" ]; then
echo " Moving: From $param1 to $param2"
file_dir=$(dirname "$param2")
# Create directory with same ownership as file
if [ ! -d file_dir ]; then
mkdir -p "$file_dir"
prev_user_group=$(ls -ld "$param1" | awk '{print $3 ":" $4}')
chown -R "$prev_user_group" "$file_dir"
fi
mv "$param1" "$param2"
fi
;; ;;
'REPLACE') 'REPLACE')
# Avoid error if file does not exist # Avoid error if file does not exist

View File

@ -40,9 +40,12 @@ run_command() {
case $command in case $command in
'DEFAULT') 'DEFAULT')
# Just rename the file, the update process adds back the new version if [ -f "$param1" ]; then
echo " Adding '.bak' to $param1" echo " Adding '.bak' to $param1"
mv "$param1" "$param1.bak" mv "$param1" "$param1.bak"
fi
echo " Using default file $param1"
cp "$(echo "$param1" | sed "s:${OPENHAB_HOME}:${OPENHAB_HOME}/dist:g")" "$param1"
;; ;;
'DELETE') 'DELETE')
# We should be strict and specific here, i.e only delete one file. # We should be strict and specific here, i.e only delete one file.
@ -59,8 +62,18 @@ run_command() {
fi fi
;; ;;
'MOVE') 'MOVE')
echo " Moving: From $param1 to $param2" # Avoid error if file or directory does not exist
mv "$param1" "$param2" if [ -e "$param1" ]; then
echo " Moving: From $param1 to $param2"
file_dir=$(dirname "$param2")
# Create directory with same ownership as file
if [ ! -d file_dir ]; then
mkdir -p "$file_dir"
prev_user_group=$(ls -ld "$param1" | awk '{print $3 ":" $4}')
chown -R "$prev_user_group" "$file_dir"
fi
mv "$param1" "$param2"
fi
;; ;;
'REPLACE') 'REPLACE')
# Avoid error if file does not exist # Avoid error if file does not exist

View File

@ -40,9 +40,12 @@ run_command() {
case $command in case $command in
'DEFAULT') 'DEFAULT')
# Just rename the file, the update process adds back the new version if [ -f "$param1" ]; then
echo " Adding '.bak' to $param1" echo " Adding '.bak' to $param1"
mv "$param1" "$param1.bak" mv "$param1" "$param1.bak"
fi
echo " Using default file $param1"
cp "$(echo "$param1" | sed "s:${OPENHAB_HOME}:${OPENHAB_HOME}/dist:g")" "$param1"
;; ;;
'DELETE') 'DELETE')
# We should be strict and specific here, i.e only delete one file. # We should be strict and specific here, i.e only delete one file.
@ -59,8 +62,18 @@ run_command() {
fi fi
;; ;;
'MOVE') 'MOVE')
echo " Moving: From $param1 to $param2" # Avoid error if file or directory does not exist
mv "$param1" "$param2" if [ -e "$param1" ]; then
echo " Moving: From $param1 to $param2"
file_dir=$(dirname "$param2")
# Create directory with same ownership as file
if [ ! -d file_dir ]; then
mkdir -p "$file_dir"
prev_user_group=$(ls -ld "$param1" | awk '{print $3 ":" $4}')
chown -R "$prev_user_group" "$file_dir"
fi
mv "$param1" "$param2"
fi
;; ;;
'REPLACE') 'REPLACE')
# Avoid error if file does not exist # Avoid error if file does not exist

View File

@ -40,9 +40,12 @@ run_command() {
case $command in case $command in
'DEFAULT') 'DEFAULT')
# Just rename the file, the update process adds back the new version if [ -f "$param1" ]; then
echo " Adding '.bak' to $param1" echo " Adding '.bak' to $param1"
mv "$param1" "$param1.bak" mv "$param1" "$param1.bak"
fi
echo " Using default file $param1"
cp "$(echo "$param1" | sed "s:${OPENHAB_HOME}:${OPENHAB_HOME}/dist:g")" "$param1"
;; ;;
'DELETE') 'DELETE')
# We should be strict and specific here, i.e only delete one file. # We should be strict and specific here, i.e only delete one file.
@ -59,8 +62,18 @@ run_command() {
fi fi
;; ;;
'MOVE') 'MOVE')
echo " Moving: From $param1 to $param2" # Avoid error if file or directory does not exist
mv "$param1" "$param2" if [ -e "$param1" ]; then
echo " Moving: From $param1 to $param2"
file_dir=$(dirname "$param2")
# Create directory with same ownership as file
if [ ! -d file_dir ]; then
mkdir -p "$file_dir"
prev_user_group=$(ls -ld "$param1" | awk '{print $3 ":" $4}')
chown -R "$prev_user_group" "$file_dir"
fi
mv "$param1" "$param2"
fi
;; ;;
'REPLACE') 'REPLACE')
# Avoid error if file does not exist # Avoid error if file does not exist

View File

@ -40,9 +40,12 @@ run_command() {
case $command in case $command in
'DEFAULT') 'DEFAULT')
# Just rename the file, the update process adds back the new version if [ -f "$param1" ]; then
echo " Adding '.bak' to $param1" echo " Adding '.bak' to $param1"
mv "$param1" "$param1.bak" mv "$param1" "$param1.bak"
fi
echo " Using default file $param1"
cp "$(echo "$param1" | sed "s:${OPENHAB_HOME}:${OPENHAB_HOME}/dist:g")" "$param1"
;; ;;
'DELETE') 'DELETE')
# We should be strict and specific here, i.e only delete one file. # We should be strict and specific here, i.e only delete one file.
@ -59,8 +62,18 @@ run_command() {
fi fi
;; ;;
'MOVE') 'MOVE')
echo " Moving: From $param1 to $param2" # Avoid error if file or directory does not exist
mv "$param1" "$param2" if [ -e "$param1" ]; then
echo " Moving: From $param1 to $param2"
file_dir=$(dirname "$param2")
# Create directory with same ownership as file
if [ ! -d file_dir ]; then
mkdir -p "$file_dir"
prev_user_group=$(ls -ld "$param1" | awk '{print $3 ":" $4}')
chown -R "$prev_user_group" "$file_dir"
fi
mv "$param1" "$param2"
fi
;; ;;
'REPLACE') 'REPLACE')
# Avoid error if file does not exist # Avoid error if file does not exist

View File

@ -40,9 +40,12 @@ run_command() {
case $command in case $command in
'DEFAULT') 'DEFAULT')
# Just rename the file, the update process adds back the new version if [ -f "$param1" ]; then
echo " Adding '.bak' to $param1" echo " Adding '.bak' to $param1"
mv "$param1" "$param1.bak" mv "$param1" "$param1.bak"
fi
echo " Using default file $param1"
cp "$(echo "$param1" | sed "s:${OPENHAB_HOME}:${OPENHAB_HOME}/dist:g")" "$param1"
;; ;;
'DELETE') 'DELETE')
# We should be strict and specific here, i.e only delete one file. # We should be strict and specific here, i.e only delete one file.
@ -59,8 +62,18 @@ run_command() {
fi fi
;; ;;
'MOVE') 'MOVE')
echo " Moving: From $param1 to $param2" # Avoid error if file or directory does not exist
mv "$param1" "$param2" if [ -e "$param1" ]; then
echo " Moving: From $param1 to $param2"
file_dir=$(dirname "$param2")
# Create directory with same ownership as file
if [ ! -d file_dir ]; then
mkdir -p "$file_dir"
prev_user_group=$(ls -ld "$param1" | awk '{print $3 ":" $4}')
chown -R "$prev_user_group" "$file_dir"
fi
mv "$param1" "$param2"
fi
;; ;;
'REPLACE') 'REPLACE')
# Avoid error if file does not exist # Avoid error if file does not exist

View File

@ -40,9 +40,12 @@ run_command() {
case $command in case $command in
'DEFAULT') 'DEFAULT')
# Just rename the file, the update process adds back the new version if [ -f "$param1" ]; then
echo " Adding '.bak' to $param1" echo " Adding '.bak' to $param1"
mv "$param1" "$param1.bak" mv "$param1" "$param1.bak"
fi
echo " Using default file $param1"
cp "$(echo "$param1" | sed "s:${OPENHAB_HOME}:${OPENHAB_HOME}/dist:g")" "$param1"
;; ;;
'DELETE') 'DELETE')
# We should be strict and specific here, i.e only delete one file. # We should be strict and specific here, i.e only delete one file.
@ -59,8 +62,18 @@ run_command() {
fi fi
;; ;;
'MOVE') 'MOVE')
echo " Moving: From $param1 to $param2" # Avoid error if file or directory does not exist
mv "$param1" "$param2" if [ -e "$param1" ]; then
echo " Moving: From $param1 to $param2"
file_dir=$(dirname "$param2")
# Create directory with same ownership as file
if [ ! -d file_dir ]; then
mkdir -p "$file_dir"
prev_user_group=$(ls -ld "$param1" | awk '{print $3 ":" $4}')
chown -R "$prev_user_group" "$file_dir"
fi
mv "$param1" "$param2"
fi
;; ;;
'REPLACE') 'REPLACE')
# Avoid error if file does not exist # Avoid error if file does not exist

View File

@ -40,9 +40,12 @@ run_command() {
case $command in case $command in
'DEFAULT') 'DEFAULT')
# Just rename the file, the update process adds back the new version if [ -f "$param1" ]; then
echo " Adding '.bak' to $param1" echo " Adding '.bak' to $param1"
mv "$param1" "$param1.bak" mv "$param1" "$param1.bak"
fi
echo " Using default file $param1"
cp "$(echo "$param1" | sed "s:${OPENHAB_HOME}:${OPENHAB_HOME}/dist:g")" "$param1"
;; ;;
'DELETE') 'DELETE')
# We should be strict and specific here, i.e only delete one file. # We should be strict and specific here, i.e only delete one file.
@ -59,8 +62,18 @@ run_command() {
fi fi
;; ;;
'MOVE') 'MOVE')
echo " Moving: From $param1 to $param2" # Avoid error if file or directory does not exist
mv "$param1" "$param2" if [ -e "$param1" ]; then
echo " Moving: From $param1 to $param2"
file_dir=$(dirname "$param2")
# Create directory with same ownership as file
if [ ! -d file_dir ]; then
mkdir -p "$file_dir"
prev_user_group=$(ls -ld "$param1" | awk '{print $3 ":" $4}')
chown -R "$prev_user_group" "$file_dir"
fi
mv "$param1" "$param2"
fi
;; ;;
'REPLACE') 'REPLACE')
# Avoid error if file does not exist # Avoid error if file does not exist

View File

@ -40,9 +40,12 @@ run_command() {
case $command in case $command in
'DEFAULT') 'DEFAULT')
# Just rename the file, the update process adds back the new version if [ -f "$param1" ]; then
echo " Adding '.bak' to $param1" echo " Adding '.bak' to $param1"
mv "$param1" "$param1.bak" mv "$param1" "$param1.bak"
fi
echo " Using default file $param1"
cp "$(echo "$param1" | sed "s:${OPENHAB_HOME}:${OPENHAB_HOME}/dist:g")" "$param1"
;; ;;
'DELETE') 'DELETE')
# We should be strict and specific here, i.e only delete one file. # We should be strict and specific here, i.e only delete one file.
@ -59,8 +62,18 @@ run_command() {
fi fi
;; ;;
'MOVE') 'MOVE')
echo " Moving: From $param1 to $param2" # Avoid error if file or directory does not exist
mv "$param1" "$param2" if [ -e "$param1" ]; then
echo " Moving: From $param1 to $param2"
file_dir=$(dirname "$param2")
# Create directory with same ownership as file
if [ ! -d file_dir ]; then
mkdir -p "$file_dir"
prev_user_group=$(ls -ld "$param1" | awk '{print $3 ":" $4}')
chown -R "$prev_user_group" "$file_dir"
fi
mv "$param1" "$param2"
fi
;; ;;
'REPLACE') 'REPLACE')
# Avoid error if file does not exist # Avoid error if file does not exist

View File

@ -40,9 +40,12 @@ run_command() {
case $command in case $command in
'DEFAULT') 'DEFAULT')
# Just rename the file, the update process adds back the new version if [ -f "$param1" ]; then
echo " Adding '.bak' to $param1" echo " Adding '.bak' to $param1"
mv "$param1" "$param1.bak" mv "$param1" "$param1.bak"
fi
echo " Using default file $param1"
cp "$(echo "$param1" | sed "s:${OPENHAB_HOME}:${OPENHAB_HOME}/dist:g")" "$param1"
;; ;;
'DELETE') 'DELETE')
# We should be strict and specific here, i.e only delete one file. # We should be strict and specific here, i.e only delete one file.
@ -59,8 +62,18 @@ run_command() {
fi fi
;; ;;
'MOVE') 'MOVE')
echo " Moving: From $param1 to $param2" # Avoid error if file or directory does not exist
mv "$param1" "$param2" if [ -e "$param1" ]; then
echo " Moving: From $param1 to $param2"
file_dir=$(dirname "$param2")
# Create directory with same ownership as file
if [ ! -d file_dir ]; then
mkdir -p "$file_dir"
prev_user_group=$(ls -ld "$param1" | awk '{print $3 ":" $4}')
chown -R "$prev_user_group" "$file_dir"
fi
mv "$param1" "$param2"
fi
;; ;;
'REPLACE') 'REPLACE')
# Avoid error if file does not exist # Avoid error if file does not exist