|
| 1 | +#!/bin/sh |
| 2 | +# |
| 3 | +# AutoConfiguration via USB file |
| 4 | +# |
| 5 | +# Enable, Disable ftpadmin for librarybox configuration |
| 6 | +# |
| 7 | +# Available global variables |
| 8 | +# CONFIG_TMP_STORE |
| 9 | +# CONFIG_STORE |
| 10 | + |
| 11 | + |
| 12 | +#uncommend the following line for REAL modules |
| 13 | +MODULE_LIST="$MODULE_LIST librarybox_ftpadmin" |
| 14 | + |
| 15 | +librarybox_ftpadmin_myself="librarybox_ftpadmin" #contains the name of the module |
| 16 | +librarybox_ftpadmin_config_file="librarybox_ftpadmin" |
| 17 | + |
| 18 | +# FTP configuration is currently located in the hook |
| 19 | +#librarybox_config=/opt/piratebox/conf/piratebox.conf |
| 20 | +ftp_config=/opt/piratebox/conf/ftp/ftp.conf |
| 21 | + |
| 22 | +# Read configuration out of the system and save it to librarybox_ftpadmin_system_config depending on the |
| 23 | +# parameter |
| 24 | +func_read_system_config_librarybox_ftpadmin() { |
| 25 | + local path=$1 ; shift |
| 26 | + |
| 27 | + echo "Extracting FTP-admin parameter from $ftp_config" |
| 28 | + config_line=$(grep ADMIN_ACCESS=\" $ftp_config ) |
| 29 | + #extract value |
| 30 | + config_line=${config_line#ADMIN_ACCESS=\"} |
| 31 | + config_value=${config_line%\"} |
| 32 | + |
| 33 | + echo $config_value > $path/$librarybox_ftpadmin_config_file |
| 34 | +} |
| 35 | + |
| 36 | +# Parse the first parameter with the changed value |
| 37 | +# do the stuff you need to do for changing the configuratioj |
| 38 | +func_set_system_config_librarybox_ftpadmin(){ |
| 39 | + local value=$1 ; shift |
| 40 | + local old_value=$1; shift |
| 41 | + |
| 42 | + echo "Changing ftp-admin access for LibraryBox" |
| 43 | + sed "s|ADMIN_ACCESS=\"$old_value\"|ADMIN_ACCESS=\"$value\"|" -i $ftp_config |
| 44 | + |
| 45 | +} |
| 46 | + |
| 47 | + |
| 48 | +#This function is called to compare content and et differences |
| 49 | +# to initiate a restart in the end, set "changed=1" |
| 50 | +# the easiest comparison can be used with auto_default_compare |
| 51 | +# see below |
| 52 | +func_compare_and_set_librarybox_ftpadmin(){ |
| 53 | + |
| 54 | + auto_config_lookup_and_set "$librarybox_ftpadmin_myself" \ |
| 55 | + "$cfg_auto_folder/$librarybox_ftpadmin_config_file" \ |
| 56 | + "$cfg_tmp_folder/$librarybox_ftpadmin_config_file" |
| 57 | + |
| 58 | +} |
0 commit comments