Skip to content

Commit

Permalink
minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
outdoorbits committed Oct 25, 2023
1 parent c15e6cc commit c5f13e9
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 21 deletions.
4 changes: 3 additions & 1 deletion install-comitup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ if [[ ! "${INSTALLER_DIR}" =~ "little-backup-box" ]]; then
INSTALLER_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/little-backup-box"
fi

const_WEB_ROOT_LBB="/var/www/little-backup-box"

echo "Installing comitup..."

# Installing comitup*: install comitup sources
Expand Down Expand Up @@ -62,7 +64,7 @@ sudo systemctl mask dhcpcd.service
sudo systemctl mask wpa-supplicant.service

# create config
sudo python3 "${INSTALLER_DIR}/scripts/lib_comitup.py"
sudo python3 "${const_WEB_ROOT_LBB}/lib_comitup.py"

echo "All done. Connect to the little-backup-box-<nn> network and open http://10.41.0.1/"
echo "comitup will be available after reboot."
Expand Down
42 changes: 42 additions & 0 deletions scripts/apache_ports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python

# Author: Stefan Saam, [email protected]

#######################################################################
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#######################################################################

import subprocess
import sys

ApachePortsConf = '/etc/apache2/ports.conf'

BasicPorts = [
8000,
443,
81,
8443
]

with open(ApachePortsConf,'w') as f:
for Port in BasicPorts:
f.write(f'Listen {Port}\n')

if len(sys.argv) > 1:
if sys.argv[1] == 'CONNECTED':
f.write(f'Listen 80\n')

subprocess.run('service apache2 restart || service apache2 start', shell=True)


22 changes: 22 additions & 0 deletions scripts/apache_ports.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

# Author: Stefan Saam, [email protected]

#######################################################################
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#######################################################################

# catches the command from comitup and executes apache_ports.py

sudo python3 /var/www/little-backup-box/apache_ports.py "${1}"
4 changes: 2 additions & 2 deletions scripts/cmd-runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@
break;

case 'comitup_reset':
$MAIN_COMMAND = "comitup-cli d";
$MAIN_COMMAND = "$WORKING_DIR/comitup-reset.sh";

$COMMAND_LINE = "echo 'sudo $MAIN_COMMAND'";
$COMMAND_LINE = "cat $MAIN_COMMAND | grep '^[^# ]'";
$COMMAND_LINE .= ";echo ''";
$COMMAND_LINE .= ";sudo $MAIN_COMMAND";
$COMMAND_LINE .= ";echo ''";
Expand Down
23 changes: 23 additions & 0 deletions scripts/comitup-reset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

# Author: Stefan Saam, [email protected]

#######################################################################
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#######################################################################

# resets the comitup wifi settings and reconfigures apache

comitup-cli d
sudo python3 /var/www/little-backup-box/apache_ports.py ${1}
2 changes: 1 addition & 1 deletion scripts/displaymenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def __init__(self,DISPLAY_LINES,setup):
{
'type': 'item',
'title': self.__lan.l('box_menu_comitup_reset'),
'action': self.create_confirmed_shell_action(self.__lan.l('box_menu_comitup_reset'),[['sudo','comitup-cli','d']]),
'action': self.create_confirmed_shell_action(self.__lan.l('box_menu_comitup_reset'),[['sudo',f'{self.WORKING_DIR}/comitup-reset.sh']]),
},

{
Expand Down
16 changes: 0 additions & 16 deletions scripts/handle_port_80.sh

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/lib_comitup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def run(self):
with open(self.configfile,'w') as f:
f.write('ap_name: little-backup-box-<nnnn>\n')
f.write('web_service: apache2.service\n')
f.write('external_callback: /var/www/little-backup-box/handle_port_80.sh\n')
f.write('external_callback: /var/www/little-backup-box/apache_ports.sh\n')
if self.Password:
if (
(len(self.Password) >= 8) and
Expand Down

0 comments on commit c5f13e9

Please sign in to comment.