I've written some bash scripts, but this is just beyond me and I have no idea where to start. I'm using a VPN that allows me to have a forwarded port forwarded, but only by running the following line, which produces the output below, with a different port each time.
I'm looking to make a script that runs that process, takes the port output, and then puts it into the configuration file for Deluge, and then runs Deluge. I've pasted my current configuration below, with the two numbers that need to be replaced in bold. This file is located at /home/user/.config/deluge/core.conf
Is this possible? If there's a way to use the output from the command, I would think I could store a given port number in a seperate file that would then be used by the script to find the and replace with the new port number, and then change the number in the file for the next run.
Command:
./port_forward.sh <user> <password>
Output:
Loading port forward assignment information..
{"port:58661}
I'm looking to make a script that runs that process, takes the port output, and then puts it into the configuration file for Deluge, and then runs Deluge. I've pasted my current configuration below, with the two numbers that need to be replaced in bold. This file is located at /home/user/.config/deluge/core.conf
{
"file": 1,
"format": 1
}{
"info_sent": 0.0,
"lsd": true,
"send_info": false,
"move_completed_path": "/media/sf_Storage2/Download folder",
"enc_in_policy": 1,
"queue_new_to_top": false,
"ignore_limits_on_local_network": true,
"rate_limit_ip_overhead": true,
"daemon_port": 58846,
"natpmp": true,
"max_active_limit": 8,
"utpex": true,
"max_active_downloading": 5,
"max_active_seeding": 0,
"allow_remote": false,
"max_half_open_connections": 50,
"download_location": "/media/sf_Storage2/Temp Download Folder",
"compact_allocation": false,
"max_upload_speed": -1.0,
"cache_expiry": 60,
"prioritize_first_last_pieces": false,
"auto_managed": true,
"enc_level": 2,
"max_connections_per_second": 20,
"dont_count_slow_torrents": true,
"random_outgoing_ports": true,
"max_upload_slots_per_torrent": -1,
"new_release_check": false,
"enc_out_policy": 1,
"outgoing_ports": [
0,
0
],
"seed_time_limit": 180,
"cache_size": 512,
"share_ratio_limit": 2.0,
"max_download_speed": -1.0,
"geoip_db_location": "/usr/share/GeoIP/GeoIP.dat",
"torrentfiles_location": "/home/user/Downloads",
"stop_seed_at_ratio": false,
"peer_tos": "0x00",
"listen_interface": "",
"upnp": true,
"max_download_speed_per_torrent": -1,
"max_upload_slots_global": 4,
"enabled_plugins": [],
"random_port": false,
"autoadd_enable": false,
"max_connections_global": 200,
"enc_prefer_rc4": true,
"listen_ports": [
32157,
32157
],
"dht": true,
"stop_seed_ratio": 2.0,
"seed_time_ratio_limit": 7.0,
"max_upload_speed_per_torrent": -1,
"copy_torrent_file": false,
"del_copy_torrent_file": false,
"move_completed": true,
"proxies": {
"peer": {
"username": "",
"password": "",
"type": 0,
"hostname": "",
"port": 8080
},
"web_seed": {
"username": "",
"password": "",
"type": 0,
"hostname": "",
"port": 8080
},
"tracker": {
"username": "",
"password": "",
"type": 0,
"hostname": "",
"port": 8080
},
"dht": {
"username": "",
"password": "",
"type": 0,
"hostname": "",
"port": 8080
}
},
"add_paused": false,
"max_connections_per_torrent": -1,
"remove_seed_at_ratio": false,
"autoadd_location": "/home/user/Downloads",
"plugins_location": "/home/user/.config/deluge/plugins"
}
Is this possible? If there's a way to use the output from the command, I would think I could store a given port number in a seperate file that would then be used by the script to find the and replace with the new port number, and then change the number in the file for the next run.