From 0a7c9364427f925130b24233f608a55986a56761 Mon Sep 17 00:00:00 2001 From: neil Date: Sun, 17 Apr 2016 19:47:22 +0800 Subject: [PATCH] modify shebang to bash after install if bash is installed. --- acme.sh | 29 +++++++++++++++++++++++++++-- dnsapi/dns_cf.sh | 2 +- dnsapi/dns_cx.sh | 2 +- dnsapi/dns_dp.sh | 2 +- dnsapi/dns_myapi.sh | 2 +- 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/acme.sh b/acme.sh index 0453240..697dc23 100755 --- a/acme.sh +++ b/acme.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh VER=2.2.1 PROJECT_NAME="acme.sh" @@ -1844,6 +1844,19 @@ _precheck() { return 0 } +_setShebang() { + _file="$1" + _shebang="$2" + if [ -z "$_shebang" ] ; then + _err "Usage: file shebang" + return 1 + fi + cp "$_file" "$_file.tmp" + echo "$_shebang" > "$_file" + sed -n 2,99999p "$_file.tmp" >> "$_file" + rm -f "$_file.tmp" +} + install() { if ! _initpath ; then @@ -1937,7 +1950,19 @@ install() { fi installcronjob - + + #Modify shebang + if _exists bash ; then + _info "Good, bash is installed, change the shebang to use bash as prefered." + _shebang='#!/usr/bin/env bash' + _setShebang "$LE_WORKING_DIR/$PROJECT_ENTRY" "$_shebang" + if [ -d "$LE_WORKING_DIR/dnsapi" ] ; then + for _apifile in $(ls "$LE_WORKING_DIR/dnsapi/"*.sh) ; do + _setShebang "$_apifile" "$_shebang" + done + fi + fi + _info OK } diff --git a/dnsapi/dns_cf.sh b/dnsapi/dns_cf.sh index a6c1576..2aac340 100755 --- a/dnsapi/dns_cf.sh +++ b/dnsapi/dns_cf.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh # diff --git a/dnsapi/dns_cx.sh b/dnsapi/dns_cx.sh index 1975802..070a2ad 100644 --- a/dnsapi/dns_cx.sh +++ b/dnsapi/dns_cx.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh # Cloudxns.com Domain api # diff --git a/dnsapi/dns_dp.sh b/dnsapi/dns_dp.sh index a504379..510384a 100644 --- a/dnsapi/dns_dp.sh +++ b/dnsapi/dns_dp.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh # Dnspod.cn Domain api # diff --git a/dnsapi/dns_myapi.sh b/dnsapi/dns_myapi.sh index 3c5b865..f06cc1e 100644 --- a/dnsapi/dns_myapi.sh +++ b/dnsapi/dns_myapi.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh #Here is a sample custom api script. #This file name is "dns_myapi.sh"