Raphael Schneeberger 6 лет назад
Родитель
Сommit
29482d74c0
2 измененных файлов с 53 добавлено и 1 удалено
  1. 53 0
      bin/v-open-fs-config
  2. 0 1
      install/upgrade/versions/latest.sh

+ 53 - 0
bin/v-open-fs-config

@@ -0,0 +1,53 @@
+#!/bin/bash
+# info: open config
+# options: CONFIG
+#
+# The function opens/reads config files on the file system
+
+src_file=$1
+
+# Checking arguments
+if [ -z "$src_file" ]; then
+    echo "Usage: CONFIG"
+    exit 1
+fi
+
+# Checking hestia user
+if [ ! -d "$HESTIA/data/users/$user" ]; then
+    echo "Error: hestia user $user doesn't exist"
+    exit 3
+fi
+
+# Checking file on fs
+if [ ! -e "$src_file" ]; then
+    echo "Error: $src_file file doesn't exist"
+    exit 3
+fi
+
+# Checking path
+if [ ! -z "$src_file" ]; then
+    rpath=$(readlink -f "$src_file")
+    services="nginx|apache|httpd|php|ftp|bind|named|exim|dovecot|spamassassin"
+    services="$services|clam|mysql|postgresql|pgsql|cron|ssh|fail2ban|iptables"
+    services="$services|my.cnf"
+    spath=$(echo "$rpath" |egrep "$services")
+    if [ -z "$spath" ]; then
+        echo "Error: invalid source path $src_file"
+        exit 2
+    fi
+    spath=$(echo "$rpath" |egrep "/etc|/var/lib")
+    if [ -z "$spath" ]; then
+        echo "Error: invalid source path $src_file"
+        exit 2
+    fi
+fi
+
+# Reading conf
+cat "$src_file" 2>/dev/null
+if [ $? -ne 0 ]; then
+    echo "Error: file $src_file was not opened"
+    exit 3
+fi
+
+# Exiting
+exit

+ 0 - 1
install/upgrade/versions/latest.sh

@@ -86,7 +86,6 @@ mv $HESTIA/bin/v-get-fs-file-type $HESTIA_BACKUP/bin/
 mv $HESTIA/bin/v-list-fs-directory $HESTIA_BACKUP/bin/
 mv $HESTIA/bin/v-move-fs-directory $HESTIA_BACKUP/bin/
 mv $HESTIA/bin/v-move-fs-file $HESTIA_BACKUP/bin/
-mv $HESTIA/bin/v-open-fs-config $HESTIA_BACKUP/bin/
 mv $HESTIA/bin/v-open-fs-file $HESTIA_BACKUP/bin/
 mv $HESTIA/bin/v-search-fs-object $HESTIA_BACKUP/bin/
 if [ ! -d "$HESTIA_BACKUP/web" ]; then