check for hardware+OS compatibility & disable log-send if not

pull/925/head
Botspot 3 years ago
parent 884213436f
commit ada99f4258

24
api

@ -386,6 +386,20 @@ apt_lock_wait() { #Wait until other apt processes are finished before proceeding
echo "Done"
}
is_supported_system() {
if uname -m | grep -q 'x86' ;then
echo "Pi-Apps is not supported on x86 processors. Expect almost all apps to fail."
return 1
elif [[ "$(cat /etc/os-release | grep VERSION_CODENAME | tr -d '"' | awk -F= '{print $2}')" == @(stretch|wheezy|jessie) ]];then
echo "Pi-Apps is not supported on the outdated $(cat /etc/os-release | grep VERSION_CODENAME | tr -d '"' | awk -F= '{print $2}') operating system. Expect many apps to fail. Consider upgrading your operating system."
return 1
elif [[ "$(uname -m)" == armv6* ]];then
echo "Pi-Apps has not been tested on armv6 Raspberry Pi boards. Expect many apps to fail."
return 1
fi
return 0
}
format_log_file() { #remove ANSI escape sequences from a given file, and add OS information to beginning of file
[ -z "$1" ] && error "format_log_file: no filename given!"
[ ! -f "$1" ] && error "format_log_file: given filename ($1) does not exist or is not a file!"
@ -397,11 +411,7 @@ format_log_file() { #remove ANSI escape sequences from a given file, and add OS
get_device_info() { #returns information about current install and hardware
echo "OS: $(cat /etc/os-release | grep PRETTY_NAME | tr -d '"' | awk -F= '{print $2}')"
echo "OS architecture: ${arch}-bit"
if [ "$(cat /proc/self/cgroup | grep '^0:' | grep -o 'session-.*\.')" != 'session-1.' ];then
echo "OS is running in a container."
fi
[ ! -z "$DIRECTORY" ] && echo "Pi-Apps local commit ID: $(cd "$DIRECTORY"; git rev-parse HEAD)"
echo "Kernel: $(uname -m) $(uname -r)"
echo "Device model: $(cat /proc/cpuinfo | grep Model | sed 's/Model.*: //g')"
@ -415,10 +425,6 @@ get_device_info() { #returns information about current install and hardware
echo "Language: $LC_ALL"
fi
if [ -f "${DIRECTORY}/gui" ];then
echo "Pi-Apps gui script datestamp: $(date -r "${DIRECTORY}/gui" +'%x %X')"
fi
}
send_error_report() { #non-interactively send a Pi-Apps error log file to the Botspot discord server

@ -20,13 +20,9 @@ mkdir -p "${DIRECTORY}/data/status" "${DIRECTORY}/data/update-status" "${DIRECTO
#remove week-old logfiles
find "${DIRECTORY}/logs" -type f -mtime +7 -exec rm -f {} \; &>/dev/null &
#Ensure running arm processor
if uname -m | grep -q 'x86' ;then
error "Pi-Apps is not not supported on x86 processors."
fi
#check for internet connection
if ! ping -c 1 github.com &>/dev/null ;then
error "No internet connection!\ngithub.com failed to respond.\nErrors: $(ping -c 1 github.com 2>&1)"
if ! wget --spider github.com &>/dev/null ;then
error "No internet connection!\ngithub.com failed to respond.\nErrors: $(wget --spider github.com 2>&1)"
fi
dirhash() {
@ -42,41 +38,20 @@ dirhash() {
echo "$hash"
}
if [ "$1" == 'multi-install' ];then
failed_apps=''
IFS=$'\n'
for app in $2
do
"${DIRECTORY}/manage" install "$app"
if [ $? != 0 ];then
#this app failed to install - add it to the list of failed apps
failed_apps="$failed_apps
$app"
fi
done
app_results="${app_results:1}" #remove first blank newline
if [ "$1" == 'multi-uninstall' ] || [ "$1" == 'multi-install' ];then
for app in $(echo "$failed_apps" | list_intersect "$(list_apps online)") ;do
logfile="$(ls -dt "${DIRECTORY}/logs"/* | grep '\-'"${app}"'\.log' -m 1)" #sort logfiles by modification date, get the most recent one for the current app
#if logfile detected, exists, and is not empty, ask permission to send error report
if [ ! -z "$logfile" ] && [ -f "$logfile" ] && [ -s "$logfile" ];then
send_error_report_gui "$logfile" "<b>$app</b> failed to install."
fi
done
if [ ! -z "$failed_apps" ];then
exit 1
if [ "$1" == 'multi-uninstall' ];then
action=uninstall
elif [ "$1" == 'multi-install' ];then
action=install
fi
elif [ "$1" == 'multi-uninstall' ];then
failed_apps=''
IFS=$'\n'
for app in $2
do
"${DIRECTORY}/manage" uninstall "$app"
"${DIRECTORY}/manage" $action "$app"
if [ $? != 0 ];then
#this app failed to install - add it to the list of failed apps
failed_apps="$failed_apps
@ -85,14 +60,16 @@ $app"
done
app_results="${app_results:1}" #remove first blank newline
for app in $(echo "$failed_apps" | list_intersect "$(list_apps online)") ;do
logfile="$(ls -dt "${DIRECTORY}/logs"/* | grep '\-'"${app}"'\.log' -m 1)" #sort logfiles by modification date, get the most recent one for the current app
#if logfile detected, exists, and is not empty, ask permission to send error report
if [ ! -z "$logfile" ] && [ -f "$logfile" ] && [ -s "$logfile" ];then
send_error_report_gui "$logfile" "<b>$app</b> failed to uninstall."
fi
done
if [ "$supported" == yes ];then #if hardware and OS is supported
for app in $(echo "$failed_apps" | list_intersect "$(list_apps online)") ;do
logfile="$(ls -dt "${DIRECTORY}/logs"/* | grep '\-'"${app}"'\.log' -m 1)" #sort logfiles by modification date, get the most recent one for the current app
#if logfile detected, exists, and is not empty, ask permission to send error report
if [ ! -z "$logfile" ] && [ -f "$logfile" ] && [ -s "$logfile" ];then
send_error_report_gui "$logfile" "<b>$app</b> failed to ${action}."
fi
done
fi
if [ ! -z "$failed_apps" ];then
exit 1
fi
@ -106,7 +83,6 @@ elif [ "$1" == 'install-if-not-installed' ];then
fi
elif [ "$1" == 'install' ] || [ "$1" == 'uninstall' ];then
#INSTALL
#for this operation, a program name must be specified.
app="$2"
if [ -z "$app" ];then
@ -115,6 +91,15 @@ elif [ "$1" == 'install' ] || [ "$1" == 'uninstall' ];then
error "${DIRECTORY}/apps/$app does not exist!"
fi
#check if hardware and OS is supported
if is_supported_system >/dev/null;then
supported=yes
else
supported=no
echo -e "\e[103m\e[30mWARNING: YOUR SETUP IS UNSUPPORTED:\n$(is_supported_system)\e[39m\e[49m"
sleep 10
fi
if [ "$1" == install ];then
mode=install
else

Loading…
Cancel
Save