From 98469b1d20c955fcc269a3dae274a17d70866784 Mon Sep 17 00:00:00 2001 From: Martin Winkler Date: Wed, 10 Apr 2019 12:33:34 +0100 Subject: [PATCH] preparation for verbose output of shell commands (called by function exe()) --- seqs/gitea.sh | 40 ++++++++++++++++++++-------------------- seqs/librenms.sh | 30 +++++++++++++++--------------- seqs/tvheadend.sh | 16 ++++++++-------- seqs/webserver.sh | 38 +++++++++++++++++++------------------- 4 files changed, 62 insertions(+), 62 deletions(-) diff --git a/seqs/gitea.sh b/seqs/gitea.sh index 0aff5b0..e0f1b51 100755 --- a/seqs/gitea.sh +++ b/seqs/gitea.sh @@ -10,20 +10,20 @@ giteaServiceLoc="/etc/systemd/system/gitea.service" step_1_info() { echo "Updating apt"; } step_1() { - apt update + exe apt update } step_2_info() { echo "Downloading $toolName to user home: $giteaDownload"; } step_2() { - cd - wget -O gitea $giteaDownload + exe cd ~ + exe wget -O gitea $giteaDownload saveReturn $? endReturn } step_3_info() { echo "Adding user for $toolName (git:git)"; } step_3() { - adduser \ + exe adduser \ --system \ --shell /bin/bash \ --gecos 'Git Version Control' \ @@ -38,14 +38,14 @@ step_3() { step_4_info() { echo "Create required directory structure"; } step_4() { mkdir -p /var/lib/gitea/{custom,data,log} - chown -R git: /var/lib/gitea/ - chmod -R 750 /var/lib/gitea/ + exe chown -R git: /var/lib/gitea/ + exe chmod -R 750 /var/lib/gitea/ mkdir /etc/gitea - chown root:git /etc/gitea - chmod 770 /etc/gitea + exe chown root:git /etc/gitea + exe chmod 770 /etc/gitea echo "Copying gitea to global location and making it executable" - chmod +x ~/gitea - cp ~/gitea /usr/local/bin/gitea + exe chmod +x ~/gitea + exe cp ~/gitea /usr/local/bin/gitea saveReturn $? endReturn } @@ -60,8 +60,8 @@ step_5() { step_6_info() { echo -e "Starting $toolName service\n"; } step_6() { - systemctl enable gitea - systemctl start gitea + exe systemctl enable gitea + exe systemctl start gitea echo "Before proceeding to installation you may need to create a database first with step 10" echo echo "Goto http://[yourip]:3000/install and complete installation" @@ -77,17 +77,17 @@ step_10() { local mysqlPass echo "Existing mysql databases:" - mysql -u root -e 'SHOW DATABASES;' + exe mysql -u root -e 'SHOW DATABASES;' echo -en "Enter database name: " read mysqlDatabase endCheckEmpty mysqlDatabase "database name" - mysql -u root -e 'CREATE DATABASE '$mysqlDatabase' CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;' + exe mysql -u root -e 'CREATE DATABASE '$mysqlDatabase' CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;' saveReturn $? endReturn echo "Existing mysql user:" - mysql -u root -e 'SELECT User, Host FROM mysql.user;' + exe mysql -u root -e 'SELECT User, Host FROM mysql.user;' echo -en "Enter mysql user name: " read mysqlUser endCheckEmpty mysqlDatabase "user name" @@ -95,21 +95,21 @@ step_10() { echo -en "Enter mysql user password: " read mysqlPass endCheckEmpty mysqlPass "password" - mysql -u root -e 'CREATE USER '"'"$mysqlUser"'"'@'"'"'localhost'"'"' IDENTIFIED BY '"'"$mysqlPass"'"';' + exe mysql -u root -e 'CREATE USER '"'"$mysqlUser"'"'@'"'"'localhost'"'"' IDENTIFIED BY '"'"$mysqlPass"'"';' saveReturn $? endReturn - mysql -u root -e 'GRANT ALL PRIVILEGES ON '$mysqlDatabase'.* TO '"'"$mysqlUser"'"'@'"'"'localhost'"'"';' + exe mysql -u root -e 'GRANT ALL PRIVILEGES ON '$mysqlDatabase'.* TO '"'"$mysqlUser"'"'@'"'"'localhost'"'"';' saveReturn $? endReturn - mysql -u root -e 'FLUSH PRIVILEGES;' + exe mysql -u root -e 'FLUSH PRIVILEGES;' } step_20_info() { echo "Secure settings after installation"; } step_20() { - chmod 750 /etc/gitea - chmod 644 /etc/gitea/app.ini + exe chmod 750 /etc/gitea + exe chmod 644 /etc/gitea/app.ini } # Sequence Revision diff --git a/seqs/librenms.sh b/seqs/librenms.sh index 7ea4f03..b9ef16d 100755 --- a/seqs/librenms.sh +++ b/seqs/librenms.sh @@ -12,28 +12,28 @@ librePackages="fping git graphviz imagemagick mtr-tiny nmap python-memcache pyth step_1_info() { echo "Updating apt"; } step_1_alias() { ALIAS="install"; } step_1() { - apt update + exe apt update } step_2_info() { echo -e "Installing $toolname dependencies: $librePackages"; } step_2() { - apt install $librePackages + exe apt install $librePackages saveReturn $? endReturn } step_3_info() { echo -e "Installing -t buster PHP related packages:\n $librePhpDeps"; } step_3() { - apt -t buster install $librePhpDeps + exe apt -t buster install $librePhpDeps saveReturn $? endReturn } step_4_info() { echo "Adding $toolName user (librenms:librenms)"; } step_4() { - useradd librenms -d /opt/librenms -M -r + exe useradd librenms -d /opt/librenms -M -r saveReturn $? - usermod -a -G librenms www-data + exe usermod -a -G librenms www-data saveReturn $? endReturn } @@ -41,7 +41,7 @@ step_4() { step_5_info() { echo "Installing $toolName using composer"; } step_5() { cd /opt - composer create-project --no-dev --keep-vcs librenms/librenms librenms dev-master + exe composer create-project --no-dev --keep-vcs librenms/librenms librenms dev-master saveReturn $? endReturn } @@ -53,17 +53,17 @@ step_10() { local mysqlPass echo "Existing mysql databases:" - mysql -u root -e 'SHOW DATABASES;' + exe mysql -u root -e 'SHOW DATABASES;' echo -en "Enter database name: " read mysqlDatabase endCheckEmpty mysqlDatabase "database name" - mysql -u root -e 'CREATE DATABASE '$mysqlDatabase' CHARACTER SET utf8 COLLATE utf8_unicode_ci;' + exe mysql -u root -e 'CREATE DATABASE '$mysqlDatabase' CHARACTER SET utf8 COLLATE utf8_unicode_ci;' saveReturn $? endReturn echo "Existing mysql user:" - mysql -u root -e 'SELECT User, Host FROM mysql.user;' + exe mysql -u root -e 'SELECT User, Host FROM mysql.user;' echo -en "Enter mysql user name: " read mysqlUser endCheckEmpty mysqlDatabase "user name" @@ -71,15 +71,15 @@ step_10() { echo -en "Enter mysql user password: " read mysqlPass endCheckEmpty mysqlPass "password" - mysql -u root -e 'CREATE USER '"'"$mysqlUser"'"'@'"'"'localhost'"'"' IDENTIFIED BY '"'"$mysqlPass"'"';' + exe mysql -u root -e 'CREATE USER '"'"$mysqlUser"'"'@'"'"'localhost'"'"' IDENTIFIED BY '"'"$mysqlPass"'"';' saveReturn $? endReturn - mysql -u root -e 'GRANT ALL PRIVILEGES ON '$mysqlDatabase'.* TO '"'"$mysqlUser"'"'@'"'"'localhost'"'"';' + exe mysql -u root -e 'GRANT ALL PRIVILEGES ON '$mysqlDatabase'.* TO '"'"$mysqlUser"'"'@'"'"'localhost'"'"';' saveReturn $? endReturn - mysql -u root -e 'FLUSH PRIVILEGES;' + exe mysql -u root -e 'FLUSH PRIVILEGES;' } step_11_info() { echo "MariaDB configuration"; } @@ -129,9 +129,9 @@ step_40() { step_42_info() { echo "Fix librenms permission"; } step_42_alias() { ALIAS="repair"; } step_42() { - chown -R librenms:librenms /opt/librenms - setfacl -d -m g::rwx /opt/librenms/bootstrap/cache /opt/librenms/storage /opt/librenms/logs /opt/librenms/rrd - chmod -R ug=rwX /opt/librenms/bootstrap/cache /opt/librenms/storage /opt/librenms/logs /opt/librenms/rrd + exe chown -R librenms:librenms /opt/librenms + exe setfacl -d -m g::rwx /opt/librenms/bootstrap/cache /opt/librenms/storage /opt/librenms/logs /opt/librenms/rrd + exe chmod -R ug=rwX /opt/librenms/bootstrap/cache /opt/librenms/storage /opt/librenms/logs /opt/librenms/rrd } # Sequence Revision diff --git a/seqs/tvheadend.sh b/seqs/tvheadend.sh index 5458745..7c1f321 100755 --- a/seqs/tvheadend.sh +++ b/seqs/tvheadend.sh @@ -8,14 +8,14 @@ step_1() { local sourceList="/etc/apt/sources.list.d/tvheadend.list" local sourceEntry="deb https://apt.tvheadend.org/stable raspbian-stretch main" - apt update + exe apt update saveReturn $? - apt install coreutils wget apt-transport-https ca-certificates + exe apt install coreutils wget apt-transport-https ca-certificates saveReturn $? endReturn echo -n "Downloading tvheadend repository key ... " - wget -qO- https://doozer.io/keys/tvheadend/tvheadend/pgp | sudo apt-key add - + exe wget -qO- https://doozer.io/keys/tvheadend/tvheadend/pgp | sudo apt-key add - saveReturn $? endReturn @@ -24,9 +24,9 @@ step_1() { step_2_info() { echo "Install/Upate $toolName"; } step_2() { - apt update + exe apt update saveReturn $? - apt install tvheadend + exe apt install tvheadend saveReturn $? endReturn @@ -39,14 +39,14 @@ step_99() { local sourceList="/etc/apt/sources.list.d/tvheadend.list" local sourceEntry="deb https://dl.bintray.com/mpmc/deb raspbianstretch release-4.2" - apt update && apt install dirmngr - apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61 + exe apt update && apt install dirmngr + exe apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61 if [ -f "$sourceList" ] ; then echo "Skipping creating of $sourceList; Already exists" return fi echo "$sourceEntry" > "$sourceList" - apt update + exe apt update saveReturn $? endReturn } diff --git a/seqs/webserver.sh b/seqs/webserver.sh index 4c24cdf..aa79924 100755 --- a/seqs/webserver.sh +++ b/seqs/webserver.sh @@ -10,11 +10,11 @@ phpPackages="${phpName}-fpm ${phpName}-json ${phpName}-mysql ${phpName}-curl ${p step_1_info() { echo -e "Installation of $serverName and ${databaseName} packages:\n $serverPackages $databasePackages"; } step_1_alias() { ALIAS=install; } step_1() { - apt update - apt install $databasePackages + exe apt update + exe apt install $databasePackages saveReturn $? endReturn - apt install $serverPackages + exe apt install $serverPackages saveReturn $? } @@ -29,11 +29,11 @@ step_2() { # try fix errors on first install attempt # (possible missing ipv6 support on system) if [ $ERNO -ne 0 ] ; then - apt install nginx + exe apt install nginx fi # create webroot - mkdir -p "$siteLetsencryptWww" + exe mkdir -p "$siteLetsencryptWww" echo -n "Restarting Nginx ... " service nginx restart && echo "ok" @@ -57,7 +57,7 @@ siteDefaultIp4="server { step_3_info() { echo "Secure mariadb installation"; } step_3() { - mysql_secure_installation + exe mysql_secure_installation } step_4_info() { echo "Mariadb configuration"; } @@ -81,7 +81,7 @@ lower_case_table_names=0 step_5_info() { echo -e "Installation of $phpName packages:\n $phpPackages"; } step_5() { - apt install $phpPackages + exe apt install $phpPackages } phpFpmConfigLocation="/etc/php/7.0/fpm/conf.d/90-custom_pi.ini" @@ -122,30 +122,30 @@ step_10() { local mysqlPass echo "Existing mysql databases:" - mysql -u root -e 'SHOW DATABASES;' + exe mysql -u root -e 'SHOW DATABASES;' read -p "Enter database name: " mysqlDatabase endCheckEmpty mysqlDatabase "database name" - mysql -u root -e 'CREATE DATABASE '$mysqlDatabase';' + exe mysql -u root -e 'CREATE DATABASE '$mysqlDatabase';' saveReturn $? endReturn echo "Existing mysql user:" - mysql -u root -e 'SELECT User, Host FROM mysql.user;' + exe mysql -u root -e 'SELECT User, Host FROM mysql.user;' read -p "Enter mysql user name: " mysqlUser endCheckEmpty mysqlDatabase "user name" read -p "Enter mysql user password: " mysqlPass endCheckEmpty mysqlPass "password" - mysql -u root -e 'CREATE USER '"'"$mysqlUser"'"'@'"'"'localhost'"'"' IDENTIFIED BY '"'"$mysqlPass"'"';' + exe mysql -u root -e 'CREATE USER '"'"$mysqlUser"'"'@'"'"'localhost'"'"' IDENTIFIED BY '"'"$mysqlPass"'"';' saveReturn $? endReturn - mysql -u root -e 'GRANT ALL PRIVILEGES ON '$mysqlDatabase'.* TO '"'"$mysqlUser"'"'@'"'"'localhost'"'"';' + exe mysql -u root -e 'GRANT ALL PRIVILEGES ON '$mysqlDatabase'.* TO '"'"$mysqlUser"'"'@'"'"'localhost'"'"';' saveReturn $? endReturn - mysql -u root -e 'FLUSH PRIVILEGES;' + exe mysql -u root -e 'FLUSH PRIVILEGES;' } step_12_info() { echo -e "Create mysql database with characterset utf8mb4\n"; } @@ -156,30 +156,30 @@ step_12() { local mysqlPass echo "Existing mysql databases:" - mysql -u root -e 'SHOW DATABASES;' + exe mysql -u root -e 'SHOW DATABASES;' read -p "Enter database name: " mysqlDatabase endCheckEmpty mysqlDatabase "database name" - mysql -u root -e 'CREATE DATABASE '$mysqlDatabase' CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;' + exe mysql -u root -e 'CREATE DATABASE '$mysqlDatabase' CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;' saveReturn $? endReturn echo "Existing mysql user:" - mysql -u root -e 'SELECT User, Host FROM mysql.user;' + exe mysql -u root -e 'SELECT User, Host FROM mysql.user;' read -p "Enter mysql user name: " mysqlUser endCheckEmpty mysqlDatabase "user name" read -p "Enter mysql user password: " mysqlPass endCheckEmpty mysqlPass "password" - mysql -u root -e 'CREATE USER '"'"$mysqlUser"'"'@'"'"'localhost'"'"' IDENTIFIED BY '"'"$mysqlPass"'"';' + exe mysql -u root -e 'CREATE USER '"'"$mysqlUser"'"'@'"'"'localhost'"'"' IDENTIFIED BY '"'"$mysqlPass"'"';' saveReturn $? endReturn - mysql -u root -e 'GRANT ALL PRIVILEGES ON '$mysqlDatabase'.* TO '"'"$mysqlUser"'"'@'"'"'localhost'"'"';' + exe mysql -u root -e 'GRANT ALL PRIVILEGES ON '$mysqlDatabase'.* TO '"'"$mysqlUser"'"'@'"'"'localhost'"'"';' saveReturn $? endReturn - mysql -u root -e 'FLUSH PRIVILEGES;' + exe mysql -u root -e 'FLUSH PRIVILEGES;' } VERSION_SEQREV=2