Creating an RPM with CMake will result in unusable system - linux

Currently I am moving my packaging from a bunch of weird scripts into CMake using CPack. The Debian and TGZ work really nice but the RPM is giving me troubles... When I install the RPM that has been created on openSUSE 15.1 then it will result in an unusable system (no even ls can be executed anymore and I cannot dig into why as of not beeing able to open a konsole or something).
Here is my CPack code (ive stripped anything with DEB and TGZ for readability):
set(CPACK_GENERATOR "DEB;TGZ;RPM")
# Common packaging params
set(CPACK_PACKAGE_NAME "mytool")
set(VERSION "${ver_maj}.${ver_min}.${ver_build}")
set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_SET_DESTDIR true)
# RPM packaging params
set(CPACK_RPM_PACKAGE_SUMMARY "Summary")
set(CPACK_RPM_PACKAGE_NAME "mytool")
set(CPACK_RPM_PACKAGE_VERSION "${VERSION}")
set(CPACK_RPM_PACKAGE_LICENSE "Proprietary")
set(CPACK_RPM_PACKAGE_GROUP "Applications/Internet")
set(CPACK_RPM_PACKAGE_VENDOR "me, myself and I")
set(CPACK_RPM_PACKAGE_URL "https://myurl555.com/")
set(CPACK_RPM_PACKAGE_DESCRIPTION "MyDesc")
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/make/rpm/post")
set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/make/rpm/postun")
set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/make/rpm/preun")
The post script:
if [ -x %{_bindir}/gtk-update-icon-cache-2.0 ]; then
%{_bindir}/gtk-update-icon-cache-2.0 %{_datadir}/icons/hicolor > /dev/null 2>&1 || true
fi
if [ -x %{_bindir}/gtk-update-icon-cache ]; then
%{_bindir}/gtk-update-icon-cache %{_datadir}/icons/hicolor > /dev/null 2>&1 || true
fi
SYSTEMD=`pidof systemd || echo '0'`
if [ "${SYSTEMD}" != "0" ]; then
if [ -e /etc/systemd/system/mytool.service ]; then
rm /etc/systemd/system/mytool.service
fi
cp /usr/share/mytool/files/systemd/mytool.service /etc/systemd/system/mytool.service
systemctl daemon-reload
systemctl enable mytool
fi
service mytool start
if [ -x %{_bindir}/update-desktop-database ]; then
%{_bindir}/update-desktop-database > /dev/null 2>&1 || true
fi
postun:
if [ -x %{_bindir}/gtk-update-icon-cache-2.0 ]; then
%{_bindir}/gtk-update-icon-cache-2.0 %{_datadir}/icons/hicolor > /dev/null 2>&1 || true
fi
if [ -x %{_bindir}/gtk-update-icon-cache ]; then
%{_bindir}/gtk-update-icon-cache %{_datadir}/icons/hicolor > /dev/null 2>&1 || true
fi
SYSTEMD=`pidof systemd || echo '0'`
if [ "${SYSTEMD}" != "0" ]; then
systemctl daemon-reload
fi
preun:
service mytool stop > /dev/null 2>&1 || true
SYSTEMD=`pidof systemd || echo '0'`
if [ "${SYSTEMD}" != "0" ]; then
systemctl disable mytool > /dev/null 2>&1 || true
rm /etc/systemd/system/mytool.service
fi
I cannot see any reason why something like this happens. What happens to the system is that when using alt+f2 and running for example konsole then it will tell me that it cannot make konsole executable. The executable /usr/bin/konsole is still there, the groups of the user did not change, etc.

Related

Create menu from all users with /home/ directory in bash

