diff --git a/.gitignore b/.gitignore index 331324f6..c171831c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules yarn-error.log *.swp +includes/config.php diff --git a/includes/config.php b/config/config.php similarity index 100% rename from includes/config.php rename to config/config.php diff --git a/includes/defaults.php b/includes/defaults.php new file mode 100755 index 00000000..b3956bf6 --- /dev/null +++ b/includes/defaults.php @@ -0,0 +1,50 @@ + '2.0', + 'RASPI_CONFIG_NETWORKING' => RASPI_CONFIG.'/networking', + 'RASPI_ADMIN_DETAILS' => RASPI_CONFIG.'/raspap.auth', + 'RASPI_WIFI_CLIENT_INTERFACE' => 'wlan0', + 'RASPI_CACHE_PATH' => sys_get_temp_dir() . '/raspap', + + // Constants for configuration file paths. + // These are typical for default RPi installs. Modify if needed. + 'RASPI_DNSMASQ_CONFIG' => '/etc/dnsmasq.conf', + 'RASPI_DNSMASQ_LEASES' => '/var/lib/misc/dnsmasq.leases', + 'RASPI_HOSTAPD_CONFIG' => '/etc/hostapd/hostapd.conf', + 'RASPI_DHCPCD_CONFIG' => '/etc/dhcpcd.conf', + 'RASPI_WPA_SUPPLICANT_CONFIG' => '/etc/wpa_supplicant/wpa_supplicant.conf', + 'RASPI_HOSTAPD_CTRL_INTERFACE' => '/var/run/hostapd', + 'RASPI_WPA_CTRL_INTERFACE' => '/var/run/wpa_supplicant', + 'RASPI_OPENVPN_CLIENT_CONFIG' => '/etc/openvpn/client.conf', + 'RASPI_OPENVPN_SERVER_CONFIG' => '/etc/openvpn/server.conf', + 'RASPI_TORPROXY_CONFIG' => '/etc/tor/torrc', + + // Optional services, set to true to enable. + 'RASPI_WIFICLIENT_ENABLED' => true, + 'RASPI_HOTSPOT_ENABLED' => true, + 'RASPI_NETWORK_ENABLED' => true, + 'RASPI_DHCP_ENABLED' => true, + 'RASPI_OPENVPN_ENABLED' => false, + 'RASPI_TORPROXY_ENABLED' => false, + 'RASPI_CONFAUTH_ENABLED' => true, + 'RASPI_CHANGETHEME_ENABLED' => true, + 'RASPI_VNSTAT_ENABLED' => true, + 'RASPI_MONITOR_ENABLED' => false, + + // Locale settings + 'LOCALE_ROOT' => 'locale', + 'LOCALE_DOMAIN' => 'messages' +]; + +foreach ($defaults as $setting => $value) { + if (!defined($setting)) { + define($setting, $value); + } +} + +unset($defaults); diff --git a/index.php b/index.php index 5898e51e..15a267ad 100755 --- a/index.php +++ b/index.php @@ -22,6 +22,7 @@ require('includes/csrf.php'); ensureCSRFSessionToken(); include_once('includes/config.php'); +include_once('includes/defaults.php'); include_once(RASPI_CONFIG.'/raspap.php'); include_once('includes/locale.php'); include_once('includes/functions.php'); diff --git a/installers/common.sh b/installers/common.sh index ea4d18ef..f47934df 100755 --- a/installers/common.sh +++ b/installers/common.sh @@ -215,6 +215,10 @@ function default_configuration() { sudo cp $webroot_dir/config/dnsmasq.conf /etc/dnsmasq.conf || install_error "Unable to move dnsmasq configuration file" sudo cp $webroot_dir/config/dhcpcd.conf /etc/dhcpcd.conf || install_error "Unable to move dhcpcd configuration file" + if [ ! -f "$webroot_dir/includes/config.php" ]; then + sudo cp "$webroot_dir/config/config.php" "$webroot_dir/includes/config.php" + fi + # Generate required lines for Rasp AP to place into rc.local file. # #RASPAP is for removal script lines=(