-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Ottercast/twig
Introduce Templating via Twig Ott :3
- Loading branch information
Showing
354 changed files
with
33,033 additions
and
511 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<?php | ||
require(__DIR__ . "/config.php"); | ||
|
||
`mount -o remount,rw /`; | ||
|
||
$snapclient_config_path = "/etc/default/snapclient"; | ||
$wpaconf_path = "/etc/wpa_supplicant/wpa_supplicant-wlan0.conf"; | ||
$ssh_system_authorized_keys = "/root/.ssh/authorized_keys"; | ||
|
||
// 23 == 0dB capture gain | ||
`amixer cset name='Capture Volume' 23`; | ||
|
||
if (file_exists($ssh_key_file)) | ||
{ | ||
if (file_get_contents($ssh_system_authorized_keys) != file_get_contents($ssh_key_file)) | ||
{ | ||
@mkdir(dirname($ssh_system_authorized_keys)); | ||
file_put_contents($ssh_system_authorized_keys, file_get_contents($ssh_key_file)); | ||
chmod($ssh_system_authorized_keys, 0700); | ||
} | ||
} | ||
|
||
if ($config['software']["airplay_active"]) | ||
{ | ||
`systemctl start shairport-sync`; | ||
} | ||
else | ||
{ | ||
`systemctl stop shairport-sync`; | ||
} | ||
|
||
if ($config['software']["pulseaudio_active"]) | ||
{ | ||
`systemctl start pulseaudio`; | ||
} | ||
else | ||
{ | ||
`systemctl stop pulseaudio`; | ||
} | ||
|
||
if ($config['software']["librespot_active"]) | ||
{ | ||
`systemctl start librespot`; | ||
} | ||
else | ||
{ | ||
`systemctl stop librespot`; | ||
} | ||
|
||
if ($config['software']["linein_stream_active"]) | ||
{ | ||
`systemctl start snapserver`; | ||
} | ||
else | ||
{ | ||
`systemctl stop snapserver`; | ||
} | ||
|
||
if ($config['software']["snapcast_client_active"]) | ||
{ | ||
$snapclient_config = 'START_SNAPCLIENT=true' . "\n" . | ||
'SNAPCLIENT_OPTS="-h ' . escapeshellarg($config['software']["snapcast_client_hostname"]) . '"' . "\n"; | ||
if (file_get_contents($snapclient_config_path) != $snapclient_config) | ||
{ | ||
file_put_contents($snapclient_config_path, $snapclient_config); | ||
`systemctl restart snapclient`; | ||
} | ||
else | ||
{ | ||
`systemctl start snapclient`; | ||
} | ||
} | ||
else | ||
{ | ||
`systemctl stop snapclient`; | ||
} | ||
|
||
$wpaconf = 'ctrl_interface=/var/run/wpa_supplicant | ||
#ap_scan=1 | ||
network={ | ||
ssid="'. addslashes($config['network']["wifi_ssid"]) .'" | ||
scan_ssid=1 | ||
key_mgmt=WPA-PSK | ||
psk="'. addslashes($config['network']["wifi_passphrase"]) .'" | ||
} | ||
'; | ||
|
||
if (file_get_contents($wpaconf_path) != $wpaconf) | ||
{ | ||
file_put_contents($wpaconf_path, $wpaconf); | ||
`ifdown --force wlan0`; | ||
`systemctl restart network`; | ||
`ifup wlan0`; | ||
} | ||
else | ||
{ | ||
`ifup wlan0`; | ||
} | ||
|
||
if (trim(file_get_contents("/etc/hostname")) != trim($config['general']["hostname"])) | ||
{ | ||
$cmd = 'hostnamectl set-hostname ' . escapeshellarg($config['general']["hostname"]); | ||
`$cmd`; | ||
|
||
`systemctl restart avahi-daemon`; | ||
|
||
if ($config['software']["pulseaudio_active"]) | ||
{ | ||
`systemctl restart pulseaudio`; | ||
} | ||
if ($config['software']["airplay_active"]) | ||
{ | ||
`systemctl restart shairport-sync`; | ||
} | ||
if ($config['software']["librespot_active"]) | ||
{ | ||
`systemctl restart librespot`; | ||
} | ||
if ($config['software']["snapcast_client_active"]) | ||
{ | ||
`systemctl restart snapclient`; | ||
} | ||
if ($config['software']["linein_stream_active"]) | ||
{ | ||
`systemctl restart snapserver`; | ||
} | ||
} | ||
|
||
`mount -o remount,ro /`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
error_reporting(E_ALL); | ||
ini_set("display_errors", 1); | ||
|
||
define("SERVER_PATH", __DIR__); | ||
|
||
require_once(SERVER_PATH . '/vendor/autoload.php'); | ||
require_once(SERVER_PATH . '/config.php'); | ||
|
||
$loader = new \Twig\Loader\FilesystemLoader(SERVER_PATH.'/templates'); | ||
$twig = new \Twig\Environment($loader, [ | ||
'cache' => '/tmp/twig_cache', | ||
]); | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.