I am trying to write a bash script to remove cookies and cache from installed browsers on shared Ubuntu machines. The problem I am facing is in creating a menu where you can select either ALL users or individual users.
I am trying to create a main menu that calls either of the 2 functions (a work in progress) to perform the tasks (I have commented out the commands to run for the meantime).
#!/bin/bash
# Remove Browser cache from Ubuntu 16.04 or Ubuntu 18.04
# Check running as root/sudo
if [ "$EUID" -ne 0 ] ;then
echo -e "Please run with;\nsudo $0"
exit
fi
# Enable extended globbing for the +(...) pattern
shopt -s extglob
## Check Ubuntu version
VERSION=$(lsb_release -d | awk -F":" '/Description/ {print $2}')
if [[ "$VERSION" = *"Ubuntu 18.04"* ]]; then
HOME_DIR="/home/ANT.DOMAIN.COM"
else
[[ "$VERSION" = *"Ubuntu 16.04"* ]]
HOME_DIR="/home/local/ANT"
fi
# Set Colours
RED='\033[1;31m'
YELLOW='\033[1;33m'
GREEN='\033[1;32m'
NC='\033[0m' # No Color
## Clear Browser Cache for ALL Users
clear_cache_all () {
mapfile -t PROFILES < <(find "$HOME_DIR" -mindepth 1 -maxdepth 1 -type d)
for PRO in "${PROFILES[#]}"
do
# Check FireFox installed
dpkg -s firefox &> /dev/null
if [ $? -eq 0 ]; then
#rm -rf "$PRO"/.mozilla/firefox/*.default/*.sqlite "$PRO"/.mozilla/firefox/*default/sessionstore.js
#rm -rf "$PRO"/.cache/mozilla/firefox/*.default/*
echo -e "FireFox Cookies & Cache Cleared for user ${GREEN}$USERNAME${NC}"
else
echo -e "${YELLOW}FireFox Not Installed...moving on${NC}"
fi
# Check Chromium installed
dpkg -s chromium-browser &> /dev/null
if [ $? -eq 0 ]; then
#rm -rf "$PRO"/.config/chromium/Default/
#rm -rf "$PRO"/.cache/chromium
echo -e "Chromium Cookies & Cache Cleared for user ${GREEN}$USERNAME${NC}"
else
echo -e "${YELLOW}Chromium Not Installed...moving on${NC}"
fi
# Check Chrome installed
dpkg -s google-chrome-stable &> /dev/null
if [ $? -eq 0 ]; then
#rm -rf "$PRO"/.config/google-chrome/Default/
#rm -rf "$PRO"/.cache/google-chrome
echo -e "Google Chrome Cookies & Cache Cleared for user ${GREEN}$USERNAME${NC}"
else
echo -e "${YELLOW}Google Chrome Not Installed...moving on${NC}"
fi
done
}
## Clear Cache for Individual Users
clear_cache_user () {
echo "stuff!"
}
# main menu function
main_menu () {
clear
if [ -d "$HOME_DIR" ]
then
mapfile -t USERS < <(find "$HOME_DIR" -mindepth 1 -maxdepth 1 -type d)
# Get basename for users
USERNAME="${USERS[#]##*/}"
string="#(${USERNAME[0]}"
for((i=1;i<${#USERNAME[#]};i++))
do
string+="|${USERNAME[$i]}"
done
string+=")"
select NAME in "Clear ALL" "${USERNAME[#]}" "Quit"
do
case $NAME in
"Clear ALL")
# Call clear_cache_all Function
clear_cache_all
exit
;;
$string)
# Call clear_cache_user Function
clear_cache_user
;;
"Quit")
exit
;;
*)
echo "Invalid option, please try again";;
esac
done
else
echo -e "${RED}Error: Cannot find home directories...exiting${NC}"
fi
}
### SCRIPT COMMANDS ###
main_menu
Ok, so I can think of two options for your problem. I'll try to follow the names of your variables.
As I can see in your code, you have already put in the variable "string" all the usernames, so my first idea is to use a read and a simple if:
read -P "Insert ALL for all users, the Username for a single user, or Quit to exit: " NAME
if [ $NAME = "ALL" ]
then
clear_cache_all
exit
elif [ $NAME = "Quit" ]
then
echo "Bye!"
exit
else
for i in "${string[#]}"
do
if [ "$i" == "$NAME" ] ; then
clear_cache_user($NAME) #Guessing you'll pass the username as a variable to the function
exit
fi
done
echo "Invalid option, please try again"
fi
The other option is to use the case statement, as you were using. The problem is that case doesn't work easy with arrays, so while it's "case / in", it doesn't mean it's checking if the variable is an element of the array. In case you are forced to use case (or are in love with it), check this two links for some solutions: this one and this one.
Hope this helps! Good luck!

Shell script segmentation fault - AWS

