You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							174 lines
						
					
					
						
							3.8 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							174 lines
						
					
					
						
							3.8 KiB
						
					
					
				
								#!/bin/bash
							 | 
						|
								
							 | 
						|
								prerequisites(){
							 | 
						|
									failed=0
							 | 
						|
									missing="(not found)"
							 | 
						|
									[[ $1 ]] && output=": &&" || output="printf";
							 | 
						|
									$output "$w_l  CHECK for binaries\n  ==================\n";
							 | 
						|
								
							 | 
						|
								# check for a forgotten and unusable 'upx' and remove this crap
							 | 
						|
									[ -x "$bindir"/upx ] && "$bindir"/upx -V &>/dev/null || rm -f "$bindir"/upx &>/dev/null;
							 | 
						|
								
							 | 
						|
									for e in "${binvars[@]}"
							 | 
						|
									do
							 | 
						|
										if hash "$e" 2>/dev/null
							 | 
						|
										then
							 | 
						|
											einfo=$(type -pf "$e")
							 | 
						|
											printf -v pad %40s
							 | 
						|
											e=$e$pad
							 | 
						|
											e=${e:0:15}
							 | 
						|
											$output "$w_l  have\t$g_l$e $y_l$einfo\n"
							 | 
						|
										else
							 | 
						|
											failed=1
							 | 
						|
											printf -v pad %40s
							 | 
						|
											e=$e$pad
							 | 
						|
											e=${e:0:15}
							 | 
						|
											$output "$r_l  need\t$w_l$e $r_l$missing\n"
							 | 
						|
										fi
							 | 
						|
									done
							 | 
						|
								
							 | 
						|
									if hash upx 2>/dev/null; then
							 | 
						|
										upxversion=($(upx -V | awk 'NR==1 { verok=$2>=3.91; printf "%.2f %i", $2, verok }'));
							 | 
						|
										$output "$w_l  have$g_l  upx$y_l\t\t"$w_l"Version$P ${upxversion[0]}";
							 | 
						|
										if [ ${upxversion[1]} == 1 ]
							 | 
						|
										then
							 | 
						|
											$output "$g_l ok\n"
							 | 
						|
										else
							 | 
						|
											$output "$r_l nok\n"
							 | 
						|
											failed=1
							 | 
						|
										fi
							 | 
						|
									fi
							 | 
						|
								
							 | 
						|
									$output " \n $w_l CHECK for headers\n  =================\n"
							 | 
						|
								
							 | 
						|
									for e in "${headervars[@]}"
							 | 
						|
									do
							 | 
						|
										e1=$(find /usr/include/* | grep -m1 "$e")
							 | 
						|
										if [ ${#e1} -gt 8 ]
							 | 
						|
										  then
							 | 
						|
											printf -v pad %40s
							 | 
						|
											e=$e$pad
							 | 
						|
											e=${e:0:15}
							 | 
						|
											$output "$w_l  have\t$g_l$e$y_l $e1\n"
							 | 
						|
										else
							 | 
						|
											failed=1
							 | 
						|
											printf -v pad %40s
							 | 
						|
											e=$e$pad
							 | 
						|
											e=${e:0:15}
							 | 
						|
											$output "$r_l  need\t$w_l$e$r_l $missing\n"
							 | 
						|
										fi
							 | 
						|
									done
							 | 
						|
								
							 | 
						|
								$output " \n $w_l CHECK for libraries\n  ===================\n"
							 | 
						|
								
							 | 
						|
								for e in "${libvars[@]}"
							 | 
						|
								do
							 | 
						|
									e1=$(find /usr/lib* 2>/dev/null | grep -m1 "$e")
							 | 
						|
									if [ ${#e1} -gt 8 ]
							 | 
						|
									then
							 | 
						|
										printf -v pad %40s
							 | 
						|
										e=$e$pad
							 | 
						|
										e=${e:0:15}
							 | 
						|
										$output "$w_l  have\t$g_l$e$y_l $e1\n"
							 | 
						|
									else
							 | 
						|
										failed=1
							 | 
						|
										printf -v pad %40s
							 | 
						|
										e=$e$pad
							 | 
						|
										e=${e:0:15}
							 | 
						|
										$output "$r_l  need\t$w_l$e$r_l $missing\n";
							 | 
						|
									fi
							 | 
						|
								done
							 | 
						|
								
							 | 
						|
								if [ "$(uname -m)" == "x86_64" ]
							 | 
						|
									then
							 | 
						|
									$output " \n $w_l CHECK for zlib32\n  ================\n"
							 | 
						|
									e="zlib32"
							 | 
						|
									e1="/usr/lib/libz.so"
							 | 
						|
									e2="/usr/lib32/libz.so.1"
							 | 
						|
									if [ -f $e1 ]
							 | 
						|
									then
							 | 
						|
										printf -v pad %40s
							 | 
						|
										e=$e$pad
							 | 
						|
										e=${e:0:15}
							 | 
						|
										$output "$w_l  have\t$g_l$e$y_l $e1\n"
							 | 
						|
									elif [ -f $e2 ]
							 | 
						|
										then
							 | 
						|
										printf -v pad %40s
							 | 
						|
										e=$e$pad
							 | 
						|
										e=${e:0:15}
							 | 
						|
										$output "$w_l  have\t$g_l$e$y_l $e2\n"
							 | 
						|
									else
							 | 
						|
										failed=1
							 | 
						|
										printf -v pad %40s
							 | 
						|
										e=$e$pad
							 | 
						|
										e=${e:0:15}
							 | 
						|
										$output "$r_l  need\t$w_l$e$r_l $missing\n"
							 | 
						|
									fi
							 | 
						|
								fi
							 | 
						|
								
							 | 
						|
								return $failed
							 | 
						|
								}
							 | 
						|
								
							 | 
						|
								# Parameters (all optional):
							 | 
						|
								#   $1: installer name (or "auto")
							 | 
						|
								#   $2: add architecture (not implemented yet)
							 | 
						|
								#
							 | 
						|
								# Example:
							 | 
						|
								#   syscheck debian_os
							 | 
						|
								#     call installer 'debian_os' (Do not care about the actual Linux distribution.)
							 | 
						|
								
							 | 
						|
								syscheck(){
							 | 
						|
								[[ $1 ]] && [ "$1" != "auto" ] && override="$1"
							 | 
						|
								now=$2
							 | 
						|
								if [ -d "$osdir" ]
							 | 
						|
								then
							 | 
						|
									cd "$osdir"
							 | 
						|
									x=(*)
							 | 
						|
									for i in "${x[@]}"
							 | 
						|
									do
							 | 
						|
										source "$i"
							 | 
						|
									done
							 | 
						|
								fi
							 | 
						|
								
							 | 
						|
								unset binvars; unset headervars; unset libvars;
							 | 
						|
								[ -z ${3+x} ] && binvars=( dialog grep gawk wget tar bzip2 svn xz upx patch gcc make scp sshpass openssl dos2unix patchelf ) || binvars=( $(echo "$3" | tr ' ' '\n') )
							 | 
						|
								[ -z ${4+x} ] && headervars=( crypto.h libusb.h pcsclite.h pthread.h opensslconf.h ) || headervars=( $(echo "$4" | tr ' ' '\n') )
							 | 
						|
								[ -z ${5+x} ] && libvars=( libccidtwin.so ) || libvars=( $(echo "$5" | tr ' ' '\n') )
							 | 
						|
								sanity=1
							 | 
						|
								
							 | 
						|
								if ! prerequisites silent || [ "$now" == "now" ]
							 | 
						|
								then
							 | 
						|
									clear
							 | 
						|
									s3logo
							 | 
						|
									prerequisites
							 | 
						|
									sanity=0
							 | 
						|
									installer="unknown"
							 | 
						|
								
							 | 
						|
									# Debian and Ubuntu
							 | 
						|
									[ -f /etc/debian_version ] && installer="debian_os"
							 | 
						|
								
							 | 
						|
									# CentOS and Redhat
							 | 
						|
									[ -f /etc/redhat-release ] && installer="redhat_os"
							 | 
						|
								
							 | 
						|
									# Manjaro (/etc/os-release)
							 | 
						|
									[ -f /etc/manjaro-release ] || [ -f /etc/arch-release ] && installer="manjaro_os"
							 | 
						|
								
							 | 
						|
									# SuSE (/etc/SuSE-release is depreciated -> check for YaST2)
							 | 
						|
									[ -d /etc/YaST2 ] && installer="suse_os"
							 | 
						|
								
							 | 
						|
									# Optional override via parameter
							 | 
						|
									#[[ $override ]] && installer=$override;
							 | 
						|
									printf "\n$w_l  Selected installer:    $P$installer\n"
							 | 
						|
								
							 | 
						|
									if type -t "$installer" >/dev/null
							 | 
						|
									then
							 | 
						|
										$installer && prerequisites silent && sanity=1
							 | 
						|
									else
							 | 
						|
										printf "\n$r_l  Needs manual installation.\n"
							 | 
						|
									fi
							 | 
						|
								
							 | 
						|
									printf "$re_\n"
							 | 
						|
								fi
							 | 
						|
								
							 | 
						|
								return $sanity
							 | 
						|
								}
							 | 
						|
								
							 |