From bfa4eae68642a62900e8d4da40a15a8ac6acb89f Mon Sep 17 00:00:00 2001 From: "S.Rahul" Date: Sat, 11 Oct 2025 16:26:54 +0530 Subject: [PATCH] Fix syntax errors and improve installation script robustness Corrected conditional syntax in install.sh and ensured proper installation of Google Earth by adding error handling. Enhanced the handling of dotfiles to only process regular files. Updated index.php to prevent errors when reading queries and improved KML file processing by checking for valid file names. --- install.sh | 19 +++++++++---------- php-interface/index.php | 18 ++++++++++++------ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/install.sh b/install.sh index ec42f68..2c4d780 100755 --- a/install.sh +++ b/install.sh @@ -114,7 +114,7 @@ done printf -v LG_FRAMES "%s " "${array[@]}" -if [ $INSTALL_DRIVERS_CHAR == "y" ] || [$INSTALL_DRIVERS_CHAR == "Y" ] ; then +if [ $INSTALL_DRIVERS_CHAR == "y" ] || [ $INSTALL_DRIVERS_CHAR == "Y" ] ; then INSTALL_DRIVERS=true @@ -214,7 +214,7 @@ if [ $INSTALL_DRIVERS == true ] ; then sudo apt-get install -yq libfontconfig1:i386 libx11-6:i386 libxrender1:i386 libxext6:i386 libglu1-mesa:i386 libglib2.0-0:i386 libsm6:i386 - sudo apt-get install nvidia-361 + sudo apt-get install -y nvidia-361 fi @@ -222,7 +222,7 @@ echo "Installing Google Earth..." wget -q $EARTH_DEB -sudo dpkg -i google-earth*.deb +sudo dpkg -i google-earth*.deb || sudo apt-get install -f -y rm google-earth*.deb # OS config tweaks (like disabling idling, hiding launcher bar, ...) @@ -234,7 +234,7 @@ autologin-user=$LOCAL_USER autologin-user-timeout=0 autologin-session=ubuntu EOM -echo autologin-user=lg >> sudo /etc/lightdm/lightdm.conf +echo autologin-user=lg | sudo tee -a /etc/lightdm/lightdm.conf > /dev/null gsettings set org.gnome.desktop.screensaver idle-activation-enabled false gsettings set org.gnome.desktop.session idle-delay 0 gsettings set org.gnome.desktop.screensaver lock-enabled false @@ -269,14 +269,13 @@ fi sudo cp -r $USER_PATH/gnu_linux/home/lg/. $HOME -for file in *; do - - sudo mv "$HOME/dotfiles/$file" "$HOME/dotfiles/.$file" - +for file in $HOME/dotfiles/*; do + if [ -f "$file" ]; then + filename=$(basename "$file") + sudo mv "$file" "$HOME/dotfiles/.$filename" + fi done -sudo cp -r . $HOME - cd - > /dev/null sudo cp -r $USER_PATH/gnu_linux/etc/ $USER_PATH/gnu_linux/patches/ $USER_PATH/gnu_linux/sbin/ / diff --git a/php-interface/index.php b/php-interface/index.php index 3351b02..23c2664 100755 --- a/php-interface/index.php +++ b/php-interface/index.php @@ -21,10 +21,12 @@ if ($handle) { while (!feof($handle)) { $buffer = fgets($handle); - if (substr_count($buffer, $delimiter) == 2) { + if ($buffer && substr_count($buffer, $delimiter) == 2) { list($planet, $name, $query) = explode($delimiter, $buffer); $planet = explode('/', $planet)[0]; // tmp subcategories - $queries[$planet][] = array(trim($name), trim($query)); + if (isset($queries[$planet])) { + $queries[$planet][] = array(trim($name), trim($query)); + } } } fclose($handle); @@ -39,9 +41,14 @@ $kml_files = array('earth' => array(), 'moon' => array(), 'mars' => array(), 'layers' => array()); foreach (array_keys($kml_files) as $planet) { $planet_kml_path = $KML_SYS_PATH . $planet . "/" . $FILE_FILTER; - foreach (glob($planet_kml_path) as $file) { - $basename = str_replace('_', ' ', explode('.', basename($file))); - $kml_files[$planet][$basename[0]] = str_replace($KML_SYS_PATH, $KML_SERVER_BASE, $file); + $files = glob($planet_kml_path); + if ($files !== false) { + foreach ($files as $file) { + $basename = str_replace('_', ' ', explode('.', basename($file))); + if (isset($basename[0])) { + $kml_files[$planet][$basename[0]] = str_replace($KML_SYS_PATH, $KML_SERVER_BASE, $file); + } + } } } @@ -153,7 +160,6 @@ function clearKmls() { -