I've been following a tutorial on connecting a raspberry pi to the AWS greengrass and I keep getting a segmentation fault on the final step. AWS provided me with this greengrassd shell script however when i run it I'm getting a segmentation fault. I have no idea why its throwing this error so any help would be appreciated.
AWS Greengrass Tutorial / RaspberryPi
Error
pi#raspberrypi:/greengrass/ggc/packages/1.1.0 $ sudo ./greengrassd start
Setting up greengrass daemon
Validating execution environment
Found cgroup subsystem: cpu
Found cgroup subsystem: cpuacct
Found cgroup subsystem: blkio
Found cgroup subsystem: memory
Found cgroup subsystem: devices
Found cgroup subsystem: freezer
Found cgroup subsystem: net_cls
Starting greengrass daemon./greengrassd: line 158: 2254 Segmentation fault nohup $COMMAND > /dev/null 2> $CRASH_LOG < /dev/null
Greengrass daemon 2254 failed to start
greengrassd script
#!/usr/bin/env bash
##########Environment Requirement for Greengrass Daemon##########
# by default, the daemon assumes it's going to be launched from a directory
# that has the following structure:
# GREENGRASS_ROOT/
# greengrassd
# bin/daemon
# configuration/
# group/group.json
# certs/server.crt
# lambda/
# system_lambda1/...
# system_lambda2/...
# root cgroup has to be mounted separately, this script doesn't do that for you.
#################################################################
set -e
PWD=$(cd $(dirname "$0"); pwd)
GGC_PKG_HOME=$(readlink -f $PWD)
GG_HOME=$(cd $GGC_PKG_HOME/../../; pwd)
CRASH_LOG=$GG_HOME/var/log/crash.log
GGC_ROOT_FS=$GGC_PKG_HOME/ggc_root
PID_FILE=/var/run/greengrassd.pid
FS_SETTINGS=/proc/sys/fs
GGC_GROUP=ggc_group
GGC_USER=ggc_user
MAX_DAEMON_KILL_WAIT_SECONDS=60
RETRY_SIGTERM_INTERVAL_SECONDS=20
if [ -z "$COMMAND" ]; then
COMMAND="$GGC_PKG_HOME/bin/daemon -core-dir=$GGC_PKG_HOME -greengrassdPid=$$"
fi
# Function ran as part of initial setup
setup() {
echo "Setting up greengrass daemon"
mkdir -p $GGC_ROOT_FS
# Mask greengrass directory for containers
mknod $GGC_ROOT_FS/greengrass c 1 3 &>/dev/null || true
mkdir -p $(dirname "$CRASH_LOG")
}
validatePlatformSecurity() {
if [[ -f $FS_SETTINGS/protected_hardlinks &&
-f $FS_SETTINGS/protected_symlinks ]]; then
PROT_HARDLINK_VAL=$(cat $FS_SETTINGS/protected_hardlinks)
PROT_SOFTLINK_VAL=$(cat $FS_SETTINGS/protected_symlinks)
if [[ "$PROT_HARDLINK_VAL" -ne 1 || "$PROT_SOFTLINK_VAL" -ne 1 ]]; then
echo "AWS Greengrass detected insecure OS configuration: No hardlink/softlink protection enabled." | tee -a $CRASH_LOG
exit 1
fi
fi
}
validateEnvironment() {
echo "Validating execution environment"
# ensure all commands that the installation script is going to use are available
if ! type grep >/dev/null ; then
echo "grep command is NOT on the path or is NOT installed on the system"
exit 1
fi
if ! type cat >/dev/null ; then
echo "cat command is NOT on the path or is NOT installed on the system"
exit 1
fi
if ! type awk >/dev/null ; then
echo "awk command is NOT on the path or is NOT installed on the system"
exit 1
fi
if ! type id >/dev/null ; then
echo "id command is NOT on the path or is NOT installed on the system"
exit 1
fi
if ! type ps >/dev/null ; then
echo "ps command is NOT on the path or is NOT installed on the system"
exit 1
fi
if ! type sqlite3 >/dev/null ; then
echo "sqlite3 command is NOT on the path or is NOT installed on the system"
exit 1
fi
# the script needs to be run as root
if [ ! $(id -u) = 0 ]; then
echo "The script needs to be run using sudo"
exit 1
fi
if ! id $GGC_USER >/dev/null ; then
echo "${GGC_USER} doesn't exist. Please add a user ${GGC_USER} on the system"
exit 1
fi
if ! grep -q $GGC_GROUP /etc/group ; then
echo "${GGC_GROUP} doesn't exist. Please add a group ${GGC_GROUP} on the system"
exit 1
fi
# ensure that kernel supports cgroup
if [ ! -e /proc/cgroups ]; then
echo "The kernel in use does NOT support cgroup."
exit 1
fi
# assume that all kernel supported subsystems, which are listed in /proc/cgroups, are going to be used
# so check whether all of them are mounted.
for d in `awk '$4 == 1 {print $1}' /proc/cgroups`; do
if cat /proc/self/cgroup | grep -q $d; then
echo "Found cgroup subsystem: $d"
else
# exit with error if can't find cgroup
echo "The cgroup subsystem is not mounted: $d"
exit 1
fi
done
}
finish() {
pid=$1
echo "$pid" > $PID_FILE
echo ""
echo -e "\e[0;32mGreengrass successfully started with PID: $pid\e[0m"
exit 0
}
start() {
setup
if [[ $INSECURE -ne 1 ]]; then
validatePlatformSecurity
fi
validateEnvironment
trap 'finish $pid' SIGUSR1
echo ""
echo -n "Starting greengrass daemon"
if nohup $COMMAND >/dev/null 2>$CRASH_LOG < /dev/null &
then
pid=$!
# sleep 10 seconds to wait for daemon to start or exit
sleep 10 &
wait $!
echo ""
echo "Greengrass daemon $pid failed to start"
echo -e "\e[0;31m$(cat $CRASH_LOG)\e[0m"
exit 1
else
echo "Failed to start Greengrass daemon"
exit 1
fi
}
version() {
$GGC_PKG_HOME/bin/daemon --version
}
stop() {
if [ -f $PID_FILE ]; then
PID=$(cat $PID_FILE)
echo "Stopping greengrass daemon of PID: $PID"
if [ ! -e "/proc/$PID" ]; then
rm $PID_FILE
echo "Process with pid $PID does not exist already"
return 0
fi
echo -n "Waiting"
kill "$PID" > /dev/null 2>&1
total_sleep_seconds=0
until [ "$total_sleep_seconds" -ge "$MAX_DAEMON_KILL_WAIT_SECONDS" ]; do
sleep 1
# If the pid no longer exists, we're done, remove the pid file and exit. Otherwise, just increment the loop counter
if [ ! -e "/proc/$PID" ]; then
rm $PID_FILE
echo -e "\nStopped greengrass daemon, exiting with success"
break
else
total_sleep_seconds=$(($total_sleep_seconds+1))
echo -n "."
fi
# If it has been $RETRY_SIGTERM_INTERVAL_SECONDS since the last SIGTERM, send SIGTERM
if [ $(($total_sleep_seconds % $RETRY_SIGTERM_INTERVAL_SECONDS)) -eq "0" ]; then
kill "$PID" > /dev/null 2>&1
fi
done
if [ $total_sleep_seconds -ge $MAX_DAEMON_KILL_WAIT_SECONDS ] && [ -e "/proc/$PID" ]; then
# If we are here, we never exited in the previous loop and the pid still exists. Exit with failure.
kill -9 "$PID" > /dev/null 2>&1
echo -e "\nProcess with pid $PID still alive after timeout of $MAX_DAEMON_KILL_WAIT_SECONDS seconds. Forced kill process, exiting with failure."
exit 1
fi
fi
}
usage() {
echo ""
echo "Usage: $0 [FLAGS] {start|stop|restart}"
echo ""
echo -e "[FLAGS]: \n -i, --insecure \t Run GGC in insecure mode without hardlink/softlink protection, (highly discouraged for production use) \n -v, --version \t\t Outputs the version of GGC."
echo ""
exit 1
}
if [[ $# -eq 0 ]]; then
usage
fi
for var in "$#"
do
case "$var" in
-v|--version)
version
exit 0
;;
esac
done
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-i|--insecure)
mkdir -p $(dirname "$CRASH_LOG")
echo "Warning! You are running in insecure mode, this is highly discouraged!" | tee -a $CRASH_LOG
INSECURE=1
;;
-h|--help)
usage
;;
start)
stop
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
usage
esac
shift
done
#Jim Maybe check the model of Pi you are using?
It seems that the Pi version of Greengrass is for ARMv7-A. I got this problem too and I'm using an older Model 1 B+ which is ARMv6Z (https://en.wikipedia.org/wiki/Raspberry_Pi#Specifications).
The error we're seeing for line 158 is the ./greengrassd script waiting for the actual process to run:
sudo /greengrass/ggc/packages/1.1.0/bin/daemon -core-dir=/greengrass/ggc/packages/1.1.0 -greengrassdPid=641
/greengrass/ggc/packages/1.1.0/bin/daemon is the binary. If you run the above command directly in the console it exits with the same segmentation fault error.
AWS do recommend using the Pi 3 so I'm guessing it will work on that.

