Gamaliel Espinoza vor 7 Jahren
Ursprung
Commit
9df207053b
2 geänderte Dateien mit 30 neuen und 19 gelöschten Zeilen
  1. 24 10
      configure.py
  2. 6 9
      fourier_install.sh

+ 24 - 10
configure.py

@@ -1,5 +1,6 @@
 #!/usr/bin/python
 import sys
+import pwd
 import os
 import json
 import re
@@ -32,16 +33,29 @@ with open(infile[0], 'rb') as fpin:
         fpout.write(json.dumps(data, indent=4))
         print(theid)
 
+user = getpwnam('fourier')
+src_fourier_path = '/media/datadrive/fourier'
 fourier_path = '/var/fourier'
 box_path = os.path.join(fourier_path, theid)
 db_path = os.path.join(box_path, 'files.db')
-if os.path.isdir(fourier_path):
-    if not os.path.isdir(box_path):
-        print('** Creating Box ID folder')
-        os.mkdir(box_path)
-    if not os.path.isfile(db_path):
-        print('** Preparing local database')
-        subprocess.call(['fourier', 'db', 'setup'])
-        print('** Applying migrations')
-        subprocess.call(['fourier', 'db', 'migrate'])
-        print('** Creating database')
+
+if not os.path.isdir(src_fourier_path):
+    os.mkdir(src_fourier_path)
+    os.chown(src_fourier_path, user.pw_uid, user.pw_gid)
+
+if not os.path.islink(fourier_path):
+    os.src_fourier_path(src_fourier_path, fourier_path)
+
+if not os.path.isdir(box_path):
+    print('** Creating Box ID folder')
+    os.mkdir(box_path)
+    os.chown(box_path, user.pw_uid, user.pw_gid)
+
+if not os.path.isfile(db_path):
+    print('** Preparing local database')
+    subprocess.call(['fourier', 'db', 'setup'])
+    print('** Applying migrations')
+    subprocess.call(['fourier', 'db', 'migrate'])
+    print('** Creating database')
+
+    

+ 6 - 9
fourier_install.sh

@@ -19,7 +19,7 @@ mount_point=/media/datadrive
 echo "Fourier installer $installer_version"
 echo "------------------------------------"
 
-sudo apt-get install python python-pip
+sudo apt-get install -y python python-pip
 
 if [[ "$OSTYPE" == darwin* ]]; then
 	programspath=~/fourier
@@ -37,6 +37,11 @@ read -p "How many receivers has this box? " RECEIVERS_COUNT
 read -p "Box ID (from API): " BOX_ID
 read -p "API secret: " API_SECRET
 
+findmnt "$mount_point"
+if [ "$?" -neq 0 ]; then
+	echo -e 'Data drive is not mounted'
+fi
+
 if [[ "$OSTYPE" == darwin* ]]; then
 	keyfile="$programspath/fourier.key"
 	[ ! -f "$keyfile" ] && ssh-keygen -t rsa -b 2048 -f $keyfile
@@ -171,14 +176,6 @@ if [[ "$OSTYPE" != darwin* ]]; then
 	sudo cp $installerpath/fourier-key.json /etc/Fourier-key.json
 fi
 
-
-findmnt $mount_point
-if [ "$?" -neq 0 ]; then
-	echo -e '\e[34mData drive is not mounted\e[0m'
-
-fi
-
-
 echo "****************************************************************************"
 echo "REMEMBER: Initialize attached storage and create a symlink named $datapath pointing to the storage volume"
 echo "****************************************************************************"