├── modules.enabled └── .keep ├── bin └── auto_config.sh ├── conf └── auto.config.sh ├── modules.available ├── 11_openwrt_txpower.sh ├── 12_openwrt_channel.sh ├── 10_openwrt_ssid.sh ├── 13_openwrt_hostname.sh ├── 51_piratebox_node_ip.sh ├── 50_piratebox_hostname.sh ├── 52_piratebox_node_name.sh ├── 60_librarybox_ftpadmin.sh ├── 60_librarybox_ftpanon.sh ├── 60_librarybox_ftpsync.sh ├── 60_librarybox_ftpsyncport.sh ├── 60_librarybox_ftp.sh ├── 51_openwrt_node_ip.sh └── 61_librarybox_shoutbox.sh └── lib ├── template_module.sh └── autoconfig.sh /modules.enabled/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bin/auto_config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ## Initiates the autoconfig and lateron a restart 4 | 5 | . /opt/autocfg/conf/auto.config.sh 6 | . /opt/autocfg/lib/autoconfig.sh 7 | 8 | DEBUG=false 9 | 10 | _start_ 11 | -------------------------------------------------------------------------------- /conf/auto.config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #### Temporary folder to put the current output to 4 | cfg_tmp_folder=/tmp/auto_config 5 | 6 | #### Folder where the user changable files are located 7 | cfg_auto_folder=/opt/piratebox/share/Config 8 | 9 | #### Enabled-Modules folder 10 | cfg_modules=/opt/autocfg/modules.enabled 11 | 12 | -------------------------------------------------------------------------------- /modules.available/11_openwrt_txpower.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # AutoConfiguration via USB file 4 | ## 5 | # Set txpower on OpenWRT 6 | # 7 | 8 | 9 | #uncommend the following line for REAL modules 10 | MODULE_LIST="$MODULE_LIST openwrt_txpower" 11 | 12 | openwrt_txpower_myself="openwrt_txpower" #contains the name of the module 13 | openwrt_txpower_config_file="txpower.txt" 14 | 15 | interface_no=0 16 | 17 | # Read configuration out of the system and save it to openwrt_txpower_system_config depending on the 18 | # parameter 19 | func_read_system_config_openwrt_txpower() { 20 | local path=$1 ; shift 21 | 22 | echo "Getting txpower of device-$interface_no via uci" 23 | uci get "wireless.@wifi-device[$interface_no].txpower" > $path/$openwrt_txpower_config_file 24 | } 25 | 26 | # Parse the first parameter with the changed value 27 | # do the stuff you need to do for changing the configuratioj 28 | func_set_system_config_openwrt_txpower(){ 29 | local value=$1 ; shift 30 | uci set "wireless.radio0.txpower=$value" 31 | uci_commit_needed="1" 32 | } 33 | 34 | 35 | #This function is called to compare content and et differences 36 | # to initiate a restart in the end, set "changed=1" 37 | # the easiest comparison can be used with auto_default_compare 38 | # see below 39 | func_compare_and_set_openwrt_txpower(){ 40 | 41 | 42 | auto_config_lookup_and_set "$openwrt_txpower_myself" \ 43 | "$cfg_auto_folder/$openwrt_txpower_config_file" \ 44 | "$cfg_tmp_folder/$openwrt_txpower_config_file" 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /modules.available/12_openwrt_channel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # AutoConfiguration via USB file 4 | ## 5 | # Set channel on OpenWRT 6 | # 7 | 8 | 9 | #uncommend the following line for REAL modules 10 | MODULE_LIST="$MODULE_LIST openwrt_channel" 11 | 12 | openwrt_channel_myself="openwrt_channel" #contains the name of the module 13 | openwrt_channel_config_file="channel.txt" 14 | 15 | interface_no=0 16 | 17 | # Read configuration out of the system and save it to openwrt_channel_system_config depending on the 18 | # parameter 19 | func_read_system_config_openwrt_channel() { 20 | local path=$1 ; shift 21 | 22 | echo "Getting channel of device-$interface_no via uci" 23 | uci get "wireless.@wifi-device[$interface_no].channel" > $path/$openwrt_channel_config_file 24 | } 25 | 26 | # Parse the first parameter with the changed value 27 | # do the stuff you need to do for changing the configuratioj 28 | func_set_system_config_openwrt_channel(){ 29 | local value=$1 ; shift 30 | uci set "wireless.radio0.channel=$value" 31 | uci_commit_needed="1" 32 | 33 | } 34 | 35 | 36 | #This function is called to compare content and et differences 37 | # to initiate a restart in the end, set "changed=1" 38 | # the easiest comparison can be used with auto_default_compare 39 | # see below 40 | func_compare_and_set_openwrt_channel(){ 41 | 42 | 43 | auto_config_lookup_and_set "$openwrt_channel_myself" \ 44 | "$cfg_auto_folder/$openwrt_channel_config_file" \ 45 | "$cfg_tmp_folder/$openwrt_channel_config_file" 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /lib/template_module.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # AutoConfiguration via USB file 4 | # This is a template module, which contains empty functions, which can be called 5 | # 6 | # name shema is 7 | # nn_name.sh 8 | # 9 | # functions are named with 10 | # name_fffff 11 | # where ffff is the predifined template step. 12 | 13 | # Available global variables 14 | # CONFIG_TMP_STORE 15 | # CONFIG_STORE 16 | 17 | 18 | #uncommend the following line for REAL modules 19 | #MODULE_LIST="$MODULE_LIST template" 20 | 21 | template_myself="template" #contains the name of the module 22 | template_config_file="template" 23 | 24 | # Read configuration out of the system and save it to template_system_config depending on the 25 | # parameter 26 | func_read_system_config_template() { 27 | local path=$1 ; shift 28 | echo "" > $path/$template_config_file 29 | } 30 | 31 | # Parse the first parameter with the changed value 32 | # do the stuff you need to do for changing the configuratioj 33 | func_set_system_config_template(){ 34 | local value=$1 ; shift 35 | local old_value=$1 ; shift 36 | } 37 | 38 | 39 | #This function is called to compare content and et differences 40 | # to initiate a restart in the end, set "changed=1" 41 | # the easiest comparison can be used with auto_default_compare 42 | # see below 43 | func_compare_and_set_template(){ 44 | 45 | auto_config_lookup_and_set "$openwrt_ssid_myself" \ 46 | "$cfg_auto_folder/$openwrt_ssid_config_file" \ 47 | "$cfg_tmp_folder/$openwrt_ssid_config_file" 48 | 49 | } 50 | -------------------------------------------------------------------------------- /modules.available/10_openwrt_ssid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # AutoConfiguration via USB file 4 | ## 5 | # Set SSID on OpenWRT 6 | # 7 | 8 | 9 | #uncommend the following line for REAL modules 10 | MODULE_LIST="$MODULE_LIST openwrt_ssid" 11 | 12 | openwrt_ssid_myself="openwrt_ssid" #contains the name of the module 13 | openwrt_ssid_config_file="ssid.txt" 14 | 15 | interface_no=0 16 | 17 | # Read configuration out of the system and save it to openwrt_ssid_system_config depending on the 18 | # parameter 19 | func_read_system_config_openwrt_ssid() { 20 | local path=$1 ; shift 21 | 22 | echo "Getting SSID of iface-$interface_no via uci" 23 | uci get "wireless.@wifi-iface[$interface_no].ssid" > $path/$openwrt_ssid_config_file 24 | } 25 | 26 | # Parse the first parameter with the changed value 27 | # do the stuff you need to do for changing the configuratioj 28 | func_set_system_config_openwrt_ssid(){ 29 | local value=$1 ; shift 30 | #Wifi-SSID can only be a maximum of 32 chars 31 | local cleaned=`echo $value | cut -b 1-32 | head -n 1 ` 32 | uci set "wireless.@wifi-iface[$interface_no].ssid=$cleaned" 33 | uci_commit_needed="1" 34 | } 35 | 36 | 37 | #This function is called to compare content and et differences 38 | # to initiate a restart in the end, set "changed=1" 39 | # the easiest comparison can be used with auto_default_compare 40 | # see below 41 | func_compare_and_set_openwrt_ssid(){ 42 | 43 | 44 | auto_config_lookup_and_set "$openwrt_ssid_myself" \ 45 | "$cfg_auto_folder/$openwrt_ssid_config_file" \ 46 | "$cfg_tmp_folder/$openwrt_ssid_config_file" 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /modules.available/13_openwrt_hostname.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # AutoConfiguration via USB file 4 | ## 5 | # Set hostname on OpenWRT 6 | # 7 | 8 | 9 | #uncommend the following line for REAL modules 10 | MODULE_LIST="$MODULE_LIST openwrt_hostname" 11 | 12 | openwrt_hostname_myself="openwrt_hostname" #contains the name of the module 13 | openwrt_hostname_config_file="system_hostname.txt" 14 | 15 | # Read configuration out of the system and save it to openwrt_hostname_system_config depending on the 16 | # parameter 17 | func_read_system_config_openwrt_hostname() { 18 | local path=$1 ; shift 19 | 20 | echo "Getting system-hostname via uci" 21 | uci get "system.@system[0].hostname" > $path/$openwrt_hostname_config_file 22 | } 23 | 24 | # Parse the first parameter with the changed value 25 | # do the stuff you need to do for changing the configuratioj 26 | func_set_system_config_openwrt_hostname(){ 27 | local value=$1 ; shift 28 | 29 | ip=$(uci get network.lan.ipaddr) 30 | 31 | uci set "system.@system[0].hostname=$value" 32 | uci_commit_needed="1" 33 | 34 | echo "127.0.0.1 $value localhost." >/etc/hosts 35 | echo "$ip $value" >>/etc/hosts 36 | 37 | } 38 | 39 | 40 | #This function is called to compare content and et differences 41 | # to initiate a restart in the end, set "changed=1" 42 | # the easiest comparison can be used with auto_default_compare 43 | # see below 44 | func_compare_and_set_openwrt_hostname(){ 45 | 46 | 47 | auto_config_lookup_and_set "$openwrt_hostname_myself" \ 48 | "$cfg_auto_folder/$openwrt_hostname_config_file" \ 49 | "$cfg_tmp_folder/$openwrt_hostname_config_file" 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /modules.available/51_piratebox_node_ip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # AutoConfiguration via USB file 4 | # 5 | # Prints out the PirateBox Node IP and changes it 6 | # DOES NOT change IP in OPENWRT network config 7 | # 8 | # Available global variables 9 | # CONFIG_TMP_STORE 10 | # CONFIG_STORE 11 | 12 | 13 | #uncommend the following line for REAL modules 14 | MODULE_LIST="$MODULE_LIST piratebox_node_ip" 15 | 16 | piratebox_node_ip_myself="piratebox_node_ip" #contains the name of the module 17 | piratebox_node_ip_config_file="piratebox_node_ip.txt" 18 | 19 | node_config=/opt/piratebox/conf/node.conf 20 | 21 | # Read configuration out of the system and save it to piratebox_node_ip_system_config depending on the 22 | # parameter 23 | func_read_system_config_piratebox_node_ip() { 24 | local path=$1 ; shift 25 | 26 | echo "Extracting Node-IPv6 IP parameter from $node_config" 27 | config_line=$(grep NODE_IPV6_IP=\' $node_config ) 28 | #extract value 29 | config_line=${config_line#NODE_IPV6_IP=\'} 30 | config_value=${config_line%\'} 31 | 32 | echo $config_value > $path/$piratebox_node_ip_config_file 33 | } 34 | 35 | # Parse the first parameter with the changed value 36 | # do the stuff you need to do for changing the configuratioj 37 | func_set_system_config_piratebox_node_ip(){ 38 | local value=$1 ; shift 39 | local old_value=$1; shift 40 | 41 | echo "Changing PirateBox node ipv6 ip ..." 42 | sed "s|NODE_IPV6_IP='$old_value'|NODE_IPV6_IP='$value'|" -i $node_config 43 | 44 | } 45 | 46 | 47 | #This function is called to compare content and et differences 48 | # to initiate a restart in the end, set "changed=1" 49 | # the easiest comparison can be used with auto_default_compare 50 | # see below 51 | func_compare_and_set_piratebox_node_ip(){ 52 | 53 | auto_config_lookup_and_set "$piratebox_node_ip_myself" \ 54 | "$cfg_auto_folder/$piratebox_node_ip_config_file" \ 55 | "$cfg_tmp_folder/$piratebox_node_ip_config_file" 56 | 57 | } 58 | -------------------------------------------------------------------------------- /modules.available/50_piratebox_hostname.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # AutoConfiguration via USB file 4 | # 5 | # Changes hostname for piratebox 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 piratebox_hostname" 14 | 15 | piratebox_hostname_myself="piratebox_hostname" #contains the name of the module 16 | piratebox_hostname_config_file="hostname.txt" 17 | 18 | piratebox_config=/opt/piratebox/conf/piratebox.conf 19 | piratebox_install_sh=/opt/piratebox/bin/install_piratebox.sh 20 | 21 | # Read configuration out of the system and save it to piratebox_hostname_system_config depending on the 22 | # parameter 23 | func_read_system_config_piratebox_hostname() { 24 | local path=$1 ; shift 25 | 26 | echo "Extracting HOST parameter from $piratebox_config" 27 | config_line=$(grep HOST=\" $piratebox_config ) 28 | #extract value 29 | config_line=${config_line#HOST=\"} 30 | config_value=${config_line%\"} 31 | 32 | echo $config_value > $path/$piratebox_hostname_config_file 33 | } 34 | 35 | # Parse the first parameter with the changed value 36 | # do the stuff you need to do for changing the configuratioj 37 | func_set_system_config_piratebox_hostname(){ 38 | local value=$1 ; shift 39 | local old_value=$1; shift 40 | 41 | echo "Changing hostname for PirateBox with install_piratebox.sh" 42 | . $piratebox_install_sh "$piratebox_config" hostname "$value" 43 | } 44 | 45 | 46 | #This function is called to compare content and et differences 47 | # to initiate a restart in the end, set "changed=1" 48 | # the easiest comparison can be used with auto_default_compare 49 | # see below 50 | func_compare_and_set_piratebox_hostname(){ 51 | 52 | auto_config_lookup_and_set "$piratebox_hostname_myself" \ 53 | "$cfg_auto_folder/$piratebox_hostname_config_file" \ 54 | "$cfg_tmp_folder/$piratebox_hostname_config_file" 55 | 56 | } 57 | -------------------------------------------------------------------------------- /modules.available/52_piratebox_node_name.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # AutoConfiguration via USB file 4 | # 5 | # Prints out the PirateBox Node IP and changes it 6 | # DOES NOT change IP in OPENWRT network config 7 | # 8 | # Available global variables 9 | # CONFIG_TMP_STORE 10 | # CONFIG_STORE 11 | 12 | 13 | #uncommend the following line for REAL modules 14 | MODULE_LIST="$MODULE_LIST piratebox_node_name" 15 | 16 | piratebox_node_name_myself="piratebox_node_name" #contains the name of the module 17 | piratebox_node_name_config_file="piratebox_node_name.txt" 18 | 19 | node_config=/opt/piratebox/conf/node.conf 20 | 21 | # Read configuration out of the system and save it to piratebox_node_name_system_config depending on the 22 | # parameter 23 | func_read_system_config_piratebox_node_name() { 24 | local path=$1 ; shift 25 | 26 | echo "Extracting Node-NAME parameter from $node_config" 27 | config_line=$(grep NODE_NAME=\' $node_config ) 28 | #extract value 29 | config_line=${config_line#NODE_NAME=\'} 30 | config_value=${config_line%\'} 31 | 32 | echo $config_value > $path/$piratebox_node_name_config_file 33 | } 34 | 35 | # Parse the first parameter with the changed value 36 | # do the stuff you need to do for changing the configuratioj 37 | func_set_system_config_piratebox_node_name(){ 38 | local value=$1 ; shift 39 | local old_value=$1; shift 40 | 41 | echo "Changing PirateBox node node name ..." 42 | sed "s|NODE_NAME='$old_value'|NODE_NAME='$value'|" -i $node_config 43 | 44 | } 45 | 46 | 47 | #This function is called to compare content and et differences 48 | # to initiate a restart in the end, set "changed=1" 49 | # the easiest comparison can be used with auto_default_compare 50 | # see below 51 | func_compare_and_set_piratebox_node_name(){ 52 | 53 | auto_config_lookup_and_set "$piratebox_node_name_myself" \ 54 | "$cfg_auto_folder/$piratebox_node_name_config_file" \ 55 | "$cfg_tmp_folder/$piratebox_node_name_config_file" 56 | 57 | } 58 | -------------------------------------------------------------------------------- /modules.available/60_librarybox_ftpadmin.sh: -------------------------------------------------------------------------------- 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.txt" 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 | } 59 | -------------------------------------------------------------------------------- /modules.available/60_librarybox_ftpanon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # AutoConfiguration via USB file 4 | # 5 | # Enable, Disable anonymous FTP access 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_ftpanon" 14 | 15 | librarybox_ftpanon_myself="librarybox_ftpanon" #contains the name of the module 16 | librarybox_ftpanon_config_file="librarybox_ftpanon.txt" 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_ftpanon_system_config depending on the 23 | # parameter 24 | func_read_system_config_librarybox_ftpanon() { 25 | local path=$1 ; shift 26 | 27 | echo "Extracting FTP-Anon parameter from $ftp_config" 28 | config_line=$(grep ENABLE_ANON=\" $ftp_config ) 29 | #extract value 30 | config_line=${config_line#ENABLE_ANON=\"} 31 | config_value=${config_line%\"} 32 | 33 | echo $config_value > $path/$librarybox_ftpanon_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_ftpanon(){ 39 | local value=$1 ; shift 40 | local old_value=$1; shift 41 | 42 | echo "Changing ftp-anonymous access for LibraryBox" 43 | sed "s|ENABLE_ANON=\"$old_value\"|ENABLE_ANON=\"$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_ftpanon(){ 53 | 54 | auto_config_lookup_and_set "$librarybox_ftpanon_myself" \ 55 | "$cfg_auto_folder/$librarybox_ftpanon_config_file" \ 56 | "$cfg_tmp_folder/$librarybox_ftpanon_config_file" 57 | 58 | } 59 | -------------------------------------------------------------------------------- /modules.available/60_librarybox_ftpsync.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # AutoConfiguration via USB file 4 | # 5 | # Enable, Disable sync access 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_ftpsync" 14 | 15 | librarybox_ftpsync_myself="librarybox_ftpsync" #contains the name of the module 16 | librarybox_ftpsync_config_file="librarybox_ftpsync.txt" 17 | 18 | # FTP configuration is currently located in the hook 19 | #librarybox_config=/opt/piratebox/conf/piratebox.conf 20 | ftp_config=/opt/piratebox/conf/hook_custom.conf 21 | 22 | # Read configuration out of the system and save it to librarybox_ftpsync_system_config depending on the 23 | # parameter 24 | func_read_system_config_librarybox_ftpsync() { 25 | local path=$1 ; shift 26 | 27 | echo "Extracting FTP-Sync parameter from $ftp_config" 28 | config_line=$(grep FTP_SYNC_ENABLED=\" $ftp_config ) 29 | #extract value 30 | config_line=${config_line#FTP_SYNC_ENABLED=\"} 31 | config_value=${config_line%\"} 32 | 33 | echo $config_value > $path/$librarybox_ftpsync_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_ftpsync(){ 39 | local value=$1 ; shift 40 | local old_value=$1; shift 41 | 42 | echo "Changing ftp-sync access for LibraryBox" 43 | sed "s|FTP_SYNC_ENABLED=\"$old_value\"|FTP_SYNC_ENABLED=\"$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_ftpsync(){ 53 | 54 | auto_config_lookup_and_set "$librarybox_ftpsync_myself" \ 55 | "$cfg_auto_folder/$librarybox_ftpsync_config_file" \ 56 | "$cfg_tmp_folder/$librarybox_ftpsync_config_file" 57 | 58 | } 59 | -------------------------------------------------------------------------------- /modules.available/60_librarybox_ftpsyncport.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # AutoConfiguration via USB file 4 | # 5 | # Set Port for Sync Access in 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_ftpsyncport" 14 | 15 | librarybox_ftpsyncport_myself="librarybox_ftpsyncport" #contains the name of the module 16 | librarybox_ftpsyncport_config_file="librarybox_ftpsyncport.txt" 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_ftpsyncport_system_config depending on the 23 | # parameter 24 | func_read_system_config_librarybox_ftpsyncport() { 25 | local path=$1 ; shift 26 | 27 | echo "Extracting FTP-Sync port from $ftp_config" 28 | config_line=$(grep SYNC_PORT=\" $ftp_config ) 29 | #extract value 30 | config_line=${config_line#SYNC_PORT=\"} 31 | config_value=${config_line%\"} 32 | 33 | echo $config_value > $path/$librarybox_ftpsyncport_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_ftpsyncport(){ 39 | local value=$1 ; shift 40 | local old_value=$1; shift 41 | 42 | echo "Changing ftp-sync Port for LibraryBox" 43 | sed "s|SYNC_PORT=\"$old_value\"|SYNC_PORT=\"$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_ftpsyncport(){ 53 | 54 | auto_config_lookup_and_set "$librarybox_ftpsyncport_myself" \ 55 | "$cfg_auto_folder/$librarybox_ftpsyncport_config_file" \ 56 | "$cfg_tmp_folder/$librarybox_ftpsyncport_config_file" 57 | 58 | } 59 | -------------------------------------------------------------------------------- /modules.available/60_librarybox_ftp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # AutoConfiguration via USB file 4 | # 5 | # Enable, Disable ftp 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_ftp" 14 | 15 | librarybox_ftp_myself="librarybox_ftp" #contains the name of the module 16 | librarybox_ftp_config_file="librarybox_ftp.txt" 17 | 18 | # FTP configuration is currently located in the hook 19 | #librarybox_config=/opt/piratebox/conf/piratebox.conf 20 | ### duplicate variable name with different content 21 | librarybox_ftp_piratebox_config=/opt/piratebox/conf/hook_custom.conf 22 | 23 | # Read configuration out of the system and save it to librarybox_ftp_system_config depending on the 24 | # parameter 25 | func_read_system_config_librarybox_ftp() { 26 | local path=$1 ; shift 27 | 28 | echo "Extracting FTP parameter from $librarybox_ftp_piratebox_config" 29 | config_line=$(grep FTP_ENABLED=\" $librarybox_ftp_piratebox_config ) 30 | #extract value 31 | config_line=${config_line#FTP_ENABLED=\"} 32 | config_value=${config_line%\"} 33 | 34 | echo $config_value > $path/$librarybox_ftp_config_file 35 | } 36 | 37 | # Parse the first parameter with the changed value 38 | # do the stuff you need to do for changing the configuratioj 39 | func_set_system_config_librarybox_ftp(){ 40 | local value=$1 ; shift 41 | local old_value=$1; shift 42 | 43 | echo "Changing ftp for LibraryBox" 44 | sed "s|FTP_ENABLED=\"$old_value\"|FTP_ENABLED=\"$value\"|" -i $librarybox_ftp_piratebox_config 45 | 46 | } 47 | 48 | 49 | #This function is called to compare content and et differences 50 | # to initiate a restart in the end, set "changed=1" 51 | # the easiest comparison can be used with auto_default_compare 52 | # see below 53 | func_compare_and_set_librarybox_ftp(){ 54 | 55 | auto_config_lookup_and_set "$librarybox_ftp_myself" \ 56 | "$cfg_auto_folder/$librarybox_ftp_config_file" \ 57 | "$cfg_tmp_folder/$librarybox_ftp_config_file" 58 | 59 | } 60 | -------------------------------------------------------------------------------- /modules.available/51_openwrt_node_ip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # AutoConfiguration via USB file 4 | # 5 | # Prints out the PirateBox Node IP and changes it 6 | # DOES NOT change IP in OPENWRT network config 7 | # 8 | # Available global variables 9 | # CONFIG_TMP_STORE 10 | # CONFIG_STORE 11 | 12 | 13 | #uncommend the following line for REAL modules 14 | MODULE_LIST="$MODULE_LIST openwrt_node_ip" 15 | 16 | openwrt_node_ip_myself="openwrt_node_ip" #contains the name of the module 17 | openwrt_node_ip_config_file="piratebox_node_ip.txt" 18 | 19 | node_config=/opt/piratebox/conf/node.conf 20 | 21 | # Read configuration out of the system and save it to openwrt_node_ip_system_config depending on the 22 | # parameter 23 | func_read_system_config_openwrt_node_ip() { 24 | local path=$1 ; shift 25 | 26 | echo "Extracting Node-IPv6 IP parameter from $node_config" 27 | config_line=$(grep NODE_IPV6_IP=\' $node_config ) 28 | #extract value 29 | config_line=${config_line#NODE_IPV6_IP=\'} 30 | config_value=${config_line%\'} 31 | 32 | echo $config_value > $path/$openwrt_node_ip_config_file 33 | } 34 | 35 | # Parse the first parameter with the changed value 36 | # do the stuff you need to do for changing the configuratioj 37 | func_set_system_config_openwrt_node_ip(){ 38 | local value=$1 ; shift 39 | local old_value=$1; shift 40 | 41 | echo "Changing PirateBox node ipv6 ip in OpenWRT ..." 42 | 43 | local mask_config=$(grep NODE_IPV6_MASK=\' $node_config ) 44 | local mask_config=${mask_config#NODE_IPV6_MASK=\'} 45 | local mask_config=${mask_config%\'} 46 | 47 | local new_ip="$value""$mask_config" 48 | uci set network.@alias[0].ip6addr="$new_ip" 49 | 50 | uci_commit_needed="1" 51 | 52 | } 53 | 54 | 55 | #This function is called to compare content and et differences 56 | # to initiate a restart in the end, set "changed=1" 57 | # the easiest comparison can be used with auto_default_compare 58 | # see below 59 | func_compare_and_set_openwrt_node_ip(){ 60 | 61 | auto_config_lookup_and_set "$openwrt_node_ip_myself" \ 62 | "$cfg_auto_folder/$openwrt_node_ip_config_file" \ 63 | "$cfg_tmp_folder/$openwrt_node_ip_config_file" 64 | 65 | } 66 | -------------------------------------------------------------------------------- /modules.available/61_librarybox_shoutbox.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # AutoConfiguration via USB file 4 | # 5 | # Enable, Disable ftp 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_shoutbox" 14 | 15 | librarybox_shoutbox_myself="librarybox_shoutbox" #contains the name of the module 16 | librarybox_shoutbox_config_file="librarybox_shoutbox.txt" 17 | 18 | # FTP configuration is currently located in the hook 19 | #librarybox_config=/opt/piratebox/conf/piratebox.conf 20 | ### duplicate variable name with different content 21 | librarybox_shoutbox_piratebox_config=/opt/piratebox/conf/hook_custom.conf 22 | 23 | # Read configuration out of the system and save it to librarybox_shoutbox_system_config depending on the 24 | # parameter 25 | func_read_system_config_librarybox_shoutbox() { 26 | local path=$1 ; shift 27 | 28 | echo "Extracting SHOUTBOX parameter from $librarybox_shoutbox_piratebox_config" 29 | config_line=$(grep SHOUTBOX_ENABLED=\" $librarybox_shoutbox_piratebox_config ) 30 | #extract value 31 | config_line=${config_line#SHOUTBOX_ENABLED=\"} 32 | config_value=${config_line%\"} 33 | 34 | echo $config_value > $path/$librarybox_shoutbox_config_file 35 | } 36 | 37 | # Parse the first parameter with the changed value 38 | # do the stuff you need to do for changing the configuratioj 39 | func_set_system_config_librarybox_shoutbox(){ 40 | local value=$1 ; shift 41 | local old_value=$1; shift 42 | 43 | echo "Changing Shoutbox-function for LibraryBox" 44 | sed "s|SHOUTBOX_ENABLED=\"$old_value\"|SHOUTBOX_ENABLED=\"$value\"|" -i $librarybox_shoutbox_piratebox_config 45 | 46 | } 47 | 48 | 49 | #This function is called to compare content and et differences 50 | # to initiate a restart in the end, set "changed=1" 51 | # the easiest comparison can be used with auto_default_compare 52 | # see below 53 | func_compare_and_set_librarybox_shoutbox(){ 54 | 55 | auto_config_lookup_and_set "$librarybox_shoutbox_myself" \ 56 | "$cfg_auto_folder/$librarybox_shoutbox_config_file" \ 57 | "$cfg_tmp_folder/$librarybox_shoutbox_config_file" 58 | 59 | } 60 | -------------------------------------------------------------------------------- /lib/autoconfig.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | MODULE_LIST="" 4 | 5 | 6 | #Default compare and set 7 | auto_config_lookup_and_set(){ 8 | local config=$1; shift 9 | local filename=$1; shift 10 | local current_status_file=$1; shift 11 | 12 | $DEBUG && echo "lookup_set: config - $config" 13 | $DEBUG && echo "lookup_set: filename - $filename" 14 | $DEBUG && echo "lookup_set: current_status_file - $current_status_file" 15 | 16 | if [ -f $filename ] ; then 17 | 18 | $DEBUG && echo "Config file found" 19 | $DEBUG && echo -n " tmp (current): " && cat $current_status_file 20 | $DEBUG && echo -n " config : " && cat $filename 21 | 22 | if [ "`cat $filename`" != "`cat $current_status_file`" ] ; then 23 | echo " $config - configuration is different, setting to new value" 24 | func_set_system_config_$config "`cat $filename `" "`cat $current_status_file`" 25 | changed=1 26 | fi 27 | fi 28 | 29 | return $changed 30 | } 31 | 32 | #Processes all modules.enabled 33 | auto_config_process_all() { 34 | 35 | #### Global var 36 | changed=0 37 | uci_commit_needed="0" 38 | #### 39 | 40 | for config in $MODULE_LIST 41 | do 42 | echo "Working on $config" 43 | func_read_system_config_$config $cfg_tmp_folder 44 | func_compare_and_set_$config 45 | #save new set value, which will be moved later 46 | func_read_system_config_$config $cfg_tmp_folder 47 | done 48 | 49 | if [ "$changed" = "1" ] ; then 50 | echo "done some changes.." 51 | if [ "$uci_commit_needed" == "1" ] ; then 52 | echo "doing uci commit" 53 | uci commit 54 | fi 55 | fi 56 | return 0 57 | } 58 | 59 | _load_modules_() { 60 | local module_path=$1 ; shift 61 | 62 | 63 | local available_module_files=$(ls $cfg_modules) 64 | 65 | $DEBUG && echo "modules_folder $cfg_modules " 66 | $DEBUG && echo "ls result: $available_module_files" 67 | 68 | for module in $available_module_files 69 | do 70 | echo -n "Loading module $module .." 71 | . $cfg_modules/$module 72 | echo "done" 73 | done 74 | 75 | echo "Available modules: $MODULE_LIST " 76 | 77 | return 0 78 | } 79 | 80 | 81 | _start_() { 82 | 83 | changed=0 84 | 85 | # check if $cfg_modules is available 86 | if [ ! -d $cfg_modules ] ; then 87 | echo "config module folder $cfg_modules does not exists" 88 | exit 1 89 | fi 90 | 91 | # load modules 92 | _load_modules_ || exit $? 93 | 94 | # check & create folder, if needed 95 | mkdir -p $cfg_tmp_folder 96 | mkdir -p $cfg_auto_folder 97 | 98 | 99 | # Run configuration 100 | auto_config_process_all 101 | 102 | # Transfer exported config values 103 | cp $cfg_tmp_folder/* $cfg_auto_folder 104 | 105 | 106 | if [ "$changed" == "1" ] ; then 107 | #If we changed something we deliver 0 as RC, because 108 | #we did our work successfully 109 | exit 0 110 | else 111 | #So, we haven't changed something, so, we inform with 112 | #RC 1 as a hint 113 | exit 1 114 | fi 115 | } 116 | 117 | --------------------------------------------------------------------------------