How can I check that program was installed successfully on linux?

I have .bin file, that contains a lot of scripts, that install program on Ubuntu and after installing via terminal
sudo chmod u+x myprogram.bin
./myprogram
I have it in /usr/bin/myprogram.
I need to write the program, which checks if some program was installed correctly to the system. How can I do that ?
Any one of the followings should work
$ command -v foo >/dev/null 2>&1 && echo "installed" || echo "not installed"
$ type foo >/dev/null 2>&1 && echo "installed" || echo "not installed"
$ hash foo >/dev/null 2>&1 && echo "installed" || echo "not installed"
In your case you may use
$ command -v /usr/bin/myprogram >/dev/null 2>&1 && echo "installed" || echo "not installed"
or else you can create function like below
#!/usr/bin/env bash
installed()
{
command -v "$1" >/dev/null 2>&1
}
# and then
if installed ls; then
echo 'ls exists'
else
echo 'ls not installed'
fi
Examples :
$ command -v ls >/dev/null 2>&1 && echo "installed" || echo "not installed"
installed
$ command -v foo >/dev/null 2>&1 && echo "installed" || echo "not installed"
not installed
If you already know the full path to the application/program then any one of the following should work
$ test -x /bin/ls && echo 'installed' || echo 'not installed'
installed
$ [ -x /bin/ls ] && echo 'installed' || echo 'not installed'
installed

