diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 39662160..59aaa385 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,7 @@ jobs: matrix: config: - { - name: "Ubuntu Latest GCC (Release)", + name: "Build Dash and dependencies", os: ubuntu-latest, build_type: "Release", cc: "gcc", @@ -31,7 +31,7 @@ jobs: steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Print env run: | @@ -39,18 +39,11 @@ jobs: echo github.event_name: ${{ github.event_name }} - name: Install dependencies on ubuntu - if: startsWith(matrix.config.name, 'Ubuntu Latest GCC') run: | - sudo apt-get update + sudo apt-get update && sudo apt-get upgrade -y # sudo apt-get install --no-install-recommends libxkbcommon-x11-0 libgl1-mesa-dev xserver-xorg-video-all xserver-xorg-input-all xserver-xorg-core xinit x11-xserver-utils - cmake --version - gcc --version - - - name: Patch install.sh - shell: bash - run: | - sed -i 's/libusb-1.0.0-dev/libusb-1.0-0-dev/g' install.sh - sed -i 's/^\s*\.\/dash/\# \.\/dash/g' install.sh + # cmake --version + # gcc --version - name: Build shell: bash diff --git a/autostart.sh b/autostart.sh new file mode 100755 index 00000000..1279771f --- /dev/null +++ b/autostart.sh @@ -0,0 +1,183 @@ +#!/bin/bash + +### +# Helper scripts for setting autostart methods for Dash application +### + +display_help() { + echo "Autostart install helpers Version 0.3" + echo "Usage: $0 [option...]" >&2 + echo + echo " -adi, --adddesktopicon Add desktop icon" + echo " -asd, --autostartdaemon Add autostart daemon" + echo " -axi, --addxinit Add xinit autostart" + echo " -h, --help Show help of script" + echo + echo "Example: Add an desktop icon" + echo " helpers.sh -adi" + echo + echo "Example: Add autostart Systemd daemon" + echo " helpers.sh -asd" + echo + echo "Example: Add autostart xinit script" + echo " helpers.sh -axi" + echo + exit 1 +} + + +add_desktop_icon () { + # Remove existing opendash desktop + if [ -f $HOME/Desktop/dash.desktop ]; then + echo "Removing existing shortcut" + rm $HOME/Desktop/dash.desktop + fi + + # Copy icon to pixmaps folder + echo "Copying icon to system directory (requires sudo)" + sudo cp -v assets/icons/opendash.xpm /usr/share/pixmaps/opendash.xpm + + # Create shortcut on dashboard + echo "Creating desktop shortcut at ~/Desktop/dash.desktop" + bash -c "echo '[Desktop Entry] +Name=Dash +Comment=Open Dash +Icon=/usr/share/pixmaps/opendash.xpm +Exec=$HOME/dash/bin/dash +Type=Application +Encoding=UTF-8 +Terminal=true +Categories=None; + ' > $HOME/Desktop/dash.desktop" + chmod +x $HOME/Desktop/dash.desktop +} + +create_autostart_daemon() { + WorkingDirectory="$HOME/dash" + if [[ $2 != "" ]] + then + WorkingDirectory="$HOME/$2/dash" + fi + echo ${WorkingDirectory} + + if [ -f "/etc/systemd/system/dash.service" ]; then + # Stop and disable dash service + echo "Stopping and removing previous service" + sudo systemctl stop dash.service || true + sudo systemctl disable dash.service || true + + # Remove existing dash service + sudo systemctl unmask dash.service || true + fi + # Write dash service unit + echo "Creating Dash service unit" + sudo bash -c "echo '[Unit] +Description=Dash +After=graphical.target + +[Service] +Type=idle +User=$USER +StandardOutput=inherit +StandardError=inherit +Environment=DISPLAY=:0 +Environment=XAUTHORITY=${HOME}/.Xauthority +WorkingDirectory=${WorkingDirectory} +ExecStart=${WorkingDirectory}/bin/dash +Restart=on-failure +RestartSec=5s +KillMode=process +TimeoutSec=infinity + +[Install] +WantedBy=graphical.target + ' > /etc/systemd/system/dash.service" + + # Activate and start dash service + echo "Enabling and starting Dash service" + sudo systemctl daemon-reload + sudo systemctl enable dash.service + sudo systemctl start dash.service + sudo systemctl status dash.service +} + +add_xinit_autostart () { + # Install dependencies + echo "Installing xinit and Xorg dependencies" + sudo apt install -y xserver-xorg xinit x11-xserver-utils + + # Create .xinitrc + echo "Creating ~/.xinitrc" + cat < $HOME/.xinitrc +#!/usr/bin/env sh +xset -dpms +xset s off +xset s noblank + +while [ true ]; do + sh $HOME/run_dash.sh +done +EOT + + # Create runner + echo "Creating ~/run_dash.sh and linking to ~/dash/bin/dash" + cat < $HOME/run_dash.sh +#!/usr/bin/env sh +$HOME/dash/bin/dash >> $HOME/dash/bin/dash.log 2>&1 +sleep 1 +EOT + + # Append to .bashrc + echo "Appending startx to ~/.bashrc" + cat <> $HOME/.bashrc + +### xinit +if [ "\$(tty)" = "/dev/tty1" ]; then + startx +fi +EOT + +} + +# Main Menu +while : +do + case "$1" in + -adi | --adddesktopicon) + add_desktop_icon + exit 0 + ;; + -asd | --autostartdaemon) + if [ $# -ne 0 ]; then + create_autostart_daemon $2 + exit 0 + fi + ;; + -axi | --addxinit) + if [ $# -ne 0 ]; then + add_xinit_autostart + exit 0 + fi + ;; + -h | --help) + display_help # Call your function + exit 0 + ;; + "") # If $1 is blank, run display_help + display_help + exit 0 + ;; + --) # End of all options + shift + break + ;; + -*) + echo "Error: Unknown option: $1" >&2 + ## or call function display_help + exit 1 + ;; + *) # No more options + break + ;; + esac +done \ No newline at end of file diff --git a/install.sh b/install.sh index bab62fc3..70f98c77 100755 --- a/install.sh +++ b/install.sh @@ -22,17 +22,41 @@ display_help() { echo } -#determine if script is being run on bullseye or above -BULLSEYE=false -read -d . DEBIAN_VERSION < /etc/debian_version -if (( $DEBIAN_VERSION > 10 )); then - echo Detected Debian version of Bullseye or above - BULLSEYE=true +# Check Distro version +if [ -f /etc/os-release ]; then + OS_DISTRO=$(source /etc/os-release; echo ${PRETTY_NAME%% *}) + if [ $OS_DISTRO = "Debian" ]; then + isDebian=true + #determine if script is being run on bullseye or above + read -d . DEBIAN_VERSION < /etc/debian_version + if (( $DEBIAN_VERSION > 10 )); then + echo Detected Debian version of Bullseye or above + BULLSEYE=true + else + echo Older version of Debian detected + BULLSEYE=false + fi + elif [ $OS_DISTRO = "Ubuntu" ]; then + isUbuntu=true + UBUNTU_VERSION=$(source /etc/os-release; echo ${VERSION_ID%% *} | cut -c1-2) + if (( $UBUNTU_VERSION >= 22 )); then + echo Detcted Ubuntu version of Jammy or above + JAMMY=true + else + echo Older version of Ubuntu detected. + JAMMY=false + fi + else + echo "Unsupported OS detected. Recommended Debian 12 or Ubuntu 22.04" + exit 1 + fi fi #check if /etc/rpi-issue exists, if not set the install Args to be false if [ -f /etc/rpi-issue ] then + rpiModel=$(awk '{print $3}' < /sys/firmware/devicetree/base/model) + echo "Detected Raspberry Pi Model $rpiModel" installArgs="-DRPI_BUILD=true" isRpi=true else @@ -40,6 +64,15 @@ else isRpi=false fi +#check for potential resource limit +totalMem=$(free -tm | awk '/Total/ {print $2}') +if [[ $totalMem -lt 1900 ]]; then + echo "$totalMem MB RAM detected" + echo "You may run out of memory while compiling with less than 2GB" + echo "Consider raising swap space or compiling on another machine" + sleep 5; +fi + BUILD_TYPE="Release" #check to see if there are any arguments supplied, if none are supplied run full install @@ -99,7 +132,7 @@ else if [ $isRpi = true ]; then pulseaudio=true bluez=true - ofono=true + ofono=false # Skip Ofono due to issue with Bluetooth HSP fi fi @@ -113,7 +146,7 @@ dependencies=( "alsa-utils" "cmake" "libboost-all-dev" -"libusb-1.0.0-dev" +"libusb-1.0-0-dev" "libssl-dev" "libprotobuf-dev" "protobuf-c-compiler" @@ -160,14 +193,15 @@ if [ $deps = false ] then echo -e skipping dependencies '\n' else - if [ $BULLSEYE = false ]; then + if [ $isDebian ] && [ $BULLSEYE = false ]; then echo Adding qt5-default to dependencies dependencies[${#dependencies[@]}]="qt5-default" fi + echo installing dependencies #loop through dependencies and install - echo Running apt update - sudo apt update + echo Running apt-get update + sudo apt-get update installString="sudo apt-get install -y " @@ -191,6 +225,9 @@ if [ $pulseaudio = false ] then echo -e skipping pulseaudio '\n' else + #change to project root + cd $script_path + echo Preparing to compile and install pulseaudio echo Grabbing pulseaudio deps sudo sed -i 's/#deb-src/deb-src/g' /etc/apt/sources.list @@ -226,14 +263,16 @@ if [ $ofono = false ] echo Package failed to install with error code $?, quitting check logs above exit 1 fi - sudo sed -i 's/load-module module-bluetooth-discover/load-module module-bluetooth-discover headset=ofono/g' /usr/local/etc/pulse/default.pa - sudo cat <> /usr/local/etc/pulse/default.pa - ### Echo cancel and noise reduction - .ifexists module-echo-cancel.so - load-module module-echo-cancel aec_method=webrtc source_name=ec_out sink_name=ec_ref - set-default-source ec_out - set-default-sink ec_ref - .endif + echo "Enabling Ofono in Pulse config" + sudo sed -i 's/load-module module-bluetooth-discover/load-module module-bluetooth-discover headset=ofono/g' /etc/pulse/default.pa + sudo tee -a /etc/pulse/default.pa <<'EOT' + +### Echo cancel and noise reduction +.ifexists module-echo-cancel.so +load-module module-echo-cancel aec_method=webrtc source_name=ec_out sink_name=ec_ref +set-default-source ec_out +set-default-sink ec_ref +.endif EOT fi @@ -242,6 +281,9 @@ if [ $bluez = false ] then echo -e skipping bluez '\n' else + #change to project root + cd $script_path + echo Installing bluez sudo apt-get install -y libdbus-1-dev libudev-dev libical-dev libreadline-dev libjson-c-dev wget www.kernel.org/pub/linux/bluetooth/bluez-5.63.tar.xz @@ -258,8 +300,8 @@ fi if [ $aasdk = false ]; then echo -e Skipping aasdk '\n' else - #change to parent directory - cd .. + #change to project root + cd $script_path #clone aasdk git clone $aasdkRepo @@ -281,6 +323,10 @@ else echo -e moving to aasdk '\n' cd aasdk + #apply set_FIPS_mode patch + echo Apply set_FIPS_mode patch + git apply $script_path/patches/aasdk_openssl-fips-fix.patch + #create build directory echo Creating aasdk build directory mkdir build @@ -330,10 +376,10 @@ fi if [ $h264bitstream = false ]; then echo -e Skipping h264bitstream '\n' else - #change to parent directory - cd .. + #change to project root + cd $script_path - #clone aasdk + #clone h264bitstream git clone $h264bitstreamRepo if [[ $? -eq 0 ]]; then echo -e h264bitstream Cloned ok '\n' @@ -402,8 +448,8 @@ fi if [ $gstreamer = true ]; then echo installing gstreamer - #change to parent directory - cd .. + #change to project root + cd $script_path #clone gstreamer echo Cloning Gstreamer @@ -425,7 +471,7 @@ if [ $gstreamer = true ]; then #change into newly cloned directory cd qt-gstreamer - if [ $BULLSEYE = true ]; then + if [ $BULLSEYE = true ] || [ $JAMMY = true ]; then #apply 1.18 patch echo Applying qt-gstreamer 1.18 patch git apply $script_path/patches/qt-gstreamer-1.18.patch @@ -435,6 +481,10 @@ if [ $gstreamer = true ]; then echo Apply greenline patch git apply $script_path/patches/greenline_fix.patch + #apply atomic patch + echo Apply atomic patch + git apply $script_path/patches/qt-gstreamer_atomic-load.patch + #create build directory echo Creating Gstreamer build directory mkdir build @@ -459,7 +509,7 @@ if [ $gstreamer = true ]; then fi echo Making Gstreamer - make -j4 + make if [[ $? -eq 0 ]]; then echo -e Gstreamer make ok'\n' @@ -493,8 +543,11 @@ if [ $openauto = false ]; then echo -e skipping openauto'\n' else echo Installing openauto - cd .. + #change to project root + cd $script_path + + #clone openauto echo -e cloning openauto'\n' git clone $openautoRepo if [[ $? -eq 0 ]]; then @@ -536,6 +589,7 @@ else echo Beginning openauto make make + if [[ $? -eq 0 ]]; then echo -e Openauto make OK'\n' else @@ -561,6 +615,9 @@ if [ $dash = false ]; then echo -e Skipping dash'\n' else + #change to project root + cd $script_path + #create build directory echo Creating dash build directory mkdir build @@ -585,6 +642,7 @@ else echo Running Dash make make + if [[ $? -eq 0 ]]; then echo -e Dash make ok, executable can be found ../bin/dash echo @@ -608,34 +666,37 @@ else echo Dash make failed with error code $? exit 1 fi + cd $script_path - #Setting openGL driver and GPU memory to 128mb + #Raspberry Pi addons if $isRpi; then - sudo raspi-config nonint do_memory_split 128 - if [[ $? -eq 0 ]]; then - echo -e Memory set to 128mb'\n' + read -p "View select Raspberry Pi enhancements? (y/N) " choice + if [[ $choice == "y" || $choice == "Y" ]]; then + ./rpi.sh else - echo Setting memory failed with error code $? please set manually - exit 1 + echo "Continuing" fi + fi - sudo raspi-config nonint do_gldriver G2 - if [[ $? -eq 0 ]]; then - echo -e OpenGL set ok'\n' - else - echo Setting openGL failed with error code $? please set manually + #Autostart options + read -p "View autostart options? (y/N) " choice + if [[ $choice == "y" || $choice == "Y" ]]; then + ./autostart.sh + else + echo "Continuing" + fi + + read -p "Build complete! Run application? (y/N) " choice + if [[ $choice == "y" || $choice == "Y" ]]; then + ./bin/dash + if [[ $? -eq 1 ]]; then + echo "Something went wrong! You may need to set up Xorg/X11" exit 1 + else + exit 0 fi - - echo enabling krnbt to speed up boot and improve stability - cat <> /boot/config.txt - dtparam=krnbt -EOT + else + echo "Exiting. Check autostart.sh and rpi.sh for more options" + exit 0 fi - - - #Start app - echo Starting app - cd ../bin - ./dash -fi +fi \ No newline at end of file diff --git a/patches/aasdk_openssl-fips-fix.patch b/patches/aasdk_openssl-fips-fix.patch new file mode 100644 index 00000000..cb7576c0 --- /dev/null +++ b/patches/aasdk_openssl-fips-fix.patch @@ -0,0 +1,42 @@ +From 885a8c83ef4f813205fa21cd9e96228db94bcdd2 Mon Sep 17 00:00:00 2001 +From: "John EVANS (eva0034)" +Date: Sat, 6 Jan 2024 16:58:01 +1100 +Subject: [PATCH] Update SSLWrapper.cpp: + +fix sslwrapper.cpp for newer openssl compilation. +--- + src/Transport/SSLWrapper.cpp | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +diff --git a/src/Transport/SSLWrapper.cpp b/src/Transport/SSLWrapper.cpp +index 6aca9b44..1c770bf8 100644 +--- a/src/Transport/SSLWrapper.cpp ++++ b/src/Transport/SSLWrapper.cpp +@@ -33,13 +33,27 @@ SSLWrapper::SSLWrapper() + { + SSL_library_init(); + SSL_load_error_strings(); ++#if OPENSSL_VERSION_NUMBER >= 0x30000000L && !defined(LIBRESSL_VERSION_NUMBER) ++ /* ++ * ERR_load_*(), ERR_func_error_string(), ERR_get_error_line(), ERR_get_error_line_data(), ERR_get_state() ++ * OpenSSL now loads error strings automatically so these functions are not needed. ++ * SEE FOR MORE: ++ * https://www.openssl.org/docs/manmaster/man7/migration_guide.html ++ * ++ */ ++#else + ERR_load_BIO_strings(); ++#endif + OpenSSL_add_all_algorithms(); + } + + SSLWrapper::~SSLWrapper() + { ++#if OPENSSL_VERSION_NUMBER >= 0x30000000L ++ EVP_default_properties_enable_fips(nullptr, 0); ++#else + FIPS_mode_set(0); ++#endif + ENGINE_cleanup(); + CONF_modules_unload(1); + EVP_cleanup(); diff --git a/patches/qt-gstreamer_atomic-load.patch b/patches/qt-gstreamer_atomic-load.patch new file mode 100644 index 00000000..1fc18c11 --- /dev/null +++ b/patches/qt-gstreamer_atomic-load.patch @@ -0,0 +1,13 @@ +diff --git a/elements/gstqtvideosink/gstqtvideosinkplugin.h b/elements/gstqtvideosink/gstqtvideosinkplugin.h +index dc04671..a72c572 100644 +--- a/elements/gstqtvideosink/gstqtvideosinkplugin.h ++++ b/elements/gstqtvideosink/gstqtvideosinkplugin.h +@@ -27,7 +27,7 @@ GST_DEBUG_CATEGORY_EXTERN(gst_qt_video_sink_debug); + #define DEFINE_TYPE_FULL(cpp_type, type_name, parent_type, additional_initializations) \ + GType cpp_type::get_type() \ + { \ +- static volatile gsize gonce_data = 0; \ ++ static gsize gonce_data = 0; \ + if (g_once_init_enter(&gonce_data)) { \ + GType type = 0; \ + GTypeInfo info; \ diff --git a/rpi.sh b/rpi.sh index ea512db8..c4ca2aaf 100755 --- a/rpi.sh +++ b/rpi.sh @@ -1,74 +1,115 @@ #!/bin/bash -#check if Raspian OS is active, otherwise kill script -if [ -f /etc/rpi-issue ]; -then - echo "Great this script works for RaspberryPI OS" -else - echo "This script works only for an RaspberryPI OS" - exit 1; -fi +### +# Helper scripts for setting various parameters and config for +# Raspberry Pi units running Raspberry Pi OS. +### -display_version(){ - echo "Version 0.2 RaspberryPI Dash additional install helpers" -} - -######################### -# The command line help # -######################### display_help() { + echo "Raspberry Pi Dash additional install helpers Version 0.3" echo "Usage: $0 [option...]" >&2 echo echo " -arb, --addrulebrightness Add udev rules for brightness" - echo " -adi, --adddesktopicon Add desktop icon" - echo " -asd, --autostartdaemon Add autostart daemon" - echo " -v, --version Show version of script" + echo " -mem, --memorysplit Set memory split" + echo " -gl, --gldriver Set GL driver" + echo " -krn, --krnbt Set krnbt flag" echo " -h, --help Show help of script" echo - echo - echo "Example: Setup udev rule for controlling brightness of an official 7inch Touch screen" + echo "Example: Add touchscreen brightness rule on your RPI." echo " rpi -arb" echo - echo "Example: Add an desktop icon on your RPI." - echo " rpi -adi" + echo "Example: Set memory split on your RPI." + echo " rpi -mem 128" + echo + echo "Example: Set GL driver on your RPI." + echo " rpi -gl [G2|G1]" + echo " KMS (G2) / Fake KMS (G1)" echo - echo "Example: Add autostart daemon on your RPI." - echo " rpi -asd" + echo "Example: Set krnbt flag on your RPI." + echo " rpi -krn" echo exit 1 } -################################ -# Check if parameters options # -# are given on the commandline # -################################ +add_brightness_udev_rule() { + FILE=/etc/udev/rules.d/52-dashbrightness.rules + if [[ ! -f "$FILE" ]]; then + # udev rules to allow write access to all users for Raspberry Pi 7" Touch Screen + echo "SUBSYSTEM==\"backlight\", RUN+=\"/bin/chmod 666 /sys/class/backlight/%k/brightness\"" | sudo tee $FILE + if [[ $? -eq 0 ]]; then + echo -e "Permissions created\n" + else + echo -e "Unable to create permissions\n" + fi + else + echo -e "Rules exists\n" + fi +} + +set_memory_split() { + sudo raspi-config nonint do_memory_split $2 + if [[ $? -eq 0 ]]; then + echo -e "Memory set to 128mb\n" + else + echo "Setting memory failed with error code $? please set manually" + exit 1 + fi +} + +set_opengl() { + sudo raspi-config nonint do_gldriver $2 + if [[ $? -eq 0 ]]; then + echo -e "OpenGL set ok\n" + else + echo "Setting openGL failed with error code $? please set manually" + exit 1 + fi +} + +enable_krnbt() { + echo "enabling krnbt to speed up boot and improve stability" + echo "dtparam=krnbt" >> /boot/config.txt +} + +# Check if Raspberry Pi OS is active, otherwise kill script +if [ ! -f /etc/rpi-issue ] +then + echo "This script works only for Raspberry Pi OS" + exit 1; +fi + +# Main Menu while : do - #echo "$1" case "$1" in -arb | --addrulebrightness) - /bin/bash src/bash/brightness.sh + add_brightness_udev_rule exit 0 ;; - -adi | --adddesktopicon) - /bin/bash src/bash/desktop.sh - exit 0 + -mem | --memorysplit) + if [ $# -ne 0 ]; then + set_memory_split $2 + exit 0 + fi ;; - -asd | --autostartdaemon) + -gl | --gldriver) if [ $# -ne 0 ]; then - /bin/bash src/bash/autostartdaemon.sh $2 + set_opengl $2 exit 0 fi ;; + -krn | --krnbt) + enable_krnbt + exit 0 + ;; -h | --help) display_help # Call your function exit 0 ;; - -v | --version) - display_version # Call your function + "") # If $1 is blank, run display_help + display_help exit 0 ;; - --) # End of all options shift break diff --git a/src/bash/autostartdaemon.sh b/src/bash/autostartdaemon.sh deleted file mode 100644 index 32b24259..00000000 --- a/src/bash/autostartdaemon.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -### -# Helper script to setup an autostart daemon for openDash -### -WorkingDirectory="/home/pi/dash/" -if [[ $1 != "" ]] -then - WorkingDirectory="/home/pi/$1/dash/" -fi -echo ${WorkingDirectory} - -#stop and disable dash service -sudo systemctl stop dash.service || true -sudo systemctl disable dash.service || true - -#remove existing opendash service -sudo systemctl unmask dash.service || true - -sudo bash -c "echo '[Unit] -Description=Dash -After=graphical.target - -[Service] -Type=idle -User=pi -StandardOutput=inherit -StandardError=inherit -Environment=DISPLAY=:0 -Environment=XAUTHORITY=/home/pi/.Xauthority -WorkingDirectory=${WorkingDirectory} -ExecStart=/usr/local/bin/dash -Restart=on-failure -RestartSec=5s -KillMode=process -TimeoutSec=infinity - -[Install] -WantedBy=graphical.target -' > /etc/systemd/system/dash.service" - -sudo systemctl daemon-reload -sudo systemctl enable dash.service -sudo systemctl start dash.service -sudo systemctl status dash.service \ No newline at end of file diff --git a/src/bash/brightness.sh b/src/bash/brightness.sh deleted file mode 100755 index 53c8e464..00000000 --- a/src/bash/brightness.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -### -# Helper script to setup udev rule for controlling the brightness of a official RPI 7" touch screen -### -FILE=/etc/udev/rules.d/52-dashbrightness.rules -if [[ ! -f "$FILE" ]]; then - # udev rules to allow write access to all users for Raspberry Pi 7" Touch Screen - echo "SUBSYSTEM==\"backlight\", RUN+=\"/bin/chmod 666 /sys/class/backlight/%k/brightness\"" | sudo tee $FILE - if [[ $? -eq 0 ]]; then - echo -e Permissions created'\n' - else - echo -e Unable to create permissions'\n' - fi - else - echo -e Rules exists'\n' -fi diff --git a/src/bash/desktop.sh b/src/bash/desktop.sh deleted file mode 100755 index 3e538ce6..00000000 --- a/src/bash/desktop.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -### -# Helper script to setup an desktop icon for openDash -### - -#remove existing opendash desktop -rm /home/pi/Desktop/opendash - -#copy icon to pixmaps folder -sudo cp assets/icons/opendash.xpm /usr/share/pixmaps/opendash.xpm - -#copy executable to /usr/local/bin -sudo cp bin/dash /usr/local/bin/dash - -#create shortcut on dashboard -echo " -[Desktop Entry] -Name=OpenDash -Comment=Open OpenDash -Icon=/usr/share/pixmaps/opendash.xpm -Exec=/usr/local/bin/dash -Type=Application -Encoding=UTF-8 -Terminal=true -Categories=None; -" > /home/pi/Desktop/opendash diff --git a/uninstall.sh b/uninstall.sh new file mode 100755 index 00000000..a7b2468f --- /dev/null +++ b/uninstall.sh @@ -0,0 +1,144 @@ +#!/bin/bash + +#Help text +display_help() { + echo + echo " --aasdk uninstall aasdk" + echo " --openauto uninstall openauto " + echo " --gstreamer uninstall gstreamer " + echo " --dash uninstall dash " + echo " --h264bitstream uninstall h264bitstream" + echo " --pulseaudio uninstall pulseaudio" + echo " --bluez uninstall bluez" + echo " --ofono uninstall ofono" + echo " --all uninstall all components " + echo +} + +script_path=$(dirname "$(realpath -s "$0")") + +#check to see if there are any arguments supplied, if none are supplied run full install +if [ $# -gt 0 ]; then + #initialize all arguments to false before looping to find which are available + aasdk=false + gstreamer=false + openauto=false + dash=false + h264bitstream=false + pulseaudio=false + bluez=false + ofono=false + while [ "$1" != "" ]; do + case $1 in + --aasdk ) aasdk=true + ;; + --gstreamer ) gstreamer=true + ;; + --openauto ) openauto=true + ;; + --dash ) dash=true + ;; + --h264bitstream ) h264bitstream=true + ;; + --pulseaudio ) pulseaudio=true + ;; + --bluez ) bluez=true + ;; + --ofono ) ofono=true + ;; + -h | --help ) display_help + exit + ;; + * ) display_help + exit 1 + esac + shift + done +else + echo -e Full uninstall running'\n' + aasdk=true + gstreamer=true + openauto=true + dash=true + h264bitstream=true + pulseaudio=true + bluez=true + ofono=true +fi + +if [ $pulseaudio = true ] && [ -d "$script_path/pulseaudio" ]; then + echo "Uninstalling pulseaudio" + cd pulseaudio + sudo make uninstall + cd .. + sudo rm -rv pulseaudio + rm uninstall +fi + +if [ $ofono = true ] && [[ $(dpkg -l ofono 2> /dev/null) ]]; then + echo "Uninstalling ofono" + sudo apt purge -y ofono + echo "Removing pulse config enhancemnets" + sudo sed -i 's/load-module module-bluetooth-discover headset=ofono/load-module module-bluetooth-discover/g' /etc/pulse/default.pa + sudo sed -i '/### Echo cancel and noise reduction/,/.endif/d' /etc/pulse/default.pa +fi + +if [ $bluez = true ] && [ -d "$script_path/bluez-5.63" ]; then + echo "Uninstalling bluez-5.63" + cd bluez-5.63 + sudo make uninstall + cd .. + rm -rv bluez-5.63 +fi + +if [ $aasdk = true ] && [ -d "$script_path/aasdk/build" ]; then + echo "Removing aasdk" + cd aasdk/build + xargs sudo rm < install_manifest.txt + cd ../.. + sudo rm -rv aasdk +fi + +if [ $h264bitstream = true ] && [ -d "$script_path/h264bitstream" ]; then + echo "Uninstalling h264bitstream" + cd h264bitstream + sudo make uninstall + cd .. + sudo rm -rv h264bitstream +fi + +if [ $gstreamer = true ] && [ -d "$script_path/qt-gstreamer/build" ]; then + echo "Uninstalling qt-gstreamer" + cd qt-gstreamer/build + sudo make uninstall + cd ../.. + sudo rm -rv qt-gstreamer +fi + +if [ $openauto = true ] && [ -d "$script_path/openauto/build" ]; then + echo "Removing openauto" + cd openauto/build + xargs sudo rm < install_manifest.txt + cd ../.. + sudo rm -rv openauto +fi + +if [ $dash = true ] && [ -d "$script_path/bin" ]; then + echo "Removing dash binary" + rm -rv bin build + if [ -f "$HOME/Desktop/dash.desktop" ]; then + echo "Removing desktop shortcut" + rm -v $HOME/Desktop/dash.desktop + fi + if [ -f "/etc/systemd/system/dash.service" ]; then + echo "Removing Systemd daemon" + sudo systemctl stop dash.service || true + sudo systemctl disable dash.service || true + sudo systemctl unmask dash.service || true + fi + if [ -f $HOME/run_dash.sh ]; then + echo "Removing xinit runner and bashrc line" + rm -v $HOME/run_dash.sh + sed -i '/### xinit/,/fi/d' $HOME/.bashrc + fi +fi \ No newline at end of file