Bash if condition to check if a ubuntu package has a newer version?

I need a bash line to check if a ubuntu package needs an upgrade or not.
For example, I want to check if the package 'firefox' needs an upgrade using dpkg or apt-get commands.
Hypthetical Example:
# Hypothetical example pseudo-code
if [[ $(firefox_needs_upgrade) ]]; then echo "Firefox needs upgrading";fi
This should work for you:
#!/bin/bash
PACKAGE="firefox"
TMP_FILE="/tmp/upgrade_list"
apt-get -yqq update
apt-get -sqq upgrade | grep Inst > ${TMP_FILE}
grep -qi ${PACKAGE} ${TMP_FILE}
if [ $? == 0 ]
then
echo "${PACKAGE} needs to be upgraded"
fi
Following command would help you :-
/usr/lib/update-notifier/apt-check --human-readable
or
cat /var/lib/update-notifier/updates-available
For more details you can check the link below :-
https://askubuntu.com/questions/49958/how-to-find-the-number-of-packages-needing-update-from-the-command-line
Thanks & Regards,
Alok Thaker
Bash function:
apt_needs_upgrade() {
NEEDS_UPGRADE=$(/usr/lib/update-notifier/apt-check -p 2>&1 >/dev/null | grep "^$1$" | wc -l)
if [ "$NEEDS_UPGRADE" == 1 ]; then
return 0; # 0 means true in bash!!!
else
return 1; # false
fi;
}
Use it:
if apt_needs_upgrade "firefox"; then
echo "Needs upgrading"
else
echo "No need to upgrade"
fi;
Ok edited my answer with a tested code. It's maybe a more pretty way to do it :
#retrieving info about the package
dpkg -l $1 >/dev/null
if [ $? -ne 0 ]
then
echo "$1 not installed or issue retrieving informations"
exit
else
#We check if pkg is upgradable
UPGRADABLE=$(apt-get -s upgrade -u | egrep -c "^Conf $1 |^Inst $1 ")
if [ $UPGRADABLE -gt 0 ]
then
echo "$1 need an upgrade"
else
echo "$1 up to date"
fi
fi
usage :
# /tmp/check.sh openssh-server
openssh-server need an upgrade

A universal bash script for installing with apt-get and yum

I'm trying to write a simple bash wrapper which abstracts yum and apt-get. Basically so we can do something like universal-install curl Here is what I have so far:
# universal-install
package=$1
apt=`command -v apt-get`
yum=`command -v yum`
if [ -n "$apt" ]; then
apt-get update
apt-get -y install $package
elif [ -n "$yum" ]; then
yum -y install $package
else
echo "Err: no path to apt-get or yum" >&2;
exit 1;
fi
Are there any errors or improvements/optimizations that can be made?
Take a look at how pacapt detects the OS:
# Detect package type from /etc/issue
_found_arch() {
local _ostype="$1"
shift
grep -qis "$*" /etc/issue && _OSTYPE="$_ostype"
}
# Detect package type
_OSTYPE_detect() {
_found_arch PACMAN "Arch Linux" && return
_found_arch DPKG "Debian GNU/Linux" && return
_found_arch DPKG "Ubuntu" && return
_found_arch YUM "CentOS" && return
_found_arch YUM "Red Hat" && return
_found_arch YUM "Fedora" && return
_found_arch ZYPPER "SUSE" && return
[[ -z "$_OSTYPE" ]] || return
# See also https://github.com/icy/pacapt/pull/22
# Please not that $OSTYPE (which is `linux-gnu` on Linux system)
# is not our $_OSTYPE. The choice is not very good because
# a typo can just break the logic of the program.
if [[ "$OSTYPE" != "darwin"* ]]; then
_error "Can't detect OS type from /etc/issue. Running fallback method."
fi
[[ -x "/usr/bin/pacman" ]] && _OSTYPE="PACMAN" && return
[[ -x "/usr/bin/apt-get" ]] && _OSTYPE="DPKG" && return
[[ -x "/usr/bin/yum" ]] && _OSTYPE="YUM" && return
[[ -x "/opt/local/bin/port" ]] && _OSTYPE="MACPORTS" && return
command -v brew >/dev/null && _OSTYPE="HOMEBREW" && return
[[ -x "/usr/bin/emerge" ]] && _OSTYPE="PORTAGE" && return
[[ -x "/usr/bin/zypper" ]] && _OSTYPE="ZYPPER" && return
if [[ -z "$_OSTYPE" ]]; then
_error "No supported package manager installed on system"
_error "(supported: apt, homebrew, pacman, portage, yum)"
exit 1
fi
}
As you can see it first checks /etc/issue, then failing that the script looks for the associated executable file for each package manager.
But heck, why not just use pacapt, instead of rolling your own?
If you're going to do this, why require the user to tell the script which tool to use?
#!/bin/bash
# Find our package manager
if VERB="$( which apt-get )" 2> /dev/null; then
echo "Debian-based"
elif VERB="$( which yum )" 2> /dev/null; then
echo "Modern Red Hat-based"
elif VERB="$( which portage )" 2> /dev/null; then
echo "Gentoo-based"
elif VERB="$( which pacman )" 2> /dev/null; then
echo "Arch-based"
else
echo "I have no idea what I'm doing." >&2
exit 1
fi
if [[ 1 -ne $# ]]; then
echo "Syntax: $0 PACKAGE"
exit 1
fi
$VERB "$1"
exit $?
Slightly better would to to look at /etc/issue to see what your distribution is and behave accordingly.
I was looking for a one-liner to install a package and couldn't find any so this was my final version:
if [ "" == "`which unzip`" ]; then echo "Unzip Not Found"; if [ -n "`which apt-get`" ]; then apt-get -y install unzip ; elif [ -n "`which yum`" ]; then yum -y install unzip ; fi ; fi
It's specific for the unzip package, but can be altered to any other package that is available on apt-get/yum.
Hope this will help someone :)
#!/bin/bash
# file: src/bash/aspark-starter/install-prerequisites-for-aspark-starter.sh
# caveat package names are for Ubuntu !!!
set -eu -o pipefail # fail on error , debug all lines
# run as root
[ "${USER:-}" = "root" ] || exec sudo "$0" "$#"
echo "=== $BASH_SOURCE on $(hostname -f) at $(date)" >&2
echo installing the must-have pre-requisites
while read -r p ; do
if [ "" == "`which $p`" ];
then echo "$p Not Found";
if [ -n "`which apt-get`" ];
then apt-get install -y $p ;
elif [ -n "`which yum`" ];
then yum -y install $p ;
fi ;
fi
done < <(cat << "EOF"
perl
zip unzip
exuberant-ctags
mutt
libxml-atom-perl
postgresql-9.6
libdbd-pgsql
curl
wget
libwww-curl-perl
EOF
)
echo installing the nice-to-have pre-requisites
echo you have 5 seconds to proceed ...
echo or
echo hit Ctrl+C to quit
echo -e "\n"
sleep 6
echo installing the nice to-have pre-requisites
while read -r p ; do
if [ "" == "`which $p`" ];
then echo "$p Not Found";
if [ -n "`which apt-get`" ];
then apt-get install -y $p ;
elif [ -n "`which yum`" ];
then yum -y install $p ;
fi ;
fi
done < <(cat << "EOF"
tig
EOF
)

Resources