code
stringlengths
2
1.05M
repo_name
stringlengths
5
110
path
stringlengths
3
922
language
stringclasses
1 value
license
stringclasses
15 values
size
int64
2
1.05M
#!/bin/sh # CYBERWATCH SAS - 2017 # # Security fix for RHSA-2012:1363 # # Security announcement date: 2012-10-12 20:19:11 UTC # Script generation date: 2017-01-16 21:15:20 UTC # # Operating System: Red Hat 5 # Architecture: x86_64 # # Vulnerable packages fix on version: # - bind-debuginfo.i386:9.3.6-20.P1.el5_8.5 # - bind-libs.i386:9.3.6-20.P1.el5_8.5 # - bind.x86_64:9.3.6-20.P1.el5_8.5 # - bind-debuginfo.x86_64:9.3.6-20.P1.el5_8.5 # - bind-libs.x86_64:9.3.6-20.P1.el5_8.5 # - bind-sdb.x86_64:9.3.6-20.P1.el5_8.5 # - bind-utils.x86_64:9.3.6-20.P1.el5_8.5 # - bind-devel.i386:9.3.6-20.P1.el5_8.5 # - bind-libbind-devel.i386:9.3.6-20.P1.el5_8.5 # - bind-chroot.x86_64:9.3.6-20.P1.el5_8.5 # - bind-devel.x86_64:9.3.6-20.P1.el5_8.5 # - bind-libbind-devel.x86_64:9.3.6-20.P1.el5_8.5 # - caching-nameserver.x86_64:9.3.6-20.P1.el5_8.5 # # Last versions recommanded by security team: # - bind-debuginfo.i386:9.3.6-25.P1.el5_11.12 # - bind-libs.i386:9.3.6-25.P1.el5_11.12 # - bind.x86_64:9.3.6-25.P1.el5_11.12 # - bind-debuginfo.x86_64:9.3.6-25.P1.el5_11.12 # - bind-libs.x86_64:9.3.6-25.P1.el5_11.12 # - bind-sdb.x86_64:9.3.6-25.P1.el5_11.12 # - bind-utils.x86_64:9.3.6-25.P1.el5_11.12 # - bind-devel.i386:9.3.6-25.P1.el5_11.12 # - bind-libbind-devel.i386:9.3.6-25.P1.el5_11.12 # - bind-chroot.x86_64:9.3.6-25.P1.el5_11.12 # - bind-devel.x86_64:9.3.6-25.P1.el5_11.12 # - bind-libbind-devel.x86_64:9.3.6-25.P1.el5_11.12 # - caching-nameserver.x86_64:9.3.6-25.P1.el5_11.12 # # CVE List: # - CVE-2012-5166 # # More details: # - https://www.cyberwatch.fr/vulnerabilites # # Licence: Released under The MIT License (MIT), See LICENSE FILE sudo yum install bind-debuginfo.i386-9.3.6 -y sudo yum install bind-libs.i386-9.3.6 -y sudo yum install bind.x86_64-9.3.6 -y sudo yum install bind-debuginfo.x86_64-9.3.6 -y sudo yum install bind-libs.x86_64-9.3.6 -y sudo yum install bind-sdb.x86_64-9.3.6 -y sudo yum install bind-utils.x86_64-9.3.6 -y sudo yum install bind-devel.i386-9.3.6 -y sudo yum install bind-libbind-devel.i386-9.3.6 -y sudo yum install bind-chroot.x86_64-9.3.6 -y sudo yum install bind-devel.x86_64-9.3.6 -y sudo yum install bind-libbind-devel.x86_64-9.3.6 -y sudo yum install caching-nameserver.x86_64-9.3.6 -y
Cyberwatch/cbw-security-fixes
Red_Hat_5/x86_64/2012/RHSA-2012:1363.sh
Shell
mit
2,290
#!/bin/bash PYTHON_PATH="/opt/python-2.7.9/bin/python" APP_SELECTOR="/home/mya/outside_dir.txt" DATE="outside_$(date +\%Y-\%m-\%d--\%H-\%M-\%S)" TARGET_DIR="/home/mya/apps/$DATE" GET_VERSION_CMD="git clone [email protected]:phelmig/outside.git ." # Create Target Directory if [ -d "$TARGET_DIR" ]; then rm -rf "$TARGET_DIR" fi mkdir -p $TARGET_DIR cd $TARGET_DIR # Get the latest Version $GET_VERSION_CMD cd mvp/ # Switch to productive settings mv "$TARGET_DIR/mvp/outside/outside/settings_prod.py" "$TARGET_DIR/mvp/outside/outside/settings.py" # install virtualenv virtualenv --python=$PYTHON_PATH . source bin/activate #Install required Software pip install -r requirements.txt # Update Static assets cd outside/ ./manage.py collectstatic #./manage.py compress echo "$TARGET_DIR/mvp" > $APP_SELECTOR
phelmig/outside_
mvp/update_outside.sh
Shell
mit
809
#!/bin/bash docker-compose stop message_on_error "Error encountered when stopping containers" echo "Docker has been stopped, sweet dreams..."
mortenson/drupal-docker-lite
scripts/stop.sh
Shell
mit
145
init_alpine() { log_header "Updating apk" apk update log_header "Installing essentials" apk_add curl apk_add jq } apk_add() { type "$1" >/dev/null || { log_header "Installing $1" apk add "$1" } }
stephencroberts/dotfiles
lib/alpine.sh
Shell
mit
220
# Checks fetches and checks out the merge commit for a Pull Request # USAGE: pr <pr number> <branch name> <remote> pr() { REMOTE="${3:-origin}" BRANCH="${2:-$1}" git fetch "$REMOTE" pull/"$1"/head:"$BRANCH" git checkout "$BRANCH" }
brentleyjones/dotfiles
git/pr.zsh
Shell
mit
248
#!/bin/bash set -o posix ############################################################################## # These are needed for the C++ Project Template sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test # g++-4.9 sudo add-apt-repository --yes ppa:kubuntu-ppa/backports # cmake over 2.8.7 ############################################################################## ############################################################################## # Add your projects necessary "before_install" commands here sudo apt-add-repository --yes ppa:zoogie/sdl2-snapshots # sdl2 sudo apt-add-repository --yes ppa:libreoffice/libreoffice-4-2 # doxygen 1.8 curl -R -O http://www.lua.org/ftp/lua-5.2.3.tar.gz tar zxf lua-5.2.3.tar.gz cd lua-5.2.3 make linux test sudo make install ############################################################################## ############################################################################## # This is needed for the C++ Project Template sudo apt-get update -qq ##############################################################################
CaioIcy/Dauphine
utils/travis/before_install.sh
Shell
mit
1,092
#!/bin/bash echo Starting Gunicorn. exec gunicorn sci_organizer.wsgi:application \ --bind 0.0.0.0:$PORT \ --workers 3
MilyMilo/sci-organizer
start.sh
Shell
mit
127
for n in 3000 2034 2003 999 353 287 252 203 65 30 do python src/MRDS/find_lc_spearman_significance.py $n done matlab -nojvm -r "addpath('src/MRDS'); find_prob_of_difference_of_two_beta_dist"
se4u/mvlsa
mrds.sh
Shell
mit
196
#!/usr/bin/env bash # Stop script on NZEC set -e # Stop script if unbound variable found (use ${var:-} if intentional) set -u # By default cmd1 | cmd2 returns exit code of cmd2 regardless of cmd1 success # This is causing it to fail set -o pipefail __PROJECT_DIR=${1:-} __DOTNET_CMD=${2:-} __TOOLRUNTIME_DIR=${3:-} __PACKAGES_DIR=${4:-$__TOOLRUNTIME_DIR} __TOOLS_DIR=$(cd "$(dirname "$0")"; pwd -P) __MICROBUILD_VERSION=0.2.0 __PORTABLETARGETS_VERSION=0.1.1-dev __PORTABLETARGETS_PROJECT_CONTENT=" <Project Sdk=\"Microsoft.NET.Sdk\"> <PropertyGroup> <TargetFrameworks>netcoreapp1.0;net46</TargetFrameworks> <DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences> </PropertyGroup> <ItemGroup> <PackageReference Include=\"MicroBuild.Core\" Version=\"$__MICROBUILD_VERSION\" /> <PackageReference Include=\"Microsoft.Portable.Targets\" Version=\"$__PORTABLETARGETS_VERSION\" /> </ItemGroup> </Project>" __PUBLISH_TFM=netcoreapp2.0 __INIT_TOOLS_RESTORE_ARGS="--source https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json --source https://api.nuget.org/v3/index.json ${__INIT_TOOLS_RESTORE_ARGS:-}" __TOOLRUNTIME_RESTORE_ARGS="--source https://dotnet.myget.org/F/dotnet-core/api/v3/index.json ${__INIT_TOOLS_RESTORE_ARGS}" if [ ! -d "$__PROJECT_DIR" ]; then echo "ERROR: Cannot find project root path at '$__PROJECT_DIR'. Please pass in the source directory as the 1st parameter." exit 1 fi if [ ! -e "$__DOTNET_CMD" ]; then echo "ERROR: Cannot find dotnet.exe at path '$__DOTNET_CMD'. Please pass in the path to dotnet.exe as the 2nd parameter." exit 1 fi if [ -z "$__TOOLRUNTIME_DIR" ]; then echo "ERROR: Please pass in the tools directory as the 3rd parameter." exit 1 fi if [ ! -d "$__TOOLRUNTIME_DIR" ]; then mkdir $__TOOLRUNTIME_DIR fi cp -R $__TOOLS_DIR/* $__TOOLRUNTIME_DIR __TOOLRUNTIME_PROJECT=$__TOOLS_DIR/tool-runtime/project.csproj echo "Running: $__DOTNET_CMD restore \"${__TOOLRUNTIME_PROJECT}\" $__TOOLRUNTIME_RESTORE_ARGS" $__DOTNET_CMD restore "${__TOOLRUNTIME_PROJECT}" $__TOOLRUNTIME_RESTORE_ARGS echo "Running: $__DOTNET_CMD publish \"${__TOOLRUNTIME_PROJECT}\" -f ${__PUBLISH_TFM} -o $__TOOLRUNTIME_DIR" $__DOTNET_CMD publish "${__TOOLRUNTIME_PROJECT}" -f ${__PUBLISH_TFM} -o $__TOOLRUNTIME_DIR # Copy Portable Targets Over to ToolRuntime if [ ! -d "${__PACKAGES_DIR}/generated" ]; then mkdir "${__PACKAGES_DIR}/generated"; fi __PORTABLETARGETS_PROJECT=${__PACKAGES_DIR}/generated/project.csproj echo $__PORTABLETARGETS_PROJECT_CONTENT > "${__PORTABLETARGETS_PROJECT}" echo "Running: \"$__DOTNET_CMD\" restore \"${__PORTABLETARGETS_PROJECT}\" $__INIT_TOOLS_RESTORE_ARGS --packages \"${__PACKAGES_DIR}/.\"" $__DOTNET_CMD restore "${__PORTABLETARGETS_PROJECT}" $__INIT_TOOLS_RESTORE_ARGS --packages "${__PACKAGES_DIR}/." # Copy portable and MicroBuild targets from packages, allowing for lowercased package IDs. cp -R "${__PACKAGES_DIR}"/[Mm]icrosoft.[Pp]ortable.[Tt]argets/"${__PORTABLETARGETS_VERSION}/contentFiles/any/any/Extensions/." "$__TOOLRUNTIME_DIR/." cp -R "${__PACKAGES_DIR}"/[Mm]icro[Bb]uild.[Cc]ore/"${__MICROBUILD_VERSION}/build/." "$__TOOLRUNTIME_DIR/." # Temporary Hacks to fix couple of issues in the msbuild and roslyn nuget packages # https://github.com/dotnet/buildtools/issues/1464 [ -e "$__TOOLRUNTIME_DIR/Microsoft.CSharp.Targets" ] || mv "$__TOOLRUNTIME_DIR/Microsoft.CSharp.targets" "$__TOOLRUNTIME_DIR/Microsoft.CSharp.Targets" # Copy some roslyn files over cp $__TOOLRUNTIME_DIR/runtimes/any/native/* $__TOOLRUNTIME_DIR/ #Temporarily rename roslyn compilers to have exe extension cp ${__TOOLRUNTIME_DIR}/csc.dll ${__TOOLRUNTIME_DIR}/csc.exe cp ${__TOOLRUNTIME_DIR}/vbc.dll ${__TOOLRUNTIME_DIR}/vbc.exe #Copy RID specific assets to the tools dir since we don't have a deps.json for .NETCore msbuild cp ${__TOOLRUNTIME_DIR}/runtimes/unix/lib/netstandard1.3/*.dll $__TOOLRUNTIME_DIR/ # Override versions in runtimeconfig.json files with highest available runtime version. __MNCA_FOLDER=$(dirname $__DOTNET_CMD)/shared/Microsoft.NETCore.App __HIGHEST_RUNTIME_VERSION=`ls $__MNCA_FOLDER | sed 'r/\([0-9]\+\).*/\1/g' | sort -n | tail -1` sed -i -e "s/1.1.0/$__HIGHEST_RUNTIME_VERSION/g" $__TOOLRUNTIME_DIR/*.runtimeconfig.json # Restore ILAsm, if requested in the environment. __ILASM_PACKAGE_VERSION="${ILASMCOMPILER_VERSION:-}" if [ "$__ILASM_PACKAGE_VERSION" ]; then echo "Restoring ILAsm version '$__ILASM_PACKAGE_VERSION'..." __ILASM_PACKAGE_RID="${NATIVE_TOOLS_RID:-}" if [ "$__ILASM_PACKAGE_RID" == "" ]; then echo "ERROR: Please specify native package RID." exit 1 fi echo "Running: \"$__DOTNET_CMD\" build \"${__TOOLRUNTIME_DIR}/ilasm/ilasm.depproj\"" $__DOTNET_CMD build "${__TOOLRUNTIME_DIR}/ilasm/ilasm.depproj" --packages "${__PACKAGES_DIR}/." --source https://dotnet.myget.org/F/dotnet-core/api/v3/index.json -r $__ILASM_PACKAGE_RID -p:ILAsmPackageVersion=$__ILASM_PACKAGE_VERSION fi # Download the package version props file, if passed in the environment. __PACKAGE_VERSION_PROPS_URL="${PACKAGEVERSIONPROPSURL:-}" __PACKAGE_VERSION_PROPS_PATH="$__TOOLRUNTIME_DIR/DownloadedPackageVersions.props" if [ "$__PACKAGE_VERSION_PROPS_URL" ]; then echo "Downloading package version props from '$__PACKAGE_VERSION_PROPS_URL' to '$__PACKAGE_VERSION_PROPS_PATH'..." # Copied from CoreFX init-tools.sh if command -v curl > /dev/null; then curl --retry 10 -sSL --create-dirs -o "$__PACKAGE_VERSION_PROPS_PATH" "$__PACKAGE_VERSION_PROPS_URL" else wget -q -O "$__PACKAGE_VERSION_PROPS_PATH" "$__PACKAGE_VERSION_PROPS_URL" fi echo "Downloaded package version props:" cat "$__PACKAGE_VERSION_PROPS_PATH" fi exit 0
chcosta/buildtools
src/Microsoft.DotNet.Build.Tasks/PackageFiles/init-tools.sh
Shell
mit
5,746
$PYTHON setup.py install --single-version-externally-managed --record=record.txt # Python
VlachosGroup/VlachosGroupAdditivity
conda-pieces/build.sh
Shell
mit
91
#!/bin/bash # Note: this function is meant to run WITHIN the docker container function error { echo $1 && exit 0 } nc -zw2 mongo 27017 || error "Mongo database not available, exiting..." nc -zw2 statserver $ENRICHMENT_PORT || error "Statistics server not available, exiting..." # prepare /etc/nginx/conf.d/magi-site.conf TRIM_NAME=${SITE_URL%:*} # trim port name TRIM_NAME=${TRIM_NAME#*://} # trim protocol name # bash hackery sed -i -e "s%\$SERVER_NAME_TO_REPLACE%${TRIM_NAME}%;s/\$PORT_TO_REPLACE/${PORT}/" /etc/nginx/conf.d/magi-site.conf sudo /etc/init.d/nginx start echo "Starting server with forever" LOGFILE="server.log" forever start -c "node --harmony" -l $LOGFILE ~/magi/server.js echo "Writing server output to ~/.forever/$LOGFILE" bash
raphael-group/magi-images
run-server.sh
Shell
mit
763
function autoscreen() { autossh -x -a -t "$@" "screen -x" }
doismellburning/dotfiles
screen/autoscreen.bash
Shell
mit
61
#!/bin/bash #This script will help you configuring a new storage and a network share #Remember to chmod+x on this file to make it executable # Configuring Transmission printf "Where do you want to store your downloads?\n" cd /mnt && ls -l read -p "Please select your drive from the list above: " drive printf "Setting ${drive} as working directory\n" cd ${drive} # Installing Transmission printf "Installing Transmission...\n" sudo apt-get install transmission-daemon -y # Stopping transmission-daemon printf "Stopping Transmission daemon to continue with configuration...\n" sudo /etc/init.d/transmission-daemon stop # Backup actual configuration printf "Performing backup of actual transmission configuration...\n" if sudo cp /etc/transmission-daemon/settings.json /etc/transmission-daemon/settings.json.original then printf "Backup performed successfully\n" else printf "Failure, exit status $?\n" fi # Getting configuration parameters from user's input # Download directory read -p "Would you like to create a download folder[Y] or using an existing one[N]? [Y/n] " answer case ${answer} in [yY]|[yY]) read -p "Please, name the folder: " download_dir; mkdir ${download_dir}; printf "Downloads will be stored in ${drive}/${download_dir}\n" ;; [nN]|[nN]) ls -l; read -p "Where do you want to store your downloads? Please type its name from list above: " download_dir ;; esac # Incomplete download directory read -p "Would you like to create an incomplete downloads folder [Y] or using an existing one[N]? [Y/n] " answer case ${answer} in [yY]|[yY]) read -p "Please, name the folder: " incomplete_dir; mkdir ${incomplete_dir}; printf "Incomplete downloads will be stored in ${drive}/${incomplete_dir}\n" ;; [nN]|[nN]) ls -l; read -p "Where do you want to store your incomplete downloads? Please type its name from list above: " incomplete_dir ;; esac # Other parameters read -p "What's user you want to use for login? " rpc_username printf "Type the password for ${rpc_username}: " && read -s rpc_password; printf "\n" read -p "Select your rpc-whitelist range (for example, 192.168.1.*): " rpc_whitelist # Creating new configuration strings config_download_dir="\"download-dir\": \"${download_dir}\"," config_incomplete_dir="\"incomplete-dir\": \"${incomplete_dir}\"," config_rpc_password="\"rpc-password\": \"${rpc_password}\"," config_rpc_username="\"rpc-username\": \"${rpc_username}\"," config_rpc_whitelist="\"rpc-whitelist\": \"${rpc_whitelist}\"," # Write changes to transmission config file transmission_config_file="/etc/transmission-daemon/settings.json" sudo sed -i '/'\"download-dir\":'/'c'\'"${config_download_dir}" "$transmission_config_file" sudo sed -i '/'\"incomplete-dir\":'/'c'\'"${config_incomplete_dir}" "$transmission_config_file" sudo sed -i '/'\"rpc-password\":'/'c'\'"${config_rpc_password}" "$transmission_config_file" sudo sed -i '/'\"rpc-username\":'/'c'\'"${config_rpc_username}" "$transmission_config_file" sudo sed -i '/'\"rpc-whitelist\":'/'c'\'"${config_rpc_whitelist}" "$transmission_config_file" # Restarting daemon printf "Restarting Transmission...\n" sudo /etc/init.d/transmission-daemon start # Final message printf "Done! Enjoy your piT-box!\n"
mattups/piTorrent-box
piT-box-transmission.sh
Shell
mit
3,319
#!/usr/bin/env bash set -e if (( "$#" != 1 )) then echo "Tag has to be provided" exit 1 fi CURRENT_BRANCH="master" VERSION=$1 # Always prepend with "v" if [[ $VERSION != v* ]] then VERSION="v$VERSION" fi for REMOTE in auth broadcasting bus cache config console container contracts cookie database encryption events filesystem hashing http log mail notifications pagination pipeline queue redis routing session support translation validation view do echo "" echo "" echo "Releasing $REMOTE"; TMP_DIR="/tmp/laravel-split" REMOTE_URL="[email protected]:illuminate/$REMOTE.git" rm -rf $TMP_DIR; mkdir $TMP_DIR; ( cd $TMP_DIR; git clone $REMOTE_URL . git checkout "$CURRENT_BRANCH"; git tag $VERSION git push origin --tags ) done
stidges/framework
bin/release.sh
Shell
mit
822
#!/bin/bash client=$1 # read the value the before script generated starttime=`cat /tmp/$client.timemetric` endtime=`date +%s` timetaken=$(($endtime - $starttime)) # stolen function to convert seconds to friendly notation - credit http://stackoverflow.com/a/12199816 choroba function show_time () { num=$1 min=0 hour=0 day=0 if((num>59));then ((sec=num%60)) ((num=num/60)) if((num>59));then ((min=num%60)) ((num=num/60)) if((num>23));then ((hour=num%24)) ((day=num/24)) else ((hour=num)) fi else ((min=num)) fi else ((sec=num)) fi ttaken=""$hour"h "$min"m "$sec"s" } show_time $timetaken ## Do something with ttaken value. I add it to a database.
waqark3389/baculastuff
afterjob.sh
Shell
mit
855
#!/bin/bash -e { # this ensures the entire script is downloaded # # Stops the execution of a script if a command or pipeline has an error set -e echo "Downloading latest version from github dev" #download latest wget https://github.com/MKHenson/noxy/archive/dev.zip unzip -o "dev.zip" "noxy-dev/*" # Moves the server folder to the current directory cp -r noxy-dev/server/* . # Remove noxy temp folder if [ -d "noxy-dev" ]; then rm noxy-dev -R fi # Remove the zip file rm "dev.zip" # Copy the example config to a config.json as long as config.json does not exist if [ ! -f "config.json" ]; then cp "example-config.json" "config.json" fi # All done echo "Noxy successfully installed" echo "Please run an NPM update and edit the config.json" exit } # this ensures the entire script is downloaded #
MKHenson/noxy
install-script-dev.sh
Shell
mit
807
#!/bin/sh # add heroku repository to apt echo "deb http://toolbelt.heroku.com/ubuntu ./" > /etc/apt/sources.list.d/heroku.list # install heroku's release key for package verification wget -O- https://toolbelt.heroku.com/apt/release.key | apt-key add - # update your sources apt-get update # install the toolbelt apt-get install -y heroku-toolbelt
treeder/dockers
heroku/install-ubuntu.sh
Shell
mit
351
#!/bin/sh lua node_tests.lua && \ lua agenda_tests.lua && \ lua path_finder_tests.lua
phtrivier/ube
src/engine/lua/tests/all_tests.sh
Shell
mit
85
#!/usr/bin/bash # Runs slice tree (several versions) for the synthetic graphs # @Arlei Silva source default.sh for((g=1; g<=$num_graphs; g++)) do prefix=$graph_name_prefix\_$g postfix=$g echo "$graph_compression -g $prefix.graph -v $prefix.data -o output -c ST -p $num_partitions_alg -s $prefix.sizes -m $max_radius -x > out_st_$postfix.txt" $graph_compression -g $prefix.graph -v $prefix.data -o output -c ST -p $num_partitions_alg -s $prefix.sizes -m $max_radius -x > out_st_$postfix.txt for p in ${param_delta[@]} do for((r=1; r<=$num_runs_sampling; r++)) do postfix_samp=$postfix\_$p\_$r echo "$graph_compression -g $prefix.graph -v $prefix.data -o output -c STBS -p $num_partitions_alg -s $prefix.sizes -m $max_radius -n $rate_fast_sampling -d $p -r $rho_fast_sampling -x > out_stbs_fast_$postfix_samp.txt" $graph_compression -g $prefix.graph -v $prefix.data -o output -c STBS -p $num_partitions_alg -s $prefix.sizes -m $max_radius -n $rate_fast_sampling -d $p -r $rho_fast_sampling -x > out_stbs_fast_$postfix_samp.txt echo "$graph_compression -g $prefix.graph -v $prefix.data -o output -c STBS -p $num_partitions_alg -s $prefix.sizes -m $max_radius -n $rate_slow_sampling -d $p -r $rho_slow_sampling -x > out_stbs_slow_$postfix_samp.txt" $graph_compression -g $prefix.graph -v $prefix.data -o output -c STBS -p $num_partitions_alg -s $prefix.sizes -m $max_radius -n $rate_slow_sampling -d $p -r $rho_slow_sampling -x > out_stbs_slow_$postfix_samp.txt echo "$graph_compression -g $prefix.graph -v $prefix.data -o output -c STUS -p $num_partitions_alg -s $prefix.sizes -m $max_radius -n $rate_slow_sampling -d $p -r $rho_slow_sampling -x > out_stus_slow_$postfix_samp.txt" $graph_compression -g $prefix.graph -v $prefix.data -o output -c STUS -p $num_partitions_alg -s $prefix.sizes -m $max_radius -n $rate_slow_sampling -d $p -r $rho_slow_sampling -x > out_stus_slow_$postfix_samp.txt done done done
ucsb-igert/slice-tree
experiments/sampling/delta/run_compression.sh
Shell
mit
2,012
#!/bin/sh set -eo pipefail -o nounset genome=https://raw.githubusercontent.com/gogetdata/ggd-recipes/master/genomes/Homo_sapiens/GRCh37/GRCh37.genome ## Get the vcf file, filter it, and create compress to bcf wget --quiet -O - https://storage.googleapis.com/gnomad-public/release/2.1.1/vcf/exomes/gnomad.exomes.r2.1.1.sites.vcf.bgz \ | bcftools view --no-version --threads 3 -O v \ | gsort /dev/stdin $genome \ | bcftools view -O b --no-version --threads 3 -o grch37-exome-variants-gnomad-v1.bcf bcftools index --threads 3 --csi grch37-exome-variants-gnomad-v1.bcf
gogetdata/ggd-recipes
recipes/genomics/Homo_sapiens/GRCh37/grch37-exome-variants-gnomad-v1/recipe.sh
Shell
mit
584
#!/usr/bin/env bash coinbase=$(geth --datadir . --chain=cryptodev --rpc --rpcaddr 0.0.0.0 --exec eth.coinbase console) echo "Coinbase: $coinbase" sed -i s/\"ADDRESS\"/$coinbase/g genesis_alloc.json echo "Coinbase written in genesis.json file."
heraware/cryptodev
dockerfiles/ethereum-classic/set_genesis.sh
Shell
mit
246
#!/bin/sh chown -R apache:apache ${RAINLOOP_HOME} sh -c "find . -type d -exec chmod 755 {} \;" sh -c "find . -type f -exec chmod 644 {} \;" exec /usr/sbin/httpd -D FOREGROUND
SolidNerd/docker-rainloop
docker-entrypoint.sh
Shell
mit
178
#!/bin/bash # # Some integration test in development mode. # It tests that headers can be dumped in JSON. It happens when a request headers validation error is caught. set -o errexit set -o nounset export LC_ALL=C : ${RAILS_ROOT:=.} : ${PORT:=3000} ( cd "$RAILS_ROOT/test/dummy" rails server --daemon --port=$PORT 2>&1 >/dev/null sleep 2 ) result=$(curl \ -v \ -H "X-Test-Header: wrong" \ "http://localhost:$PORT/caught_exception/headers_check.json" 2>&1) kill -9 $(cat "$RAILS_ROOT/test/dummy/tmp/pids/server.pid") if grep -q '^< HTTP/1.1 500 Internal Server Error' <<< "$result" && grep -q '^< Content-Type: application/json' <<< "$result" then exit 0 else echo "$result" exit 1 fi
nicolasdespres/respect-rails
test/headers_can_dumped_in_json.sh
Shell
mit
709
#!/bin/bash # # Michael Mottola # <[email protected]> # December 18, 2011 # # Creates backup files (bson) of all MongoDb databases on a given server. # Default behaviour dumps the mongo database and tars the output into a file # named after the current date. ex: 2011-12-19.tar.gz # ### Set server settings HOST="localhost" PORT="27017" # default mongoDb port is 27017 USERNAME="" PASSWORD="" # Set where database backups will be stored # keyword DATE gets replaced by the current date, you can use it in either path below BACKUP_PATH="/backups" # do not include trailing slash FILE_NAME="DATE" #defaults to [currentdate].tar.gz ex: 2011-12-19.tar.gz HOLD_COUNT="7" ################################################################################## # Should not have to edit below this line unless you require special functionality # or wish to make improvements to the script ################################################################################## # Auto detect unix bin paths, enter these manually if script fails to auto detect MONGO_DUMP_BIN_PATH="$(which mongodump)" TAR_BIN_PATH="$(which tar)" # Get todays date to use in filename of backup output TODAYS_DATE=`date +"%d-%m-%y"` # replace DATE with todays date in the backup path BACKUP_PATH="${BACKUP_PATH//DATE/$TODAYS_DATE}" # Create BACKUP_PATH directory if it does not exist [ ! -d $BACKUP_PATH ] && mkdir -p $BACKUP_PATH || : # Ensure directory exists before dumping to it if [ -d "$BACKUP_PATH" ]; then cd $BACKUP_PATH # initialize temp backup directory TMP_BACKUP_DIR="mongodb-$TODAYS_DATE" echo; echo "=> Backing up Mongo Server: $HOST:$PORT"; echo -n ' '; # run dump on mongoDB if [ "$USERNAME" != "" -a "$PASSWORD" != "" ]; then $MONGO_DUMP_BIN_PATH --host $HOST:$PORT -u $USERNAME -p $PASSWORD --out $TMP_BACKUP_DIR >> /dev/null else $MONGO_DUMP_BIN_PATH --host $HOST:$PORT --out $TMP_BACKUP_DIR >> /dev/null fi # check to see if mongoDb was dumped correctly if [ -d "$TMP_BACKUP_DIR" ]; then # if file name is set to nothing then make it todays date if [ "$FILE_NAME" == "" ]; then FILE_NAME="$TODAYS_DATE" fi # replace DATE with todays date in the filename FILE_NAME="${FILE_NAME//DATE/$TODAYS_DATE}" # turn dumped files into a single tar file $TAR_BIN_PATH --remove-files -czf $FILE_NAME.tar.gz $TMP_BACKUP_DIR >> /dev/null # verify that the file was created if [ -f "$FILE_NAME.tar.gz" ]; then echo "=> Success: `du -sh $FILE_NAME.tar.gz`"; echo; # forcely remove if files still exist and tar was made successfully # this is done because the --remove-files flag on tar does not always work if [ -d "$BACKUP_PATH/$TMP_BACKUP_DIR" ]; then rm -rf "$BACKUP_PATH/$TMP_BACKUP_DIR" fi else echo "!!!=> Failed to create backup file: $BACKUP_PATH/$FILE_NAME.tar.gz"; echo; fi else echo; echo "!!!=> Failed to backup mongoDB"; echo; fi # remove old files CURRENT="$(ls *.tar.gz | wc -l)" if [ "$CURRENT" -gt "$HOLD_COUNT" ]; then ls -t *.tar.gz | tail -`expr $CURRENT - $HOLD_COUNT` | xargs rm fi else echo "!!!=> Failed to create backup path: $BACKUP_PATH" fi
insspb/Bash
backup_scripts/MongoDB/mongodb-backup.sh
Shell
mit
3,138
#!/bin/sh # CYBERWATCH SAS - 2017 # # Security fix for USN-1629-1 # # Security announcement date: 2012-11-12 00:00:00 UTC # Script generation date: 2017-01-01 21:03:02 UTC # # Operating System: Ubuntu 12.04 LTS # Architecture: i386 # # Vulnerable packages fix on version: # - libproxy1:0.4.7-0ubuntu4.1 # # Last versions recommanded by security team: # - libproxy1:0.4.7-0ubuntu4.1 # # CVE List: # - CVE-2012-4504 # - CVE-2012-4505 # # More details: # - https://www.cyberwatch.fr/vulnerabilites # # Licence: Released under The MIT License (MIT), See LICENSE FILE sudo apt-get install --only-upgrade libproxy1=0.4.7-0ubuntu4.1 -y
Cyberwatch/cbw-security-fixes
Ubuntu_12.04_LTS/i386/2012/USN-1629-1.sh
Shell
mit
643
#!/bin/sh # # Homebrew # # This installs some of the common dependencies needed (or at least desired) # using Homebrew. # Check for Homebrew if test ! $(which brew) then echo " Installing Homebrew for you." ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" > /tmp/homebrew-install.log fi # Install homebrew packages brew install grc coreutils spark zsh-syntax-highlighting node z zsh-history-substring-search exit 0
ksoldau/dotfiles
homebrew/install.sh
Shell
mit
464
#!/bin/bash set -e LOGFILE=/var/www/texapi/logs/guni.log LOGDIR=$(dirname $LOGFILE) NUM_WORKERS=3 ADDRESS=127.0.0.1:8011 cd /home/texapi/ source ./vars.sh cd /var/www/texapi/root/ source /var/www/texapi/root/venv/bin/activate test -d $LOGDIR || mkdir -p $LOGDIR exec gunicorn texapi.wsgi:application -w $NUM_WORKERS --bind=$ADDRESS \ --log-level=debug \ --pythonpath=/var/www/texapi/root/ --log-file=$LOGFILE 2>>$LOGFILE
blumug/texapi
gunicorn_prod.sh
Shell
mit
426
#!/usr/bin/env sh echo "Finder: show all filename extensions" defaults write NSGlobalDomain AppleShowAllExtensions -bool true echo "show hidden files by default" defaults write com.apple.Finder AppleShowAllFiles -bool false echo "expand save dialog by default" defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true echo "show the ~/Library folder in Finder" chflags nohidden ~/Library echo "Automatically hide and show the Dock" defaults write com.apple.dock autohide -bool true echo "Always show scrollbars" defaults write NSGlobalDomain AppleShowScrollBars -string "Auto" echo "Show Path bar in Finder" defaults write com.apple.finder ShowPathbar -bool true echo "Show Status bar in Finder" defaults write com.apple.finder ShowStatusBar -bool true echo "Avoid creating .DS_Store files on network volumes" defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true # Empty Trash securely by default defaults write com.apple.finder EmptyTrashSecurely -bool true echo "Require password immediately after sleep or screen saver begins" defaults write com.apple.screensaver askForPassword -int 1 defaults write com.apple.screensaver askForPasswordDelay -int 0 echo "Disable tap to click (Trackpad)" defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool False echo "Kill affected applications" for app in Safari Finder Dock Mail SystemUIServer; do killall "$app" >/dev/null 2>&1; done
gblock0/dotfiles
install/osx.sh
Shell
mit
1,460
#! /bin/bash -l #{ export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin" CaminhoUser="ENERGY_7_2/BIONDO" MailUser="[email protected]" caminho="/home/cte/SIMULA/$CaminhoUser" echo "Pasta raiz de execução: $caminho" cd $caminho/ENTRADA horasim=$(date) echo "$horasim" sleep 1 ls *.idf > arquivos_idf datasim=$(date +%y%m%d%H%M) fileaq="$caminho/ENTRADA/arquivos_idf" if [ -s $fileaq ] then mkdir $caminho/ENTRADA/resultado_$datasim else echo " !! Não foram encontrados arquivos IDF para simular " exit 1 fi; echo "data $datasim" num=0 chmod 777 *.idf for file in `cat arquivos_idf`;do mkdir $caminho/ENTRADA//resultado_$datasim/$datasim-$num-${file%%.*}; mv $caminho/ENTRADA/$file $caminho/ENTRADA//resultado_$datasim/$datasim-$num-${file%%.*} ; echo "A simular $file, resultado em $caminho/RESULTADOS/resultado_$datasim/$datasim-$num-${file%%.*}"; ((num++)); done echo "sh $caminho/ENTRADA/repw_processos.sh /usr/local/EnergyPlus-7-2-0/bin/runenergyplus" > arquivos_idf sort $caminho/ENTRADA/arquivo_clima.txt >> $caminho/ENTRADA/arquivos_idf find $caminho/ENTRADA/resultado_$datasim/ -name *.idf > $caminho/ENTRADA/idf_plano sort $caminho/ENTRADA/idf_plano >> $caminho/ENTRADA/arquivos_idf tr '\n' ' ' < $caminho/ENTRADA/arquivos_idf > $caminho/ENTRADA/idf_plano sh $caminho/ENTRADA/idf_plano cp $caminho/ENTRADA/arquivo_clima.txt $caminho/ENTRADA/resultado_$datasim/ cp $caminho/ENTRADA/idf_plano $caminho/ENTRADA/resultado_$datasim/simulacao_$datasim.txt tar -cvf $datasim.tar resultado_$datasim/ gzip $datasim.tar mv $datasim.tar.gz $caminho/ZRESULTADOS_BACKUP/ mv ./resultado_$datasim/ $caminho/RESULTADOS/resultado_${file%%.*}_$datasim SUBJECT="Simulacao $datasim $file" datasim=$(date) # Email To ? EMAIL="$MailUser" # Email text/message EMAILMESSAGE="$caminho/ENTRADA/emailmessage.txt" echo "Simulacao Concluida"> $EMAILMESSAGE echo "A simulacao com EnergyPlus 7.2 $file, iniciada em $horasim foi concluida em $datasim. Os resultados estao na pasta \\10.0.2.242\SIMULA\$CaminhoUser\RESULTADOS">>$EMAILMESSAGE # send an email using /usr/bin/mailx /bin/mail -s "$SUBJECT" -S smtp-use-starttls -S ssl-verify=ignore -S smtp=smtp://smtp.gmail.com:587 -S smtp-auth=login -S [email protected] -S smtp-auth-password=inteligencia360 -S from=cte "$EMAIL" < $EMAILMESSAGE cd $caminho/RESULTADOS chmod -R 777 * exit 0 #} > $caminho/saidas_modelos
leandromet/EnergyPlus
simula_energy_multi.sh
Shell
mit
2,404
#! /usr/bin/env nix-shell #! nix-shell -i bash -p nix curl jq nix-prefetch-github git gnused gnugrep -I nixpkgs=. set -eu -o pipefail tmpfile=$(mktemp "update-stackage.XXXXXXX") # shellcheck disable=SC2064 stackage_config="pkgs/development/haskell-modules/configuration-hackage2nix/stackage.yaml" trap "rm ${tmpfile} ${tmpfile}.new" 0 touch "$tmpfile" "$tmpfile.new" # Creating files here so that trap creates no errors. curl -L -s "https://stackage.org/lts/cabal.config" >"$tmpfile" old_version=$(grep "# Stackage" $stackage_config | sed -E 's/.*([0-9]{2}\.[0-9]+)/\1/') version=$(sed -rn "s/^--.*http:..(www.)?stackage.org.snapshot.lts-//p" "$tmpfile") if [[ "$old_version" == "$version" ]]; then echo "No new stackage version" exit 0 # Nothing to do fi echo "Updating Stackage LTS from $old_version to $version." # Create a simple yaml version of the file. sed -r \ -e '/^--/d' \ -e 's|^constraints:||' \ -e 's|^ +| - |' \ -e 's|,$||' \ -e '/installed$/d' \ -e '/^$/d' \ < "${tmpfile}" | sort --ignore-case >"${tmpfile}.new" cat > $stackage_config << EOF # Stackage LTS $version # This file is auto-generated by # maintainers/scripts/haskell/update-stackage.sh default-package-overrides: EOF # Drop restrictions on some tools where we always want the latest version. sed -r \ -e '/ cabal2nix /d' \ -e '/ distribution-nixpkgs /d' \ -e '/ jailbreak-cabal /d' \ -e '/ language-nix /d' \ < "${tmpfile}.new" >> $stackage_config if [[ "${1:-}" == "--do-commit" ]]; then git add $stackage_config git commit -F - << EOF haskellPackages: stackage-lts $old_version -> $version This commit has been generated by maintainers/scripts/haskell/update-stackage.sh EOF fi
NixOS/nixpkgs
maintainers/scripts/haskell/update-stackage.sh
Shell
mit
1,725
#!/bin/bash #SBATCH --partition=mono #SBATCH --ntasks=1 #SBATCH --time=4-0:00 #SBATCH --mem-per-cpu=8000 #SBATCH -J Deep-DAE_MLP_7_bot_real_RICA_tanh #SBATCH -e Deep-DAE_MLP_7_bot_real_RICA_tanh.err.txt #SBATCH -o Deep-DAE_MLP_7_bot_real_RICA_tanh.out.txt source /etc/profile.modules module load gcc module load matlab cd ~/deepLearn && srun ./deepFunction 7 'DAE' 'MLP' '128 500 1500 1000 2000 250 10' '0 0 0 0 0 0 0' '7_bot_real' 'RICA_tanh' "'iteration.n_epochs', 'learning.lrate', 'use_tanh', 'noise.drop', 'noise.level', 'rica.cost', 'cae.cost'" '200 1e-3 1 0 0 0.1 0' "'iteration.n_epochs', 'use_tanh'" '200 1'
aciditeam/matlab-ts
jobs/deepJobs_DAE_MLP_7_bot_real_RICA_tanh.sh
Shell
mit
635
#!/bin/bash # # This will be the script called by websocketd when # mapping Cisco ASA firewall connections. # In the ASA config use command: logging host inside 10.1.2.3 udp/51414 # Replace 10.1.2.3 with your workstation IP address. # nc -ul 51414
pla1/mapconnections
ciscoasasyslog.sh
Shell
mit
249
#!/bin/bash yum install -y ntp systemctl enable ntpd systemctl start ntpd
heisedebaise/docker
k8s/config.sh
Shell
mit
75
#!/bin/bash bin_dir=$(dirname $0) project_dir=$(cd $bin_dir/..; pwd) source $project_dir/config.sh rm -fR ${build_dir}
julsburgs/DAT
practica2/bin/clean.sh
Shell
mit
123
#!/bin/bash # See also: https://unix.stackexchange.com/questions/27054/bin-bash-no-such-file-or-directory # Install .NET 5.0 https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#1804- wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb sudo apt-get update; \ sudo apt-get install -y apt-transport-https && \ sudo apt-get update && \ sudo apt-get install -y dotnet-sdk-5.0
WorkplaceX/Framework
Framework.Cli/Ci/travis-ci.org/Install.sh
Shell
mit
493
#! /bin/sh $XGETTEXT *.cpp -o $podir/kresources_shared_akonadi.pot
kolab-groupware/kdepim-runtime
kresources/shared/Messages.sh
Shell
gpl-2.0
67
#!/bin/bash # Scans the contents of the release folder and copies the shared task files into folders that should appear in TIRA. UDPATH=/net/work/people/zeman/unidep SRCREL=$UDPATH/release-2.2/ud-treebanks-v2.2 # SRCMOR: UDPipe morphology, gold segmentation and syntax. This has been released in Lindat. # SRCPSM: UDPipe segmentation and morphology, no syntax. Preprocessing for participants who do not want to do this on their own. # This folder contains a pipeline that Milan created for this. The script process-tira-devel-trial.sh runs it on devel and trial. # The script takes its input from my $DST folder (see below), thus it must be re-run if we change the data here. But right now # the results are there, in folders development and trial, called code-udpipe.conllu. SRCMOR=/net/work/people/zeman/unidep/ud-2.2-conll18-crossfold-morphology SRCPSM=/net/work/people/zeman/unidep/tira-data-2018-psegmorfile ###!!! Skip files preprocessed by UDPipe until Milan prepares the files from UD 2.2. ###!!! Setting the variable SKIPUDPIPE to any non-empty value will do it. ###!!! Comment it out when ready. #SKIPUDPIPE=yes DSTFOLDER=data-for-tira DST=$UDPATH/$DSTFOLDER # Expected folder structure at TIRA: Datasets are mounted under /media/*. # The top-level subfolders determine where, when and how the datasets are # accessible: # - training-datasets # - training-datasets-truth # - test-datasets # - test-datasets-truth # Each of these folders has subfolders for all shared tasks hosted at TIRA. # Ours is called "universal-dependency-learning", its subfolders could be # datasets of various years/rounds; we currently have CoNLL 2017 and 2018. # The subfolders of the 2017 task are: # - conll17-ud-trial-2017-03-19 (in training-datasets ==? training-datasets-truth; for ar, en, tr, vi, zh) # - conll17-ud-development-2017-03-19 (in training-datasets ==? training-datasets-truth) # - conll17-ud-test-2017-05-09 (in test-datasets and test-datasets-truth) # So we should now create for 2018: # - conll18-ud-trial-2018-04-15 (in training-datasets) # - conll18-ud-development-2018-04-15 # - conll18-ud-test-2018-04-15 (in test-datasets and test-datasets-truth) # /media/training-datasets: Only this folder can be accessed by the participants. # It contains the training data (just in case they want to train something # here?), the development data (participants can access the development data # directly from their virtual machine, and they can run their system through # the web interface with the development data as input), and trial data # (a small subset of the development data, used for fast debugging). # These datasets may include the gold standard so that the participants can # access it when they experiment in their virtual machine; but a copy of the # gold standard must also exist in the "truth" folder mentioned below. # /media/training-datasets-truth: Not accessible by the participants, although # the other tasks seem to have just a copy of the training and development # data here. This is probably the place where the evaluation script takes # the gold standard from. # /media/test-datasets: Blind test data used as input for the systems. The # participants normally do not see it, their system only can access it when # the virtual machine is "sandboxed", to prevent information leaks. # Of course this folder must not contain gold-standard data. # /media/test-datasets-truth: Gold standard test data used by the evaluation # script. TASK="universal-dependency-learning/conll18-ud" DATE="2018-05-06" DSTTRAINI="$DST/training-datasets/$TASK-training-$DATE" DSTTRAING="$DST/training-datasets-truth/$TASK-training-$DATE" DSTDEVI="$DST/training-datasets/$TASK-development-$DATE" DSTDEVG="$DST/training-datasets-truth/$TASK-development-$DATE" DSTTRIALI="$DST/training-datasets/$TASK-trial-$DATE" DSTTRIALG="$DST/training-datasets-truth/$TASK-trial-$DATE" DSTTESTI="$DST/test-datasets/$TASK-test-$DATE" DSTTESTG="$DST/test-datasets-truth/$TASK-test-$DATE" # Generate the folders. rm -rf $DST mkdir -p $DSTTRAINI mkdir -p $DSTTRAING mkdir -p $DSTDEVI mkdir -p $DSTDEVG mkdir -p $DSTTRIALI mkdir -p $DSTTRIALG mkdir -p $DSTTESTI mkdir -p $DSTTESTG echo code.conllu .......... gold standard data > $DSTTRAINI/README.txt echo code-pmor.conllu ..... gold segmentation and syntax, predicted morphology >> $DSTTRAINI/README.txt echo code-udpipe.conllu ... predicted segmentation and morphology, no syntax >> $DSTTRAINI/README.txt echo code.txt ............. raw text input >> $DSTTRAINI/README.txt cp $DSTTRAINI/README.txt $DSTDEVI/README.txt echo Small subset of the development data, intended for debugging. > $DSTTRIALI/README.txt echo code-udpipe.conllu ... predicted segmentation and morphology, no syntax >> $DSTTRIALI/README.txt echo code.txt ............. raw text input >> $DSTTRIALI/README.txt echo code-udpipe.conllu ... predicted segmentation and morphology, no syntax > $DSTTESTI/README.txt echo code.txt ............. raw text input >> $DSTTESTI/README.txt # In the folders that the system can get as input, we will create metadata.json. # The system should use it to identify what files it is supposed to process and # how. Metadata fields: cat << EOF > $DST/README-metadata.txt The system must read metadata.json to obtain the list of test sets it is supposed to process. Each test set has a record in the list, and the fields in the record are interpreted as follows: * lcode ..... language code (for UD languages same as in UD; but other languages may appear here too) * tcode ..... treebank code (for UD treebanks same as in UD; but extra non-UD treebanks may appear here too) * rawfile ... name of raw text file (input of systems that do their own segmentation) * psegmorfile ... name of CoNLL-U file with segmentation and morphology predicted by a baseline system (currently UDPipe) * outfile ... name of the corresponding CoNLL-U file that the system must generate in the output folder Extra fields not needed by the participating system: * goldfile ... name of the corresponding gold-standard file to be used by the evaluation script (in a separate folder) EOF cat $DST/README-metadata.txt >> $DSTDEVI/README.txt cat $DST/README-metadata.txt >> $DSTTRIALI/README.txt cat $DST/README-metadata.txt >> $DSTTESTI/README.txt rm $DST/README-metadata.txt # Copy the data to the folders. cd $SRCREL echo '[' > $DSTDEVI/metadata.json echo '[' > $DSTTRIALI/metadata.json echo '[' > $DSTTESTI/metadata.json for i in UD_* ; do # All treebanks should have test data even if they do not have training or # development data. ltcode=$(ls $i | grep test.conllu | perl -pe 's/-ud-test\.conllu$//') lcode=$(echo $ltcode | perl -pe 's/_.*//') tcode=$(echo $ltcode | perl -pe 'if(m/_(.+)/) {$_=$1} else {$_=0}') echo `pwd`/$i '-->' $ltcode # Some small treebanks do not have any training set. if [ -f $i/$ltcode-ud-train.conllu ] ; then chmod 644 $i/$ltcode-ud-train.conllu cp $i/$ltcode-ud-train.conllu $DSTTRAING/$ltcode.conllu cp $i/$ltcode-ud-train.conllu $DSTTRAINI/$ltcode.conllu if [ -z "$SKIPUDPIPE" ] ; then cp $SRCMOR/$i/$ltcode-ud-train.conllu $DSTTRAINI/$ltcode-pmor.conllu fi cp $i/$ltcode-ud-train.txt $DSTTRAINI/$ltcode.txt fi # Some small treebanks do not have any dev set. if [ -f $i/$ltcode-ud-dev.conllu ] ; then if [ -z "$firstdev" ] ; then firstdev="nolonger" else echo , >> $DSTDEVI/metadata.json fi echo -n ' {"lcode":"'$lcode'", "tcode":"'$tcode'", "rawfile":"'$ltcode'.txt", "psegmorfile":"'$ltcode'-udpipe.conllu", "outfile":"'$ltcode'.conllu", "goldfile":"'$ltcode'.conllu"}' >> $DSTDEVI/metadata.json chmod 644 $i/$ltcode-ud-dev.conllu cp $i/$ltcode-ud-dev.conllu $DSTDEVG/$ltcode.conllu cp $i/$ltcode-ud-dev.conllu $DSTDEVI/$ltcode.conllu if [ -z "$SKIPUDPIPE" ] ; then cp $SRCMOR/$i/$ltcode-ud-dev.conllu $DSTDEVI/$ltcode-pmor.conllu cp $SRCPSM/training-datasets/universal-dependency-learning/conll18-ud-development-2018-04-15/$ltcode-udpipe.conllu $DSTDEVI/$ltcode-udpipe.conllu fi cp $i/$ltcode-ud-dev.txt $DSTDEVI/$ltcode.txt fi # Create a trial dataset for debugging purposes. # Unlike the development data, we will not provide the gold-standard file in the input folder. # The purpose is to make the setting as similar to the test data as possible. if [ "$i" = "UD_English-GUM" ] || [ "$i" = "UD_Czech-PDT" ] || [ "$i" = "UD_Arabic-PADT" ] || [ "$i" = "UD_Chinese-GSD" ] || [ "$i" = "UD_Swedish-Talbanken" ] ; then if [ -z "$firsttrial" ] ; then firsttrial="nolonger" else echo , >> $DSTTRIALI/metadata.json fi echo -n ' {"lcode":"'$lcode'", "tcode":"'$tcode'", "rawfile":"'$ltcode'.txt", "psegmorfile":"'$ltcode'-udpipe.conllu", "outfile":"'$ltcode'.conllu", "goldfile":"'$ltcode'.conllu"}' >> $DSTTRIALI/metadata.json split_conll.pl -head 50 < $i/$ltcode-ud-dev.conllu $DSTTRIALG/$ltcode.conllu /dev/null ../../tools/conllu_to_text.pl --lang $lcode < $DSTTRIALG/$ltcode.conllu > $DSTTRIALI/$ltcode.txt if [ -z "$SKIPUDPIPE" ] ; then cp $SRCPSM/training-datasets/universal-dependency-learning/conll18-ud-trial-2018-04-15/$ltcode-udpipe.conllu $DSTTRIALI/$ltcode-udpipe.conllu fi fi # Copy the test data. All treebanks should have test data even if they do not # have training or development data. if [ -z "$firsttest" ] ; then firsttest="nolonger" else echo , >> $DSTTESTI/metadata.json fi echo -n ' {"lcode":"'$lcode'", "tcode":"'$tcode'", "rawfile":"'$ltcode'.txt", "psegmorfile":"'$ltcode'-udpipe.conllu", "outfile":"'$ltcode'.conllu", "goldfile":"'$ltcode'.conllu"}' >> $DSTTESTI/metadata.json chmod 644 $i/$ltcode-ud-test.conllu cp $i/$ltcode-ud-test.conllu $DSTTESTG/$ltcode.conllu cp $i/$ltcode-ud-test.txt $DSTTESTI/$ltcode.txt if [ -z "$SKIPUDPIPE" ] ; then cp $SRCPSM/test-datasets/universal-dependency-learning/conll18-ud-test-2018-04-15/$ltcode-udpipe.conllu $DSTTESTI/$ltcode-udpipe.conllu fi done echo >> $DSTDEVI/metadata.json echo >> $DSTTRIALI/metadata.json echo >> $DSTTESTI/metadata.json echo ']' >> $DSTDEVI/metadata.json echo ']' >> $DSTTRIALI/metadata.json echo ']' >> $DSTTESTI/metadata.json cp $DSTDEVI/metadata.json $DSTDEVG/metadata.json cp $DSTTRIALI/metadata.json $DSTTRIALG/metadata.json cp $DSTTESTI/metadata.json $DSTTESTG/metadata.json ###!!! For later updates we may want to generate only selected data sets. ###!!! The easiest approach is probably to generate everything and then remove ###!!! the superfluous data sets here. #rm -rf $DSTTRAINI #rm -rf $DSTTRAING #rm -rf $DSTDEVI #rm -rf $DSTDEVG #rm -rf $DSTTRIALI #rm -rf $DSTTRIALG cd $DST/.. rm tira.zip cd $DST zip -r ../tira.zip *
UniversalDependencies/tools
package_st_data.sh
Shell
gpl-2.0
10,937
#!/usr/bin/env bash # This file xman_dos2unix is part of xman utility. # # Copyright (c) 2007 Chung Shin Yee <[email protected]> # # http://myxman.org # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA. # # The GNU General Public License is contained in the file COPYING. # # Date : 22 April 2007 # Syntax: xman_dos2unix <FILE> ... # Description: Apply dos2unix to all given text files recursively. # Given: Files or folders. # Output: All text files including those in subfolders (recursively) will have all CRLF being removed. ## This script uses http://waterlan.home.xs4all.nl/dos2unix.html dos2unix implementation. FILE="file" GREP="grep -i" DOS2UNIX="dos2unix -ascii --keepdate --safe --skip-symlink --oldfile" ######################################################################################### explore() { local file="" ls -1 | while read -r file do # Recursively explore if we found a directory. if [ -d "${file}" ] ; then echo "Entering ${file}" pushd "${file}" > /dev/null explore echo "Leaving ${file}" popd > /dev/null # Process it if we found a text file. elif [ "`${FILE} \"${file}\" | ${GREP} text`" != "" ] ; then # echo "Processing: ${file}" ${DOS2UNIX} "${file}" fi done } # end of explore() # Start of main program if [ -z "${1}" ] ; then echo "usage: xman_dos2unix <FILE> ..." exit 0 fi dir="${1}" if [ ! -e "${dir}" ] ; then echo "ERROR: Path ${dir} does not exist" exit 0 fi OLDIFS=${IFS} IFS=$'\n' for file in $@ ; do # FIXME: I should have put these into a subroutine to reduce code duplications in explore(). # However, I'm not familiar with subroutines in BASH yet. IFS=${OLDIFS} if [ -d "${file}" ] ; then echo "Entering ${file}" pushd "${file}" > /dev/null explore echo "Leaving ${file}" popd elif [ "`${FILE} \"${file}\" | ${GREP} text`" != "" ] ; then ${DOS2UNIX} "${file}" fi IFS=$'\n' done IFS=${OLDIFS} exit 0 #eof
keshav21/My_Shell_Scripts
xmanutility/xman_dos2unix.sh
Shell
gpl-2.0
2,586
# # Copyright (C) 2010 OpenWrt.org # . /lib/ramips.sh PART_NAME=firmware RAMFS_COPY_DATA=/lib/ramips.sh platform_check_image() { local board=$(ramips_board_name) local magic="$(get_magic_word "$1")" [ "$ARGC" -gt 1 ] && return 1 case "$board" in dir-300-b1 | dir-600-b1 | dir-600-b2 | fonera20n | nbg-419n | nw718 | rt-g32-b1 | v22rw-2x2 | whr-g300n | hw550-3g | mofi3500-3gn) [ "$magic" != "2705" ] && { echo "Invalid image type." return 1 } return 0 ;; esac echo "Sysupgrade is not yet supported on $board." return 1 } platform_do_upgrade() { local board=$(ramips_board_name) case "$board" in *) default_do_upgrade "$ARGV" ;; esac } disable_watchdog() { killall watchdog ( ps | grep -v 'grep' | grep '/dev/watchdog' ) && { echo 'Could not disable watchdog' return 1 } } append sysupgrade_pre_upgrade disable_watchdog
ago/openwrt
target/linux/ramips/base-files/lib/upgrade/platform.sh
Shell
gpl-2.0
866
#!/bin/bash channel=calendar user=$1 prefix="/var/lib/radicale/collections" collection="collection-root" m_files=$(git ls-files -m) if [ -n "$m_files" ]; then if [ -f "${m_files}" ]; then #File was changed else tmp=$(mktemp) git show master:${collection}/${m_files} > $tmp m_file=$tmp #File was deleted fi else m_files=$(git ls-files --others --exclude-standard) if [ -n "$m_files" ]; then #File was added else m_file="" fi fi if [ -n "$m_file" ]; then text=$(python3 /etc/radicale/format_ics.py $m_file) else text="Nieznane zdarzenie kalendarza" fi #folder=/var/lib/radicale/collections/collection-root/${user} text="${user} modified calendar: ${text}" escapedText=$(echo $text | sed 's/"/\"/g' | sed "s/'/\'/g" ) json="{\"channel\": \"#$channel\", \"text\": \"$escapedText\"}" curl -s -d "payload=$json" "https://hooks.slack.com/services/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" #echo "${text}">>/root/log.txt
adamryczkowski/puppet-bootstrap
files/radicale_slack_hook.sh
Shell
gpl-2.0
951
#!/bin/bash # $Id$ # # Authors: # Jeff Buchbinder <[email protected]> # # FreeMED Electronic Medical Record and Practice Management System # Copyright (C) 1999-2012 FreeMED Software Foundation # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # Create incremental FreeMED dump PHYSICAL="$(scripts/cfg-value PHYSICAL_LOCATION)" if [ ! -d "${PHYSICAL}" ]; then echo "Could not find FreeMED!" exit -1 fi if [ ! -f "${PHYSICAL}/data/backup/full" ]; then echo "A full backup must exist before an incremental backup can be performed!" exit -1 fi # Create new full (full.inc) mysqldump \ --single-transaction \ --user="$(scripts/cfg-value DB_USER)" \ --password="$(scripts/cfg-value DB_PASS)" \ freemed > data/backup/full.inc # Diff it diff data/backup/full data/backup/full.inc > data/backup/incremental # Remove temporary full database rm -f data/backup/full.inc
freemed/freemed
scripts/dump_incremental.sh
Shell
gpl-2.0
1,522
#!/bin/sh #? #? NAME #? $0 - generate o-saft_standalone.pl #? #? SYNOPSIS #? $0 #? $0 [OPTIONS] [output-file] #? #? OPTIONS #? --h got it #? --n do not execute, just show what would be done #? --t do not check if all files are commited to repository #? --s silent, do not print informations (for usage with Makefile) #? --v be a bit verbose #? #? DESCRIPTION #? Generate script, which contains (all) modules for O-Saft. #? Prints on STDOUT if no [output-file] was specified. #? #? NOTE: this will not generate a bulletproof stand-alone script! #? #? VERSION #? @(#) 1.18 22/02/19 09:04:12 #? #? AUTHOR #? 02-apr-16 Achim Hoffmann #? # ----------------------------------------------------------------------------- dst=/dev/stdout # default STDOUT src=o-saft.pl ; [ -f $src ] || src=../$src try= sid=1 info=1 while [ $# -gt 0 ]; do case "$1" in '-h' | '--h' | '--help') ich=${0##*/} \sed -ne "s/\$0/$ich/g" -e '/^#?/s/#?//p' $0 exit 0 ;; '-n' | '--n') try=echo; ;; '-t' | '--t') sid=0 ; ;; '-s' | '--s') info=0 ; ;; '-v' | '--v') set -x ; ;; *) dst="$1"; ;; esac shift done if [ ! -e "$src" ]; then \echo "**ERROR: '$src' does not exist; exit" [ "echo" = "$try" ] || exit 2 fi _o_saft=" osaft.pm OSaft/error_handler.pm OSaft/Doc/Data.pm Net/SSLhello.pm Net/SSLinfo.pm o-saft-dbx.pm o-saft-usr.pm o-saft-man.pm " o_saft="" for f in $_o_saft ; do [ -f $f ] || f=../$f # quick&dirty if called in sub-directory o_saft="$o_saft $f" done _osaft_doc=" OSaft/Doc/coding.txt OSaft/Doc/glossary.txt OSaft/Doc/help.txt OSaft/Doc/links.txt OSaft/Doc/rfc.txt " # OSaft/Doc/misc \ osaft_doc="" for f in $_osaft_doc ; do [ -f $f ] || f=../$f # quick&dirty if called in sub-directory osaft_doc="$osaft_doc $f" done if [ $sid -eq 1 ]; then for f in $o_saft ; do # NOTE contribution to SCCS: %I''% \egrep -q 'SID.*%I''%' $f \ && \echo "**ERROR: '$f' changes not commited; exit" \ && exit 2 done fi if [ $info -eq 1 ]; then if [ "/dev/stdout" = "$dst" ]; then \echo "# generate file standalone.pl ..." else \echo "# generate $dst ..." fi \echo "" fi [ "/dev/stdout" != "$dst" ] && $try \rm -rf $dst [ "$try" = "echo" ] && dst=/dev/stdout # general hints how to include: # 1. extract from o-saft.pl anything before line ## PACKAGES # # 2. add o-saft.pl POD # # 3. add $osaft_standalone # # ?. include osaft.pm # # 4. include text from module file enclosed in ## PACKAGE scope from all modules # # 5. add rest of o-saft.pl # # 6. patch "standalone specials" # # 7. add separator line for POD ( # 1. $try \perl -ne 'print if (m()..m(## PACKAGES ))' $src # 2. $try $src --no-warning --no-rc --help=pod # 3. \echo '' \echo '$osaft_standalone = 1;' \echo '' # 4. # osaft.pm without brackets and no package f=osaft.pm ; [ -f $f ] || f=../$f \echo "# { # $f" $try \perl -ne 'print if (m(## PACKAGE [{])..m(## PACKAGE })) and not m(package osaft;)' $f \echo "# } # $f" \echo "" ## TODO: OSaft/Doc/Data.pm f=OSaft/Doc/Data.pm ; [ -f $f ] || f=../$f \echo "{ # $f" $try \perl -ne 'print if (m(## PACKAGE [{])..m(## PACKAGE }))' $f \echo "} # $f" \echo "" # TODO: o-saft-usr.pm works, but not yet perfect f=o-saft-usr.pm ; [ -f $f ] || f=../$f \echo "{ # $f" $try \perl -ne 'print if (m(## PACKAGE [{])..m(## PACKAGE }))' $f #$try \cat $f \echo "} # $f" \echo "" ## TODO: o-saft-dbx.pm still with errors #f=o-saft-dbx.pm #\echo "{ # $f" #$try \perl -ne 'print if (m(## PACKAGE [{])..m(## PACKAGE }))' $f #\echo "} # $f" #\echo "" ## TODO: o-saft-man fails to include properly f=o-saft-man.pm ; [ -f $f ] || f=../$f \echo "{ # $f" $try \perl -ne 'print if (m(## PACKAGE [{])..m(## PACKAGE })) and not m(use osaft;)' $f \ | \grep -v '^use OSaft::Doc::Data' \echo "} # $f" \echo "" f=OSaft/error_handler.pm ; [ -f $f ] || f=../$f \echo "{ # $f" #$try \perl -ne 'print if (m(## PACKAGE [{])..m(## PACKAGE }))' $f $try \cat $f \echo "} # $f" \echo "" f=Net/SSLinfo.pm ; [ -f $f ] || f=../$f \echo "{ # $f" $try \perl -ne 'print if (m(## PACKAGE [{])..m(## PACKAGE }))' $f \echo "" \echo 'my $_ssinfo_dum = $Net::SSLinfo::next_protos; # avoid Perl warning: "used only once: possible typo ..."' \echo "} # $f" \echo "" ## TODO: Net/SSLhello.pm fails # Reasons: use of STR_HINT in _hint(); need: no strict 'subs' #f=Net/SSLhello.pm #\echo "{ # $f" #$try \perl -ne 'print if (m(## PACKAGE [{])..m(## PACKAGE }))' $f \ # | \egrep -v '^use (osaft|OSaft::error_handler)' #\echo "} # $f" #\echo "" # 5. \echo "package main;" $try \perl -ne 'print if (not m()..m(## PACKAGES)) and not m(use osaft;)' $src \ | \egrep -v 'require (q.o-saft-man.pm|Net::SSLhello)' # 6. ) \ | $try \perl -pe '/^=head1 (NAME|Annotation)/ && do{print "=head1 "."_"x77 ."\n\n";};' \ | $try \sed -e 's/#\s*OSAFT_STANDALONE\s*//' \ > $dst # 7. ##TODO: lsopt= # tweak output if used from make [ -z "$OSAFT_MAKE" ] && lsopt="-la" [ "/dev/stdout" != "$dst" ] && $try \chmod 555 $dst [ $info -eq 0 ] && exit [ "/dev/stdout" != "$dst" ] && $try \ls $lsopt $dst # Writing on /dev/stdout is scary on some systems (i.e Linux). If code above # was written on /dev/stdout, the buffer may not yet flushed. Then following # echo and cat commands, which write on the tty's STDOUT, my overwrite what # is already there. Some kind of race condition ... # As the shell has no build-in posibility to flush STDOUT, following output # is written to /dev/stdout directly to avoid overwriting, ugly but seems to # work ... cat << EoDescription >> /dev/stdout # $dst generated The generated stand-alone script misses following functionality: * Commands +cipherall +cipher-dh * Options --exit* --starttls Use of any of these commands or options will result in Perl compile errors like (unsorted): Use of uninitialized value ... Undefined subroutine ... Subroutine XXXX redefined at ... "our" variable XXXX redeclared at ... Note that --help and --help=* will only work if following files exist or are located in the same directory as $dst : $osaft_doc "perldoc $dst" contains all POD of all included (module) files in unsorted order. For more details for a stand-alone script, please see: o-saft.pl --help=INSTALL EoDescription exit
OWASP/O-Saft
contrib/gen_standalone.sh
Shell
gpl-2.0
6,450
#!/bin/sh # # $Id: test_checkall.sh,v 1.2 2004/12/21 14:43:44 roca Exp $ # # Copyright (c) 1999-2004 INRIA - All rights reserved # (main author: Vincent Roca - [email protected]) # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, # USA. # check that checkall works! #exit 1 exit 0
jcable/mcl
check/alc/test_checkall.sh
Shell
gpl-2.0
953
#!/bin/bash # # usage: # # # sbatch options #SBATCH --job-name=RUN_CREATE_CRIS_HR_RANDOM_RTP # partition = dev/batch #SBATCH --partition=batch # qos = short/normal/medium/long/long_contrib #SBATCH --qos=short #SBATCH --account=pi_strow #SBATCH -N1 #SBATCH --mem-per-cpu=18000 #SBATCH --cpus-per-task 1 ##SBATCH --array=0-179 #SBATCH --time=00:59:00 #SBATCH -o /home/sbuczko1/logs/sbatch/run_cris_hr_random_batch-%A_%a.out #SBATCH -e /home/sbuczko1/logs/sbatch/run_cris_hr_random_batch-%A_%a.err # matlab options MATLAB=/usr/cluster/matlab/current/bin/matlab MATOPT=' -nojvm -nodisplay -nosplash' echo "Executing srun of run_cris_batch" $MATLAB $MATOPT -r "disp('>>Starting script');addpath('/asl/packages/swutils');cfg=ini2struct('$1');run_cris_hires_random_batch(cfg); exit" echo "Finished with run_cris_batch"
strow/rtp_prod2
cris/scripts/run_cris_hires_random_batch.sh
Shell
gpl-2.0
826
#!/bin/sh leds() { echo 0=$1 > /dev/servoblaster echo 1=$2 > /dev/servoblaster echo 2=$3 > /dev/servoblaster echo 4=$4 > /dev/servoblaster } b=0 d=0.1 while true; do leds $b 0 0 0 sleep $d leds 0 $b 0 0 sleep $d leds 0 0 $b 0 sleep $d leds 0 0 0 $b sleep $d leds 0 0 $b 0 sleep $d leds 0 $b 0 0 sleep $d b=$(( b + 100 )) [ $b = 2000 ] && b=0 done
jtanx/ServoBlasterMod
ripple.sh
Shell
gpl-2.0
387
# # Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 only, as # published by the Free Software Foundation. # # This code is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # version 2 for more details (a copy is included in the LICENSE file that # accompanied this code). # # You should have received a copy of the GNU General Public License version # 2 along with this work; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. # # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, # CA 95054 USA or visit www.sun.com if you need additional information or # have any questions. # # @test # @bug 6824477 # @summary Selector.select can fail with IOException "Invalid argument" on # Solaris if maximum number of file descriptors is less than 10000 # @build LotsOfUpdates # @run shell lots_of_updates.sh OS=`uname -s` case "$OS" in Windows_* ) echo "ulimit not on Windows" exit 0 ;; * ) CLASSPATH=${TESTCLASSES}:${TESTSRC} ;; esac export CLASSPATH # hard limit needs to be less than 10000 for this bug NOFILES=`ulimit -n -H` if [ "$NOFILES" = "unlimited" ] || [ $NOFILES -ge 10000 ]; then ulimit -n 2048 fi ${TESTJAVA}/bin/java LotsOfUpdates
TheTypoMaster/Scaper
openjdk/jdk/test/java/nio/channels/Selector/lots_of_updates.sh
Shell
gpl-2.0
1,646
#!/bin/bash # # Modify this file to deploy your project on production server # exit rsync -n -varlogpt --progress --exclude="include/conf.php" --exclude="tmp" \ --exclude=".htpassw" --exclude=".htaccess" --exclude="htdocs/admin" \ --exclude="htdocs/upload" \ /home/develop/skeleton/* root@uk:/home/skeleton/ #ssh uk "/etc/init.d/php5-fpm reload; /etc/init.d/apache2 reload;"
MrBad/skeleton
deploy.sh
Shell
gpl-2.0
376
#! /bin/sh # Copyright (C) 2011-2022 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. # Test that we can define a distcheck-hook to diagnose m4 files # missing from the dist tarball (interaction with '--install'). # See automake bug#9037. . test-init.sh cwd=$(pwd) || fatal_ "cannot get current working directory" cp "$am_testaux_srcdir"/distcheck-hook-m4.am . \ || fatal_ "cannot fetch makefile fragment 'distcheck-hook-m4.am'" cat > Makefile.am << 'END' ## The lack of '--install' here is meant. ACLOCAL_AMFLAGS = -I m4 include $(srcdir)/distcheck-hook-m4.am END cat >> configure.ac << 'END' dnl We *deliberately* don't use m4_pattern_forbid here. AC_OUTPUT MY_FOO MY_BAR MY_BAZ MY_ZAR END mkdir m4 acdir acdir1 acdir2 pth cat > acdir/dirlist << END $cwd/acdir1 $cwd/acdir2 END echo 'AC_DEFUN([MY_FOO], [:])' > m4/foo.m4 echo 'AC_DEFUN([MY_BAR], [:])' > acdir1/bar.m4 echo 'AC_DEFUN([MY_BAZ], [:])' > acdir1/baz.m4 echo 'AC_DEFUN([MY_QUX], [:])' > acdir2/qux.m4 echo 'AC_DEFUN([MY_ZAR], [:])' > pth/zar.m4 echo 'AC_DEFUN([MY_BLA], [:])' > pth/bla.m4 ACLOCAL="$ACLOCAL --system-acdir=$cwd/acdir"; export ACLOCAL ACLOCAL_PATH=$cwd/pth; export ACLOCAL_PATH # We don't use '--install' here. Our distcheck-hook should catch this. $ACLOCAL -I m4 $AUTOCONF $EGREP 'MY_(FOO|BAR|BAZ|ZAR)' configure && exit 1 # Sanity check. $AUTOMAKE check_no_spurious_error () { $EGREP -i 'mkdir:|:.*(permission|denied)' output && exit 1 # On failure, some make implementations (such as Solaris make) print the # whole failed recipe on stdout. The first grep works around this. grep -v 'rm -rf ' output | grep -i 'autom4te.*\.cache' && exit 1 : To placate 'set -e'. } ./configure run_make -M -e FAIL distcheck for x in bar baz zar; do $EGREP "required m4 file.*not distributed.* $x.m4( |$)" output done check_no_spurious_error # Now we use '--install', and "make distcheck" should pass. $ACLOCAL -I m4 --install test -f m4/bar.m4 # Sanity check. test -f m4/baz.m4 # Likewise. test -f m4/zar.m4 # Likewise. using_gmake || $MAKE Makefile $MAKE distcheck # We start to use new "third-party" macros from new .m4 files, but forget # to re-run "aclocal --install" by hand, relying on automatic remake rules. # Our distcheck-hook should catch this too. cat >> configure.ac << 'END' MY_QUX MY_BLA END $MAKE $EGREP 'MY_(FOO|BAR|BAZ|QUX|ZAR|BLA)' configure && exit 1 # Sanity check. run_make -M -e FAIL distcheck $EGREP "required m4 file.*not distributed.* qux.m4( |$)" output $EGREP "required m4 file.*not distributed.* bla.m4( |$)" output check_no_spurious_error # Check that we don't complain for files that should have been found. $FGREP " (bar|baz|zar).m4" output && exit 1 # Now we again use '--install', and "make distcheck" should pass. $ACLOCAL -I m4 --install test -f m4/qux.m4 # Sanity check. test -f m4/bla.m4 # Likewise. using_gmake || $MAKE Makefile $MAKE distcheck :
autotools-mirror/automake
t/distcheck-missing-m4.sh
Shell
gpl-2.0
3,490
#!/bin/sh # --------------------------------------- # Backup de las bases de datos PostgreSQL # Version: 1.0.b 2013-01-31 # --------------------------------------- # Uso # PostgreSQL backup, every nigth at 01:00 a.m. #0 1 * * * postgres /usr/local/bin/postgres-backup.sh 9.3 5432 >/dev/null 2>&1 set -x BACKUP_FOLDER="/var/backups/postgresql" PG_USER="postgres" uso() { echo "$0 <version>" echo "Donde: " echo " <version> es el número de versión de la instancia de PostgreSQL" } if [ $# -eq 0 ] then uso exit 1 fi # Obtener el número de version. if [ "x$1" = "x" ] then echo "ERROR: Se debe indicar el número de version de la instancia de PostgreSQL" uso exit 1 else version=$1 fi BACKUP_FOLDER="$BACKUP_FOLDER/$version" if [ ! -d $BACKUP_FOLDER ] then mkdir -p $BACKUP_FOLDER fi # Obtener la fecha fecha=`date +%Y%m%d` # Obtener la lista de bases de datos for db in `psql --command="SELECT datname FROM pg_database" --tuples-only` do filename="$BACKUP_FOLDER/$db-$fecha.dump" echo -n "Copia de seguridad de la base de datos $db" if [ ! -f $filename ] then pg_dump ${db} > $filename 2>/dev/null if [ $? -eq 0 ] then echo " . echo" else echo "ERROR: Al generar la copia de seguridad de $filename se elimina el archivo" rm -f $filename fi else echo " . ya existe" fi done # Eliminar la copia de hace N días rmfecha=`date --date='-10 day' +%Y%m%d` num=`ls $BACKUP_FOLDER/*-$rmfecha.dump 2>/dev/null |wc -l` if [ $? -eq 0 ] then if [ $num -gt 0 ] then echo -n "Se eliminan las $num copias antiguas $BACKUP_FOLDER/*-$rmfecha.dump" rm -f $BACKUP_FOLDER/*-$rmfecha.dump if [ $? -eq 0 ] then echo " . hecho" else echo " . error" echo "ERROR: Se han encontrado errores al eliminar las copias antiguas" fi fi fi
kamaxeon/scripts_linux
backup_sql/postgres-backup.sh
Shell
gpl-2.0
1,854
#!/bin/bash set -ex [[ -d ${0%/*} ]] && cd "${0%/*}" RUN_ID="$1" TESTS=$2 ./configure NCPU=$(getconf _NPROCESSORS_ONLN) if ! [[ $TESTS ]]; then make -j"$NCPU" all syncheck rpm logtee else [[ $TESTS == "99" ]] && make_docs=yes || make_docs=no make -j"$NCPU" enable_documentation=$make_docs all logtee cd test time sudo LOGTEE_TIMEOUT_MS=300000 make \ enable_documentation=$make_docs \ KVERSION="$(rpm -qa kernel --qf '%{VERSION}-%{RELEASE}.%{ARCH}\n' | sort -rn | head -1)" \ DRACUT_NO_XATTR=1 \ TEST_RUN_ID="$RUN_ID" \ ${TESTS:+TESTS="$TESTS"} \ -k V=2 \ check fi
haraldh/dracut
fedora-test.sh
Shell
gpl-2.0
648
#$ -S /bin/bash ##$ -V #$ -m as #$ -cwd #$ -q new.q ##$ -l mem_requested=8G #$ -o logs_queue #$ -e logs_queue #$ -N calccomplexity #$ -hold_jid smMIP_prep_samples # arguments should be: # $1 = sample ID key text file for all samples # sampleIDkey format: # 1st column: numeric ID (1 through x) # 2nd column: sample name # 3rd column optional # $2 = project name # $3 = MIP design file # location of Pediatrics analysis pipeline bin pipelinebin='/labdata6/allabs/mips/pipeline_smMIPS_v1.1/smMIPs_analysis' # location of MIPGEN/tools script directory mipgentoolsbin='/labdata6/allabs/mips/pipeline_smMIPS_v1.1/MIPGEN/tools' # location of executables executbin='/labdata6/allabs/mips/pipeline_smMIPS_v1.1/executables' # directory to reference files (reference genome fasta and various indexes) refdir='/labdata6/allabs/mips/references/b37/BWA0.7.8' ################### only necessary if using modules environment ####################### source /cm/local/apps/environment-modules/3.2.10/Modules/3.2.10/init/bash module load shared Tools/common dos2unix/6.0.5 sge java/1.7.0_55 python/2.7.6 conda/4.5.0 ####################################################################################### export PYTHONPATH=/labdata6/allabs/mips/pipeline_smMIPS_v1.1/MIPGEN/tools/ ####################################################################################### set -e set -o pipefail NOW=$(date +"%c") printf "Running step 2, calccomplexity job: $NOW\n" >> $2.smMIPspipeline.log.txt THISSCRIPT=$(basename $0) NODENAME=$(hostname) printf "Running $0 on cluster node $NODENAME\n" printf "Making list of all bam files for this samplesheet\n" find */* -name "*.indexed.sort.collapse.all_reads.unique.sort.bam" > bam.list printf "done\n" printf "Creating a master complexity file for all samples for all mips\n" echo -e "sample\tmip\ttotal\tunique" > QC_data/$2.allsamplesallmips.indexed.sort.collapse.complexity.txt find */* ! -path "QC_data/*" -name "*.indexed.sort.collapse.complexity.txt" -exec tail -n +2 {} \; >> QC_data/$2.allsamplesallmips.indexed.sort.collapse.complexity.txt printf "done\n" printf "Creating a mater mipwise complexity file\n" python $pipelinebin/calc_complexity_demultiplexed.py --samplekey $1 --projectname QC_data/$2 printf "done\n" printf "Creating a master samplewise-summary file for all samples\n" echo -e "sample\tmip\ttotal\tunique\tsaturation" > QC_data/$2.indexed.sort.collapse.samplewise_summary.txt find */* ! -path "QC_data/*" -name "*.indexed.sort.collapse.samplewise_summary.txt" -exec tail -n +2 {} \; >> QC_data/$2.indexed.sort.collapse.samplewise_summary.txt printf "done\n" printf "Adding Concatenated_name to QC files\n" perl $pipelinebin/add_concatname_complexity.pl --designfile $3 --complexityfile QC_data/$2.allsamplesallmips.indexed.sort.collapse.complexity.txt perl $pipelinebin/add_concatname_complexity.pl --designfile $3 --complexityfile QC_data/$2.indexed.sort.collapse.complexity.txt printf "done\n"
jxchong/smMIPs_analysis
sub_calccomplexity.sh
Shell
gpl-2.0
2,968
#!/bin/sh set -e set -x sudo apt install gnupg pandoc fakeroot sudo apt install texlive-base texlive-latex-base texlive-latex-extra texlive-fonts-recommended texlive-latex-recommended sudo apt install lmodern libxml2-utils traceroute ipset # # Set up to ensure tests run: # - Ensure unprivileged user namespaces enabled # - Install required kernel modules # - Get latest version of iprange from firehol project sudo sysctl kernel.unprivileged_userns_clone=1 sudo modprobe iptable_mangle sudo modprobe ip6table_mangle sudo modprobe iptable_raw sudo modprobe ip6table_raw sudo modprobe iptable_nat sudo modprobe ip6table_nat sudo modprobe iptable_filter sudo modprobe ip6table_filter orig=`pwd` mkdir iprange cd iprange curl -s -o json https://api.github.com/repos/firehol/iprange/releases/latest dl=$(sed -ne '/"browser_download_url":.*.tar.gz"/{s/.*"browser_download_url": *//;s/{.*//;s/",*//g;p;q}' json) if [ "$dl" = "" ] then echo "Could not find download for latest iprange" exit 1 fi curl -s -L -o iprange.tar.gz "$dl" if [ $? -ne 0 ] then echo "Could not download $dl" exit 1 else echo "Building $dl" fi mkdir build tar xfzC iprange.tar.gz build cd build/iprange* ./configure --disable-man sudo make install cd $orig rm -rf iprange
firehol/firehol
.github/workflows/setup.sh
Shell
gpl-2.0
1,260
protoc --plugin=protoc-gen-grpc=/usr/bin/grpc_python_plugin --proto_path=.. --grpc_out=. ../engine.proto protoc -I=.. --python_out=. ../engine.proto
centreon/centreon-engine
enginerpc/examples/gen_files.sh
Shell
gpl-2.0
149
#!/bin/bash # # Copyright (C) 2014 Nethesis S.r.l. # http://www.nethesis.it - [email protected] # # This script is part of NethServer. # # NethServer is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, # or any later version. # # NethServer is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with NethServer. If not, see <http://www.gnu.org/licenses/>. # set -e domain=`config get DomainName` groupName=$1 shift members=$1 shift if [ -z "${groupName}" ]; then echo "group name is missing!"; exit 1 fi if [ -z "${members}" ]; then echo "members argument is missing!"; exit 2 fi # Install custom templates, if missing: if ! [ -f /etc/e-smith/templates-custom/etc/postfix/main.cf/60helpdesk ]; then echo "Installing custom templates" rsync -Cav templates-custom/ /etc/e-smith/templates-custom/ fi if ! getent group "${groupName}"; then echo "Configuring group ${groupName}" # Create group with shared mail delivery and initialize configuration: db accounts set "${groupName}" "group" MailDeliveryType "shared" MailStatus "enabled" Members "${members}" Description "" config set helpdesk "configuration" FrontendAddress "${groupName}@${domain}" FrontendName '' GroupName "${groupName}" signal-event group-create-pseudonyms ${groupName} signal-event group-create ${groupName} perl -e ' use strict; use NethServer::MailServer; my $groupName = shift; my $imap = NethServer::MailServer->connectAclManager($groupName . "*vmail"); $imap->create("Sent"); $imap->setAcl("Sent", "\$" . $groupName, "lrs"); ' -- ${groupName} fi # Expand extra-templates: echo "Expanding templates" expand-template /etc/postfix/helpdesk_maps expand-template /etc/postfix/helpdesk_header.pcre echo "Signaling nethserver-mail-server-update event" signal-event nethserver-mail-server-update
DavidePrincipi/nethserver-mail-helpdesk
helpdesk_install.sh
Shell
gpl-2.0
2,228
#!/bin/bash # This script updates nodeJS sudo npm cache clean -f sudo npm install -g n sudo n stable echo "nodeJS:" node -v
th3mon/cli-scripts
linux/ubuntu-mate/node-upgrade.sh
Shell
gpl-2.0
125
#!/bin/sh conky -c ~/de-scripts/.conky_lft & conky -c ~/de-scripts/.conky_mid & conky -c ~/de-scripts/.conky_rht & conky -c ~/de-scripts/.conky_topl & #conky -c ~/de-scripts/.conky_topr &
fredsmithjr/de-scripts
launch_all_conky.sh
Shell
gpl-2.0
188
#!/bin/sh (echo "echo A && echo B || echo C && echo D" sleep 2 echo "(echo A && echo B) || (echo C && echo D)" #shows precedence operators sleep 2 echo "test -f /home../rshell.cpp && (echo C && echo D)" #shows precedence operators work with test and full rshell sleep 2) | ./bin/rshell
BabyBrian/rshell
tests/precedence_test.sh
Shell
gpl-2.0
287
# # Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 only, as # published by the Free Software Foundation. # # This code is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # version 2 for more details (a copy is included in the LICENSE file that # accompanied this code). # # You should have received a copy of the GNU General Public License version # 2 along with this work; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. # # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA # or visit www.oracle.com if you need additional information or have any # questions. # # @test # @summary (almost) all keytool behaviors # @author Weijun Wang # # This test is only executed on several platforms # # set a few environment variables so that the shell-script can run stand-alone # in the source directory if [ "${TESTSRC}" = "" ] ; then TESTSRC="." fi if [ "${TESTCLASSES}" = "" ] ; then TESTCLASSES="." fi if [ "${TESTJAVA}" = "" ] ; then echo "TESTJAVA not set. Test cannot execute." echo "FAILED!!!" exit 1 fi if [ "${COMPILEJAVA}" = "" ]; then COMPILEJAVA="${TESTJAVA}" fi find_one() { for TARGET_FILE in $@; do if [ -e "$TARGET_FILE" ]; then echo $TARGET_FILE return fi done } # set platform-dependent variables OS=`uname -s` case "$OS" in SunOS ) FS="/" LIBNAME="/usr/lib/mps/libsoftokn3.so" ;; Linux ) FS="/" ${TESTJAVA}${FS}bin${FS}java -XshowSettings:properties -version 2> allprop cat allprop | grep os.arch | grep 64 if [ "$?" != "0" ]; then LIBNAME=`find_one \ "/usr/lib/libsoftokn3.so" \ "/usr/lib/i386-linux-gnu/nss/libsoftokn3.so"` else LIBNAME=`find_one \ "/usr/lib64/libsoftokn3.so" \ "/usr/lib/x86_64-linux-gnu/nss/libsoftokn3.so"` fi ;; * ) echo "Will not run test on: ${OS}" exit 0; ;; esac if [ "$LIBNAME" = "" ]; then echo "Cannot find libsoftokn3.so" exit 1 fi ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . -XDignore.symbol.file \ ${TESTSRC}${FS}KeyToolTest.java || exit 10 NSS=${TESTSRC}${FS}..${FS}..${FS}pkcs11${FS}nss cp ${TESTSRC}${FS}p11-nss.txt . cp ${NSS}${FS}db${FS}cert8.db . cp ${NSS}${FS}db${FS}key3.db . cp ${NSS}${FS}db${FS}secmod.db . chmod u+w key3.db chmod u+w cert8.db echo | ${TESTJAVA}${FS}bin${FS}java -Dnss \ -Dnss.lib=${LIBNAME} \ KeyToolTest status=$? rm -f p11-nss.txt rm -f cert8.db rm -f key3.db rm -f secmod.db rm HumanInputStream*.class rm KeyToolTest*.class rm TestException.class exit $status
karianna/jdk8_tl
jdk/test/sun/security/tools/keytool/autotest.sh
Shell
gpl-2.0
3,023
#!/bin/sh sudo apt-get update -qq sudo apt-get install unzip -y cd $WERCKER_ROOT echo 'Downloading AppEngine SDK...' curl -s -o google_appengine.zip https://storage.googleapis.com/appengine-sdks/featured/google_appengine_1.9.15.zip sudo unzip -q google_appengine.zip -d /usr/local export PATH="$PATH:/usr/local/google_appengine" echo "$APP_ENGINE_PASS" > "$WERCKER_STEP_TEMP/password" echo "cleaning up" rm google_appengine.zip find . -name "*.pyc" -exec rm -rf {} \; echo 'Starting deployment of directory' cd $WERCKER_SOURCE_DIR appcfg.py update ./ --email="$APP_ENGINE_USER" --passin < "$WERCKER_STEP_TEMP/password" echo 'Finished'
FenrirUnbound/greg-ball
deploy.sh
Shell
gpl-2.0
640
#!/bin/bash # microfs - Minimally Improved Compressed Read Only File System # Copyright (C) 2012, 2013, 2014, 2015, 2016, 2017, ..., +%Y # Erik Edlund <[email protected]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. source "boilerplate.sh" script_path=`readlink -f "$0"` script_dir=`dirname "${script_path}"` top_dir=`dirname "${script_dir}"` if [[ $# -ne 2 || ! -d "$1" || ! ( "$2" =~ ^[0-9]+$ ) ]] ; then cat <<EOF Usage: `basename $0` dirname Test the statfs feature for microfs. EOF exit 1 fi workdir="$1" insid="$2" img_src="${workdir}/statfs" img_file="${img_src}.img" img_mount="${img_src}.mount" "mklndir.sh" "${img_src}" > /dev/null atexit_0 rm -rf "${img_src}" "${top_dir}/microfsmki" "${img_src}" "${img_file}" > /dev/null atexit_0 rm "${img_file}" mkdir "${img_mount}" atexit_0 rmdir "${img_mount}" eval "sudo mount -r -o loop -t microfs \"${img_file}\" \"${img_mount}\"" atexit sudo umount "${img_mount}" df -a "${img_mount}" > /dev/null eval "sudo dmesg | grep -P \" \[insid=${insid}\] microfs_statfs: ok\""
edlund/linux-microfs
tests/statfs.sh
Shell
gpl-2.0
1,705
#! /bin/sh . ../../testenv.sh for t in foo; do synth $t.vhdl -e $t > syn_$t.vhdl analyze syn_$t.vhdl done clean echo "Test successful"
tgingold/ghdl
testsuite/synth/issue1133/testsuite.sh
Shell
gpl-2.0
143
#!/usr/bin/env sh set -e -x # Build procServ using EPICS build system . "./.env" mkdir procServApp ls | grep -v procServApp | xargs mv -t procServApp EPICS_HOST_ARCH=`${EPICS_BASE}/startup/EpicsHostArch` ${EPICS_BASE}/bin/${EPICS_HOST_ARCH}/makeBaseApp.pl -t example dummy rm -fr dummyApp cat > configure/RELEASE.local << EOF EPICS_BASE=${EPICS_BASE} EOF ( cd procServApp; make; ./configure --with-epics-top=.. --disable-doc ) make
ralphlange/procServ
.ci/travis-epics-build.sh
Shell
gpl-3.0
440
cd ummisco.gama.annotations mvn -q clean install cd - cd msi.gama.processor mvn -q clean install cd - cd msi.gama.parent mvn -q clean install cd -
hqnghi88/gamaClone
build.sh
Shell
gpl-3.0
150
config() { NEW="$1" OLD="$(dirname $NEW)/$(basename $NEW .new)" # If there's no config file by that name, mv it over: if [ ! -r $OLD ]; then mv $NEW $OLD elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then # toss the redundant copy rm $NEW fi # Otherwise, we leave the .new copy for the admin to consider... } preserve_perms() { NEW="$1" OLD="$(dirname $NEW)/$(basename $NEW .new)" if [ -e $OLD ]; then cp -a $OLD ${NEW}.incoming cat $NEW > ${NEW}.incoming mv ${NEW}.incoming $NEW fi config $NEW } schema_install() { SCHEMA="$1" GCONF_CONFIG_SOURCE="xml::etc/gconf/gconf.xml.defaults" \ chroot . gconftool-2 --makefile-install-rule \ /etc/gconf/schemas/$SCHEMA \ 1>/dev/null } schema_install blah.schemas preserve_perms etc/rc.d/rc.INIT.new config etc/configfile.new if [ -x /usr/bin/update-desktop-database ]; then /usr/bin/update-desktop-database -q usr/share/applications >/dev/null 2>&1 fi if [ -x /usr/bin/update-mime-database ]; then /usr/bin/update-mime-database usr/share/mime >/dev/null 2>&1 fi # If other icon themes are installed, then add to/modify this as needed if [ -e usr/share/icons/hicolor/icon-theme.cache ]; then if [ -x /usr/bin/gtk-update-icon-cache ]; then /usr/bin/gtk-update-icon-cache -f usr/share/icons/hicolor >/dev/null 2>&1 fi fi if [ -e usr/share/glib-2.0/schemas ]; then if [ -x /usr/bin/glib-compile-schemas ]; then /usr/bin/glib-compile-schemas usr/share/glib-2.0/schemas >/dev/null 2>&1 fi fi # If needed -- be sure to sed @LIBDIR@ inside the build script chroot . /usr/bin/gio-querymodules @LIBDIR@/gio/modules/ 1> /dev/null 2> /dev/null if [ -x /usr/bin/install-info ]; then chroot . /usr/bin/install-info --info-dir=/usr/info /usr/info/blah.gz 2> /dev/null fi # WARNING # When upgradepkg is used, doinst.sh gets run twice. So don't put # anything here that takes a long time to run.
dslackw/sbo-templates
sbo_scripts_templates/doinst.sh
Shell
gpl-3.0
1,926
# Assertion types: # * expect_some_condition -- adds error to the test results, but continues the test # * assert_some_condition -- adds error to the test results and immediately stops the test # * assertlocal_some_condition -- adds error to the results and exits current subshell # (assert|assertlocal|expect)_program_installed <program>... assert_template_program_installed_() { for program in "$@"; do if ! is_program_installed "$program"; then $FAIL_FUNCTION "$program is not installed" fi done } # (assert|assertlocal|expect)_file_exists <file> assert_template_file_exists_() { if [[ ! -e "$1" ]]; then $FAIL_FUNCTION "File '$1' does not exist" fi } # (assert|assertlocal|expect)_file_not_exists <file> assert_template_file_not_exists_() { if [[ -e "$1" ]]; then $FAIL_FUNCTION "File '$1' does exist" fi } # (assert|assertlocal|expect)_files_equal <file1> <file2> assert_template_files_equal_() { local file1=$1 local file2=$2 if ! cmp "$file1" "$file2"; then $FAIL_FUNCTION "Files $file1 and $file2 are different" fi } # (assert|assertlocal|expect)_less_or_equal <number1> <number2> assert_template_less_or_equal_() { if (( $1 > $2 )); then $FAIL_FUNCTION "Expected: $1 <= $2" fi } # (assert|assertlocal|expect)_less_than <number1> <number2> assert_template_less_than_() { if (( $1 >= $2 )); then $FAIL_FUNCTION "Expected: $1 < $2" fi } # (assert|assertlocal|expect)_not_equal <string1> <string2> assert_template_not_equal_() { if [[ "$1" == "$2" ]]; then $FAIL_FUNCTION "Expected string different than $1" fi } # (assert|assertlocal|expect)_equals <expected_string> <actual_string> assert_template_equals_() { if [[ "$1" != "$2" ]]; then $FAIL_FUNCTION "Expected: $1, got: $2" fi } # (assert|assertlocal|expect)_matches <regex> <string> assert_template_matches_() { if [[ ! "$2" =~ $1 ]]; then $FAIL_FUNCTION "Expected: '$2' to match regex '$1'" fi } # (assert|assertlocal|expect)_near <expected_number> <actual_number> <max_absolute_error> assert_template_near_() { if ! (( $1 - $3 <= $2 && $2 <= $1 + $3 )); then $FAIL_FUNCTION "Expected: $1 +/- $3, got: $2" fi } # (assert|assertlocal|expect)_success <command> [<args>...] assert_template_success_() { local error_msg # a local variable for errors printed by <command> local fd # a local variable to hold a file descriptor exec {fd}>&1 # duplicate stdout to a descriptor and store its number in the 'fd' variable # Now run "$@" (the command under a test) in the following way: # - its stderr goes to the 'error_msg' variable # - its stdout goes to the current stdout (duplicated to $fd to make it available in a subshell) if ! error_msg=$("$@" 2>&1 1>&$fd); then $FAIL_FUNCTION "Command '$*' failed. Standard error:"$'\n'"$error_msg" fi exec {fd}>&- # close the descriptor stored in the 'fd' variable } # (assert|assertlocal|expect)_failure <command> [<args>...] assert_template_failure_() { if "$@"; then $FAIL_FUNCTION "Command '$*' succeeded" fi } # (assert|assertlocal|expect)_awk_finds <awk-condition> <string> assert_template_awk_finds_() { local condition=$1 local string=$2 local matches=$(awk "$condition" <<< "$string") local lines=$(awk "$condition" <<< "$string" | wc -l) if (( lines == 0 )); then $FAIL_FUNCTION "Expected line matching '$condition' to be found in:"$'\n'"$string" fi } # (assert|assertlocal|expect)_awk_finds_no <awk-condition> <string> assert_template_awk_finds_no_() { local condition=$1 local string=$2 local matches=$(awk "$condition" <<< "$string") local lines=$(awk "$condition" <<< "$string" | wc -l) if (( lines > 0 )); then local msg_header="Expected line matching '$condition' not to be found in:"$'\n'"$string" local msg_footer="But the following has been found:"$'\n'"$matches" $FAIL_FUNCTION "$msg_header"$'\n'"$msg_footer" fi } # (assert|assertlocal|expect)_no_diff <string1> <string2> assert_template_no_diff_() { local diff=$(diff -u5 <(echo -n "$1") <(echo -n "$2")) || true if [[ -n "$diff" ]]; then $FAIL_FUNCTION $'Strings are different:\n'"$diff" fi } # (assert|assertlocal|expect)_eventually <command> [<timeout>] assert_template_eventually_() { local command=$1 local timeout=$(rescale_timeout_for_assert_eventually_ "${2:-}") if ! wait_for "$command" "$timeout"; then $FAIL_FUNCTION "'$command' didn't succedd within $timeout" fi } # (assert|assertlocal|expect)_empty <string> assert_template_empty_() { if [[ -n $1 ]]; then if [[ $(wc -l <<< "$1") == 1 ]]; then $FAIL_FUNCTION "Expected empty string, got '$1'" else $FAIL_FUNCTION $'Expected empty string, got:\n'"$1" fi fi } # (assert|assertlocal|expect)_eventually_prints <string> <command> [<timeout>] assert_template_eventually_prints_() { local string=$1 local command=$2 local timeout=$(rescale_timeout_for_assert_eventually_ "${3:-}") if ! wait_for "[[ \$($command) == \"$string\" ]]" "$timeout"; then $FAIL_FUNCTION "'$command' didn't print '$string' within $timeout. "` `"It prints now: '$(eval "$command" || true)'" fi } # (assert|assertlocal|expect)_eventually_matches <regex> <command> [<timeout>] assert_template_eventually_matches_() { local regex="$1" local command="$2" local timeout=$(rescale_timeout_for_assert_eventually_ "${3:-}") if ! wait_for "[[ \$($command) =~ \$regex ]]" "$timeout"; then $FAIL_FUNCTION "'$command' didn't print output matching '$regex' within $timeout. "` `"It prints now: '$(eval "$command" || true)'" fi } # (assert|assertlocal|expect)_eventually_equals <command1> <command2> [<timeout>] assert_template_eventually_equals_() { local command1=$1 local command2=$2 local timeout=$(rescale_timeout_for_assert_eventually_ "${3:-}") if ! wait_for "[[ \$($command1) == \$($command2) ]]" "$timeout"; then diff="$(diff -u5 <(eval "$command1") <(eval "$command2") || true)" $FAIL_FUNCTION "'$command1' didn't output the same as '$command2' within $timeout` `"$'\n'"$diff" fi } # This function returns a line from some source file of this test suite test_absolute_path_=$(readlink -m .) get_source_line() { local file=$1 local line=$2 ( cd "$test_absolute_path_" ; sed -n "${line}s/^[[:blank:]]*//p" "$file" || true) } # Internal functions rescale_timeout_for_assert_eventually_() { if [[ -n "$1" ]]; then timeout_rescale "$1" else if valgrind_enabled; then echo 60 seconds else echo 15 seconds fi fi } create_error_message_() { local message=${MESSAGE:-} local call=$(get_source_line "$ASSERT_FILE" "$ASSERT_LINE") local assertion=$(grep -o "$ASSERT_NAME.*" <<< "$call" || true) if [[ $message ]]; then echo -n "$message: " fi if [[ $assertion ]]; then echo "Assertion '$assertion' failed" else echo "Assertion failed" fi echo "$*" echo "Location: $(basename "$ASSERT_FILE"):$ASSERT_LINE" echo "Backtrace:" # remove top 3 function calls from stack trace: create_error_message_, do_*_failed_, assert_template_* print_stack 3 } do_assert_failed_() { test_fail "$(create_error_message_ "$*")" } do_assertlocal_failed_() { test_add_failure "$(create_error_message_ "$*")" exit 1 } do_expect_failed_() { test_add_failure "$(create_error_message_ "$*")" } # Create expect/assert functions for all templates defined above for template in $(typeset -F | grep -o 'assert_template_.*_'); do for type in assert assertlocal expect; do function_name=$(echo $template | sed -re "s/assert_template_(.*)_/${type}_\1"/) context="ASSERT_NAME=$function_name ASSERT_FILE=\"\${BASH_SOURCE[1]}\" ASSERT_LINE=\${BASH_LINENO[0]}" body="export $context ; FAIL_FUNCTION=do_${type}_failed_ $template \"\$@\"" eval "$function_name() { $body ; }" done done unset function_name context body
onlyjob/lizardfs
tests/tools/assert.sh
Shell
gpl-3.0
7,700
#!/usr/bin/env bash # Reference: # runcommand of Retorpie: https://github.com/retropie/retropie-setup/wiki/runcommand # basic script: https://retropie.org.uk/forum/topic/3731/solved-variables-with-runcommand-onstart-sh/9 # edit and path: $ sudo nano /opt/retropie/configs/all/runcommand-onstart.sh # get the system name system=$1 # get the emulator name emul=$2 # get the full path filename of the ROM rom=$3 # rom_bn receives $rom excluding everything from the first char to the last slash '/' rom_bn="${rom##*/}" # rom_bn receives $rom_bn excluding everything from the last char to the first dot '.' #rom_bn="${rom_bn%.*}" # For English User # Display Game name to EmulationStation and CLCD from same gamelist.xml GAMELIST1="/home/pi/RetroPie/roms/${system}/gamelist.xml" GAMELIST2="/home/pi/.emulationstation/gamelists/${system}/gamelist.xml" # For 2Byte Language User(Korean, Japanese, etc..) # Display Game name to EmulationStation from gamelist.xml(Korean Game name) # Display Game name to CLCD from gamelist_en.xml(English Game name) #GAMELIST1="/home/pi/RetroPie/roms/${system}/gamelist_en.xml" #GAMELIST2="/home/pi/.emulationstation/gamelists/${system}/gamelist_en.xml" if [ -f ${GAMELIST1} ] then GAMELIST=${GAMELIST1} else GAMELIST=${GAMELIST2} fi title=`grep -A1 "${rom_bn}" ${GAMELIST} | awk '{getline;print}' | awk 'BEGIN {FS="<name>"} {print $2}' | awk 'BEGIN {FS="</name>"} {print $1}'` echo "$system" >&2 echo "$title" >&2 #echo "$rom_bn" >&2
hakjongholic/RetroPie-Clcd
runcommand-onstart.sh
Shell
gpl-3.0
1,471
#!/bin/bash # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # set -o xtrace # Trace a packet from sw0-port6 to sw0-port7. ovs-appctl ofproto/trace br-int in_port=6,dl_type=0x0800,dl_src=00:00:00:00:00:06,dl_dst=00:00:00:00:00:07,nw_src=192.168.1.10,nw_dst=192.168.1.20 -generate
ejschiller/FLEX
ovs/tutorial/ovn/env1/packet4.sh
Shell
gpl-3.0
781
#!/bin/bash set -e # set env variables if [ -n "$NSQLOOKUPD_PORT_4161_TCP_ADDR" ] && [ -n "$NSQLOOKUPD_PORT_4161_TCP_PORT" ]; then export LOOKUPD_ADDRESSES="http://${NSQLOOKUPD_PORT_4161_TCP_ADDR}:${NSQLOOKUPD_PORT_4161_TCP_PORT}" fi echo "LOOKUPD ADDRESSES: ${LOOKUPD_ADDRESSES}" # execute python application in unbuffered mode exec python -u email_service.py
clickberry/email-service-python
docker-entrypoint.sh
Shell
gpl-3.0
366
#!/bin/sh : "${LOGSTASH_PATH:?Need to set LOGSTASH_PATH non-empty}" : "${WEBSITE_PATH:?Need to set WEBSITE_PATH non-empty}" ${LOGSTASH_PATH}/bin/logstash -f ${WEBSITE_PATH}/logstash.conf
Vrixyz/website
scripts/start-logstash.sh
Shell
gpl-3.0
189
mkdir -p _orig/ for f in *.jpg; do cp -v $f _orig/ mogrify -geometry 600x $f done
icarito/arbio-azucar-adoptarbol
adoptarbol/static/images/common_trees/resize_images.sh
Shell
gpl-3.0
91
#!/bin/bash #define variables VER=$1 EXPLEN=45 TARCOV=0.30 #set up mkdir -p final_run_ver${VER} cd final_run_ver$VER cp ../final.ver${VER}.cons.mod cons.mod cp ../final.ver${VER}.noncons.mod noncons.mod mkdir -p logs mkdir -p ELEMENTS SCORES for INPUT in $(ls /n/regal/edwards_lab/ratites/wga/phast/final_mafs/split_all/*.ss) do BASE=${INPUT##*/} SAMP=${BASE%%.ss} phastCons --expected-length=$EXPLEN --target-coverage=$TARCOV --most-conserved ELEMENTS/$SAMP.bed --score --msa-format SS $INPUT cons.mod,noncons.mod 1> ./SCORES/$SAMP.wig 2> ./logs/$SAMP.log & done cd ..
tsackton/ratite-genomics
04_wga/02_ce_id/run_phastCons_local.sh
Shell
gpl-3.0
575
#!/bin/bash # put this in $HOME/bin as install.sh scriptpath=$HOME/proj/github.com/MythTV/packaging/deb-light set -e if [[ -f $HOME/.buildrc ]] ; then . $HOME/.buildrc fi # This will get projname and destdir . "$scriptpath/getdestdir.source" if [[ "$INSTALL_PREPARE" != "" ]] ; then $INSTALL_PREPARE fi case $projname in android) install_android.sh "$@" ;; mythtv) "$scriptpath/install.sh" "$@" gitbasedir=`git rev-parse --show-toplevel` if [[ -s $gitbasedir/../patch/build.patch ]] ; then cp -av $gitbasedir/../patch/build.patch $destdir/usr/share/mythtv/build.patch fi for file in $gitbasedir/../patch/Peter/${projname}_*.patch ; do if [[ -s "$file" ]] ; then cp -av "$file" $destdir/usr/share/mythtv/ fi done ;; *) "$scriptpath/install.sh" "$@" ;; esac if [[ "$INSTALL_DONE" != "" ]] ; then $INSTALL_DONE fi
bennettpeter/mythscripts
install/home/bin/install.sh
Shell
gpl-3.0
982
#!/bin/sh # SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) # # average.sh - a script to compute the average of traceshark processing time # Copyright (C) 2017, 2018 Viktor Rosendahl <[email protected]> # # This file is dual licensed: you can use it either under the terms of # the GPL, or the BSD license, at your option. # # a) This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, # MA 02110-1301 USA # # Alternatively, # # b) Redistribution and use in source and binary forms, with or # without modification, are permitted provided that the following # conditions are met: # # 1. Redistributions of source code must retain the above # copyright notice, this list of conditions and the following # disclaimer. # 2. Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials # provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # if [ ! $# -eq 1 ];then echo "Usage $0 <file>" exit 0 fi file=$1 average=$(cat $file|LC_NUMERIC="C" awk '/processTrace/ { sum+=$3;n++ } END {print sum/n}') minimum=$(cat $file|LC_NUMERIC="C" awk 'BEGIN {min=-1} $1~/processTrace/ && (min == -1 || $3 < min) { min=$3 } END {print min}') maximum=$(cat $file|LC_NUMERIC="C" awk 'BEGIN {max=-1} $1~/processTrace/ && (max == -1 || $3 > max) { max=$3 } END {print max}') st_average=$(cat $file|LC_NUMERIC="C" awk '/showTrace/ { sum+=$3;n++ } END {print sum/n}') st_minimum=$(cat $file|LC_NUMERIC="C" awk 'BEGIN {min=-1} $1~/showTrace/ && (min == -1 || $3 < min) { min=$3 } END {print min}') st_maximum=$(cat $file|LC_NUMERIC="C" awk 'BEGIN {max=-1} $1~/showTrace/ && (min == -1 || $3 > max) { max=$3 } END {print max}') tps_average=$(cat $file|LC_NUMERIC="C" awk '/tracePlot->show/ { sum+=$3;n++ } END {print sum/n}') tps_minimum=$(cat $file|LC_NUMERIC="C" awk 'BEGIN {min=-1} $1~/tracePlot->show/ && (min == -1 || $3 < min) { min=$3 } END {print min}') tps_maximum=$(cat $file|LC_NUMERIC="C" awk 'BEGIN {max=-1} $1~/tracePlot->show/ && (max == -1 || $3 > max) { max=$3 } END {print max}') echo "\nprocessTrace():" echo "minimum = "$minimum echo "average = "$average echo "maximum = "$maximum echo "\n" echo "showTrace():" echo "show trace minimum = "$st_minimum echo "show trace average = "$st_average echo "show trace maximum = "$st_maximum echo "\n" echo "tracePlot->show():" echo "show trace minimum = "$tps_minimum echo "show trace average = "$tps_average echo "show trace maximum = "$tps_maximum echo "\n"
cunctator/traceshark
scripts/stats.sh
Shell
gpl-3.0
4,130
#!/bin/bash # Criado por Franky Weber Faust 14/02/2015 # Adaptado de Erik Ljungstrom 27/05/2011 # http://loredata.com.br # Apresenta o consumo de swap em KB por PID SUM=0 OVERALL=0 for DIR in `find /proc/ -maxdepth 1 -type d -regex "^/proc/[0-9]+"` do PID=`echo $DIR | cut -d / -f 3` PROGNAME=`ps -p $PID -o comm --no-headers` for SWAP in `grep Swap $DIR/smaps 2>/dev/null | awk '{ print $2 }'` do let SUM=$SUM+$SWAP done if (( $SUM > 0 )); then echo "PID=$PID swapped $SUM KB ($PROGNAME)" fi let OVERALL=$OVERALL+$SUM SUM=0 done echo "Overall swap used: $OVERALL KB"
FrankyWeber/golden-scripts
check_swap_by_pid.sh
Shell
gpl-3.0
621
#builds the linux docker image for a java env incl ssh docker build -t linuxjavassh .
svenwillmann/docker
linuxjavassh/build-image.sh
Shell
gpl-3.0
88
#!/bin/bash # Arch Linux installation script PART 1/3 v0.2.3 - PARTITIONING & BASE SYSTEM INSTALL # Created by Colin Matthews loadkeys uk.map.gz # Set Keyboard to UK **CHANGE THIS TO YOUR KEYBOARD'S KEYMAP** grep --no-group-separator -A1 "United Kingdom" /etc/pacman.d/mirrorlist > /mirrorlist cat /mirrorlist > /etc/pacman.d/mirrorlist # Update mirror list to only UK mirrors for live CD system **CHANGE THIS TO YOUR REGION AS LISTED IN /mirrorlist** # Welcome message clear cat<<EOF INTRODUCTION ========================================================================== Arch Linux installation script v0.2.3 ------------------------------------- This install script will help make installing Arch Linux on your computer much simpler. The base system will be installed on an encrypted volume with networking enabled. EFI/BIOS will be detected and installed based on how this Live CD has been booted. Installation is mainly autonomous, but you will be asked for input where necessary. Installation should not take any longer than 20 minutes with a reasonable internet connection and PC. Wireless setup support is available for notebook installations, although testing for notebooks has been minimal thus far. You will have a choice to install a desktop environment, but this step is optional. If you want to install a desktop environment that is not listed, when prompted to install a desktop environment, select 'No desktop environment' and you will be returned to the CLI to proceed as you wish. ========================================================================== Please press any key to continue. EOF read -r -n 1 # Set Wifi connection (optional) clear WLAN=$(ls /sys/class/net/ | grep '^wl') if [[ ! -z $WLAN ]] ; then while :; do cat<<EOF WIRELESS NETWORK SETUP ========================================================================== Select 'y' if you would like to setup a wireless connection for this installation. Select 'n' if you will not be using wifi or have already set it up. ========================================================================== Will you be using Wifi for this installation? (y/n) EOF read -n1 -s -r clear case "$REPLY" in "y") wifi-menu -o;; "n") break;; *) echo "Invalid option, please try again." sleep 2;; esac done fi clear cat<<EOF DISK PARTITIONING ========================================================================== Please take note of the below list of devices and any existing partitions as you will need this information to decide how to setup your partitions in the next step. ========================================================================== EOF lsblk # Show current partition state echo "" echo "Please press any key to continue." read -r -n 1 clear while :; do cat<<EOF DISK PARTITIONING ========================================================================== !!WARNING!! Choosing automatic partitioning assumes that /dev/sda or /dev/nvme0n1 should be used for installing Arch Linux and will remove any existing partitions on that disk. This is the simplest but most destructive option. Choosing to not partition anything will allow you choose where to install EFI, boot and data files, but only the data drive will be formatted. This is recommended for dual booting with an existing OS. -------------------------------------------------------------------------- In all instances the data volume will be encrypted to increase the security of your installation. It is recommended to use a strong password. ========================================================================== Please select a partitioning method: Option (1) - Automatic partitioning on drive "sda" --Quick and destructive, wipes all data on /dev/sda-- Option (2) - Automatic partitioning for NVME M.2 SSDs --Quick and destructive, wipes all data on /dev/nvme0n1-- Option (3) - Manual partitioning --Allows customisation of partitions using cgdisk-- Option (4) - No partitioning needed --Recommended only if all necessary partitions are setup and unused-- Option (5) - Reinstall Arch Linux installed by this script --Does not modify the EFI/Boot partitions-- EOF read -n1 -s -r case "$REPLY" in "1") # Option 1 for automatic sda install if [[ -e /sys/firmware/efi && -e /dev/sda ]]; then # Check if EFI is present and /dev/sda exists so that this option can be implemented parted -s /dev/sda mklabel gpt # Make GPT and remove all current partitions parted -s /dev/sda mkpart ESP fat32 2048s 100MiB # 1 100MB EFI partition parted -s /dev/sda set 1 boot on parted -s /dev/sda mkpart primary ext2 100MiB 350MiB # 2 250MB boot partition parted -s /dev/sda mkpart primary ext4 350MiB 100% # 3 100% size partiton (to be encrypted) mkfs.vfat -F32 /dev/sda1 # Apply file system structures to the EFI and boot partitions mkfs.ext2 /dev/sda2 clear echo "Encrypted volume password creation" echo "==========================================================================" echo "" cryptsetup -c aes-xts-plain64 -y --use-random luksFormat /dev/sda3 # Setup the encryption of the system partition clear echo "Encrypted volume password entry" echo "==========================================================================" echo "" cryptsetup luksOpen /dev/sda3 crypt # Open encrypted partition clear pvcreate /dev/mapper/crypt vgcreate vg0 /dev/mapper/crypt # Create encrypted volume group and the system/swap partitions within lvcreate --size 1G vg0 --name swap lvcreate -l +100%FREE vg0 --name root mkfs.ext4 /dev/mapper/vg0-root # Create filesystems on encrypted partitions mkswap /dev/mapper/vg0-swap mount /dev/mapper/vg0-root /mnt # Mount the new system partitions swapon /dev/mapper/vg0-swap mkdir /mnt/boot mount /dev/sda2 /mnt/boot mkdir /mnt/boot/efi mount /dev/sda1 /mnt/boot/efi wget https://raw.githubusercontent.com/colinjmatt/archlinuxautomation/master/arch-linux-chroot-install.sh -P /mnt/ # Download part 2 ready to start in chroot sed -i "s/SDX3=/SDX3=sda3/g" /mnt/arch-linux-chroot-install.sh # Amend script entry so GRUB knows about the encrypted volume clear echo "Partitioning complete. Installing base system..." sleep 1 pacstrap /mnt base base-devel grub-efi-x86_64 efibootmgr wpa_supplicant dialog openssh wget # EFI - wget necessary to download script 3, dialog for wifi-menu elif [[ ! -e /sys/firmware/efi && -e /dev/sda ]]; then # Check if no EFI present and implement boot partition only parted -s /dev/sda mklabel msdos # Make MBR and remove all current partitions parted -s /dev/sda mkpart primary ext2 2048s 250MiB # 1 250MB boot partition parted -s /dev/sda set 1 boot on parted -s /dev/sda mkpart primary ext4 250MiB 100% # 2 100% size partiton (to be encrypted) mkfs.ext2 /dev/sda1 # Apply file system structures to the boot partition clear echo "Encrypted volume password creation" echo "==========================================================================" cryptsetup -c aes-xts-plain64 -y --use-random luksFormat /dev/sda2 # Setup the encryption of the system partition clear echo "Encrypted volume password entry" echo "==========================================================================" echo "" cryptsetup luksOpen /dev/sda2 crypt # Open encrypted partition clear pvcreate /dev/mapper/crypt vgcreate vg0 /dev/mapper/crypt # Create encrypted volume group and the system/swap partitions within lvcreate --size 1G vg0 --name swap lvcreate -l +100%FREE vg0 --name root mkfs.ext4 /dev/mapper/vg0-root # Create filesystems on encrypted partitions mkswap /dev/mapper/vg0-swap mount /dev/mapper/vg0-root /mnt # Mount the new partitions swapon /dev/mapper/vg0-swap mkdir /mnt/boot mount /dev/sda1 /mnt/boot wget https://raw.githubusercontent.com/colinjmatt/archlinuxautomation/master/arch-linux-chroot-install.sh -P /mnt/ # Download part 2 ready to start in chroot sed -i "s/SDX3=/SDX3=sda2/g" /mnt/arch-linux-chroot-install.sh # Amend script entry so GRUB knows about the encrypted volume clear echo "Partitioning complete. Installing base system..." sleep 1 pacstrap /mnt base base-devel grub-bios wpa_supplicant dialog openssh wget # BIOS - wget necessary to download script 3, dialog for wifi-menu else # Return error if /dev/sda does not exist echo "" echo "Error: Device /dev/sda not detected" echo "You should probably use 'fdisk -l' or 'lsblk' to find out why" echo "" echo "Press any key to exit." echo "" read -n1 -s -r exit 1 fi if # Check all partitions exist [[ -e /dev/sda1 && -e /dev/sda2 && -e /dev/sda3 ]]; then break elif [[ -e /dev/sda1 && -e /dev/sda2 && ! -e /sys/firmware/efi ]]; then break else # Return error if one or more partitions are missing echo "" echo "Error: Not all partitions have been created correctly." echo "" echo "Press any key to retry partitioning, or Ctrl-Z to exit." echo "" read -n1 -s -r continue fi break;; "2") # Option 2 for automatic NVMe install if [[ -e /sys/firmware/efi && -e /dev/nvme0n1 ]]; then # Check if EFI is present and /dev/nvme0n1 exists so that this option can be implemented parted -s /dev/nvme0n1 mklabel gpt # Make GPT and remove all current partitions parted -s /dev/nvme0n1 mkpart ESP fat32 2048s 100MiB # 1 100MB EFI partition parted -s /dev/nvme0n1 set 1 boot on parted -s /dev/nvme0n1 mkpart primary ext2 100MiB 350MiB # 2 250MB boot partition parted -s /dev/nvme0n1 mkpart primary ext4 350MiB 100% # 3 100% size partiton (to be encrypted) mkfs.vfat -F32 /dev/nvme0n1p1 # Apply file system structures to the EFI and boot partitions mkfs.ext2 /dev/nvme0n1p2 clear echo "Encrypted volume password creation" echo "==========================================================================" echo "" cryptsetup -c aes-xts-plain64 -y --use-random luksFormat /dev/nvme0n1p3 # Setup the encryption of the system partition clear echo "Encrypted volume password entry" echo "==========================================================================" echo "" cryptsetup luksOpen /dev/nvme0n1p3 crypt # Open encrypted partition clear pvcreate /dev/mapper/crypt vgcreate vg0 /dev/mapper/crypt # Create encrypted volume group and the system/swap partitions within lvcreate --size 1G vg0 --name swap lvcreate -l +100%FREE vg0 --name root mkfs.ext4 /dev/mapper/vg0-root # Create filesystems on encrypted partitions mkswap /dev/mapper/vg0-swap mount /dev/mapper/vg0-root /mnt # Mount the new system partitions swapon /dev/mapper/vg0-swap mkdir /mnt/boot mount /dev/nvme0n1p2 /mnt/boot mkdir /mnt/boot/efi mount /dev/nvme0n1p1 /mnt/boot/efi wget https://raw.githubusercontent.com/colinjmatt/archlinuxautomation/master/arch-linux-chroot-install.sh -P /mnt/ # Download part 2 ready to start in chroot sed -i "s/SDX3=/SDX3=nvme0n1p3/g" /mnt/arch-linux-chroot-install.sh # Amend script entry so GRUB knows about the encrypted volume touch /mnt/nvmeflag clear echo "Partitioning complete. Installing base system..." sleep 1 pacstrap /mnt base base-devel grub-efi-x86_64 efibootmgr wpa_supplicant dialog openssh wget # EFI - wget necessary to download script 3, dialog for wifi-menu elif [[ ! -e /sys/firmware/efi && -e /dev/nvme0n1 ]]; then # Check if no EFI present and implement boot partition only parted -s /dev/nvme0n1 mklabel msdos # Make MBR and remove all current partitions parted -s /dev/nvme0n1 mkpart primary ext2 2048s 250MiB # 1 250MB boot partition parted -s /dev/nvme0n1 set 1 boot on parted -s /dev/nvme0n1 mkpart primary ext4 250MiB 100% # 2 100% size partiton (to be encrypted) mkfs.ext2 /dev/nvme0n1p1 # Apply file system structures to the boot partition clear echo "Encrypted volume password creation" echo "==========================================================================" cryptsetup -c aes-xts-plain64 -y --use-random luksFormat /dev/nvme0n1p2 # Setup the encryption of the system partition clear echo "Encrypted volume password entry" echo "==========================================================================" echo "" cryptsetup luksOpen /dev/nvme0n1p2 crypt # Open encrypted partition clear pvcreate /dev/mapper/crypt vgcreate vg0 /dev/mapper/crypt # Create encrypted volume group and the system/swap partitions within lvcreate --size 1G vg0 --name swap lvcreate -l +100%FREE vg0 --name root mkfs.ext4 /dev/mapper/vg0-root # Create filesystems on encrypted partitions mkswap /dev/mapper/vg0-swap mount /dev/mapper/vg0-root /mnt # Mount the new partitions swapon /dev/mapper/vg0-swap mkdir /mnt/boot mount /dev/nvme0n1p1 /mnt/boot wget hhttps://raw.githubusercontent.com/colinjmatt/archlinuxautomation/master/arch-linux-chroot-install.sh -P /mnt/ # Download part 2 ready to start in chroot sed -i "s/SDX3=/SDX3=nvme0n1p2/g" /mnt/arch-linux-chroot-install.sh # Amend script entry so GRUB knows about the encrypted volume touch /mnt/nvmeflag clear echo "Partitioning complete. Installing base system..." sleep 1 pacstrap /mnt base base-devel grub-bios wpa_supplicant dialog openssh wget # BIOS - wget necessary to download script 3, dialog for wifi-menu else # Return error if /dev/nvme0n1 does not exist echo "" echo "Error: Device /dev/nvme0n1 not detected" echo "You should probably use 'fdisk -l' or 'lsblk' to find out why" echo "" echo "Press any key to exit." echo "" read -n1 -s -r exit 1 fi if # Check all partitions exist [[ -e /dev/nvme0n1p1 && -e /dev/nvme0n1p2 && -e /dev/nvme0n1p3 ]]; then break elif [[ -e /dev/nvme0n1p1 && -e /dev/nvme0n12 && ! -e /sys/firmware/efi ]]; then break else # Return error if one or more partitions are missing echo "" echo "Error: Not all partitions have been created correctly." echo "" echo "Press any key to retry partitioning, or Ctrl-Z to exit." echo "" read -n1 -s -r continue fi break;; "3") # Option 3 for manual partitioning clear lsblk # Show current partition state cat<<EOF You are about to create the partitions for your installation ========================================================================== This partitioning wizard is only designed to setup the following: 1 partition for EFI (e.g. sda1). The recommended setup is a 100MB partition with a hex code of 'ef00'. --Above partition utilised only when using UEFI USB boot method-- 1 partition for the boot image (e.g. sda2). The recommended setup is a 250MB partition with a hex code of '8300'. 1 partition for data (e.g. sda3), which will contain your OS and needs to be a sufficient size for the main installation and a 2GB swap file. It is recommended to use a hex code of '8300'. Any other partitions must be created after setup. ========================================================================== Select the disk you wish to use for the installation (e.g. /dev/sda)" EOF cgdisk # Interactive partition manager for user to make their own partition system if [[ -e /sys/firmware/efi ]]; then clear echo "" echo "File systems will be created now." echo "" lsblk # Show current partition state # Select which partion is to be used for EFI if it is being used SDX1="$1" if [[ -z "$SDX1" ]]; then echo "" echo -n "Please enter the name of the EFI partition (e.g. sda1): " read -r SDX1 < /dev/tty fi clear echo "" echo "File systems will be created now." echo "" lsblk # Show current partition state # Select which partion is to be used for boot SDX2="$1" if [[ -z "$SDX2" ]]; then echo "" echo -n "Please enter the name of the boot partition (e.g. sda2): " read -r SDX2 < /dev/tty fi clear echo "" echo "File systems will be created now." echo "" lsblk # Show current partition state # Select which partion is to be encrypted and used for system SDX3="$1" if [[ -z "$SDX3" ]]; then echo "" echo -n "Please enter the name of the partition that will be encrypted and used for the system install (e.g. sda3): " read -r SDX3 < /dev/tty fi elif [[ ! -e /sys/firmware/efi ]]; then clear echo "" echo "File systems will be created now." echo "" lsblk # Show current partition state # Select which partion is to be used for boot SDX2="$1" if [[ -z "$SDX2" ]]; then echo "" echo -n "Please enter the name of the boot partition (e.g. sda1): " read -r SDX2 < /dev/tty fi clear echo "" echo "File systems will be created now." echo "" lsblk # Show current partition state # Select which partion is to be encrypted and used for system SDX3="$1" if [[ -z "$SDX3" ]]; then echo "" echo -n "Please enter the name of the partition that will be encrypted and used for the system install (e.g. sda2): " read -r SDX3 < /dev/tty fi fi # Display file system to summarise what has been created and confirm user wants to proceed clear echo "Below is a summary of all current partitions on all disks:" echo "" lsblk # Show current partition state echo "==========================================================================" if [[ -e /sys/firmware/efi ]]; then echo "/dev/$SDX1 will be used for EFI" echo "" fi echo "/dev/$SDX2 will be used for boot" echo "" echo "/dev/$SDX3 will be encrypted and used for data" echo "==========================================================================" echo "" echo "Is this configuration correct? (y/n)" echo "" read -n1 -s -r case "$REPLY" in "y") if [[ -e /sys/firmware/efi ]]; then mkfs.vfat -F32 /dev/"$SDX1" # FAT32 for EFI mkfs.ext2 /dev/"$SDX2" # EXT2 for boot elif [[ ! -e /sys/firmware/efi ]]; then mkfs.vfat -F32 /dev/"$SDX2" # FAT32 for boot fi clear echo "Encrypted volume password creation" echo "==========================================================================" echo "" cryptsetup -c aes-xts-plain64 -y --use-random luksFormat /dev/"$SDX3" # Setup the encryption of the system partition clear echo "Encrypted volume password entry" echo "==========================================================================" echo "" cryptsetup luksOpen /dev/"$SDX3" crypt # Open encrypted partition pvcreate /dev/mapper/crypt vgcreate vg0 /dev/mapper/crypt # Create encrypted volume group and the system/swap partitions within lvcreate --size 2G vg0 --name swap lvcreate -l +100%FREE vg0 --name root mkfs.ext4 /dev/mapper/vg0-root # Create filesystems on encrypted partitions mkswap /dev/mapper/vg0-swap mount /dev/mapper/vg0-root /mnt # Mount the new partitions swapon /dev/mapper/vg0-swap if [[ -e /sys/firmware/efi ]]; then mkdir /mnt/boot mount /dev/"$SDX2" /mnt/boot mkdir /mnt/boot/efi mount /dev/"$SDX1" /mnt/boot/efi elif [[ ! -e /sys/firmware/efi ]]; then mkdir /mnt/boot mount /dev/"$SDX2" /mnt/boot fi wget https://raw.githubusercontent.com/colinjmatt/archlinuxautomation/master/rchinstall2.sh -P /mnt/ # Download part 2 ready to start in chroot sed -i "s/SDX3=/SDX3=""$SDX3""/g" /mnt/arch-linux-chroot-install.sh # Amend script entry so GRUB knows about the encrypted volume clear echo "Partitioning complete. Installing base system..." sleep 1 if [[ -e /sys/firmware/efi ]]; then pacstrap /mnt base base-devel grub-efi-x86_64 efibootmgr wpa_supplicant dialog openssh wget # EFI - wget necessary to download script 3, dialog for wifi-menu elif [[ ! -e /sys/firmware/efi ]]; then pacstrap /mnt base base-devel grub-bios wpa_supplicant dialog openssh wget # BIOS - wget necessary to download script 3, dialog for wifi-menu fi break;; "n") echo "Returning to the partitioning menu." umount -R /mnt sleep 2 continue;; "*") echo "Invalid option, please try again." sleep 2;; esac;; "4") # Option 4 for if partitions already exist, but are empty if [[ -e /sys/firmware/efi ]]; then clear echo "" echo "File systems will be created now." echo "" lsblk # Show current partition state # Select which partion is to be used for EFI SDX1="$1" if [[ -z "$SDX1" ]]; then echo "" echo -n "Please enter the name of the EFI partition (e.g. sda1): " read -r SDX1 < /dev/tty fi clear echo "" echo "File systems will be created now." echo "" # Select which partion is to be used for boot lsblk # Show current partition state SDX2="$1" if [[ -z "$SDX2" ]]; then echo "" echo -n "Please enter the name of the boot partition (e.g. sda2): " read -r SDX2 < /dev/tty fi clear echo "" echo "File systems will be created now." echo "" # Select which partion is to be encrypted and used for system lsblk # Show current partition state SDX3="$1" if [[ -z "$SDX3" ]]; then echo "" echo -n "Please enter the name of the partition that will be encrypted and used for the system install (e.g. sda3): " read -r SDX3 < /dev/tty fi elif [[ ! -e /sys/firmware/efi ]]; then clear echo "" echo "File systems will be created now." echo "" # Select which partion is to be used for boot lsblk # Show current partition state SDX2="$1" if [[ -z "$SDX2" ]]; then echo "" echo -n "Please enter the name of the boot partition (e.g. sda1): " read -r SDX2 < /dev/tty fi clear echo "" echo "File systems will be created now." echo "" # Select which partion is to be encrypted and used for system lsblk # Show current partition state SDX3="$1" if [[ -z "$SDX3" ]]; then echo "" echo -n "Please enter the name of the partition that will be encrypted and used for the system install (e.g. sda2): " read -r SDX3 < /dev/tty fi fi clear echo "Encrypted volume password creation" echo "==========================================================================" echo "" cryptsetup -c aes-xts-plain64 -y --use-random luksFormat /dev/"$SDX3" # Setup the encryption of the system partition clear echo "Encrypted volume password entry" echo "==========================================================================" echo "" cryptsetup luksOpen /dev/"$SDX3" crypt # Open encrypted partition clear pvcreate /dev/mapper/crypt vgcreate vg0 /dev/mapper/crypt # Create encrypted volume group and the system/swap partitions within lvcreate --size 2G vg0 --name swap lvcreate -l +100%FREE vg0 --name root mkfs.ext4 /dev/mapper/vg0-root # Create filesystems on encrypted partitions mkswap /dev/mapper/vg0-swap mount /dev/mapper/vg0-root /mnt # Mount the new partitions swapon /dev/mapper/vg0-swap if [[ -e /sys/firmware/efi ]]; then mkdir /mnt/boot mount /dev/"$SDX2" /mnt/boot mkdir /mnt/boot/efi mount /dev/"$SDX1" /mnt/boot/efi elif [[ ! -e /sys/firmware/efi ]]; then mkdir /mnt/boot mount /dev/"$SDX2" /mnt/boot fi wget https://raw.githubusercontent.com/colinjmatt/archlinuxautomation/master/arch-linux-chroot-install.sh -P /mnt/ # Download part 2 ready to start in chroot sed -i s/SDX3=/SDX3="$SDX3"/g /mnt/arch-linux-chroot-install.sh # Amend script entry so GRUB knows about the encrypted volume clear echo "Partitioning complete. Installing base system..." sleep 1 if [[ -e /sys/firmware/efi ]]; then pacstrap /mnt base base-devel grub-efi-x86_64 efibootmgr wpa_supplicant dialog openssh wget # EFI - wget necessary to download script 3, dialog for wifi-menu elif [[ ! -e /sys/firmware/efi ]]; then pacstrap /mnt base base-devel grub-bios wpa_supplicant dialog openssh wget # BIOS - wget necessary to download script 3, dialog for wifi-menu fi break;; "5") # Option 5 for reinstalling Arch wihtout modifying the UEFI or Boot partitions if [[ -e /sys/firmware/efi ]]; then clear echo "" echo "Identify partitions." echo "" lsblk # Show current partition state # Select which partion is to be used for Boot SDX1="$1" if [[ -z "$SDX1" ]]; then echo "" echo -n "Please enter the name of the EFI partition (e.g. sda1): " read -r SDX1 < /dev/tty fi clear echo "" echo "Identify partitions." echo "" lsblk # Show current partition state # Select which partion is to be used for Root SDX2="$1" if [[ -z "$SDX2" ]]; then echo "" echo -n "Please enter the name of the boot partition (e.g. sda2): " read -r SDX2 < /dev/tty fi clear echo "" echo "Identify partitions." echo "" lsblk # Show current partition state # Select which partion is to be used for EFI SDX3="$1" if [[ -z "$SDX3" ]]; then echo "" echo -n "Please enter the name of the encrypted partition that Arch Linux will be reinstalled on (e.g. sda2): " read -r SDX3 < /dev/tty fi elif [[ ! -e /sys/firmware/efi ]]; then clear echo "" echo "Identify partitions." echo "" lsblk # Show current partition state # Select which partion is to be used for Boot SDX2="$1" if [[ -z "$SDX2" ]]; then echo "" echo -n "Please enter the name of the boot partition (e.g. sda1): " read -r SDX2 < /dev/tty fi clear echo "" echo "Identify partitions." echo "" lsblk # Show current partition state # Select which partion is to be used for Root SDX3="$1" if [[ -z "$SDX3" ]]; then echo "" echo -n "Please enter the name of the encrypted partition that Arch Linux will be reinstalled on (e.g. sda2): " read -r SDX3 < /dev/tty fi fi clear echo "Encrypted volume password entry" echo "==========================================================================" echo "" cryptsetup luksOpen /dev/"$SDX3" crypt # Open encrypted partition clear mkfs.ext4 /dev/mapper/vg0-root # Wipes the encrypted partitions mount /dev/mapper/vg0-root /mnt # Mount the encrypted partition swapon /dev/mapper/vg0-swap if [[ -e /sys/firmware/efi ]]; then echo "Mounting existing partitions and installing base system....." sleep 1 mkdir /mnt/boot mkdir /mnt/boot/efi pacstrap /mnt base base-devel grub-efi-x86_64 efibootmgr wpa_supplicant dialog openssh wget # EFI - wget necessary to download script 3, dialog for wifi-menu rm -fr /mnt/boot/{*,.*} mount /dev/"$SDX2" /mnt/boot mount /dev/"$SDX1" /mnt/boot/efi elif [[ ! -e /sys/firmware/efi ]]; then echo "Mounting existing partitions and installing base system....." mkdir /mnt/boot pacstrap /mnt base base-devel grub-bios wpa_supplicant dialog openssh wget # BIOS - wget necessary to download script 3, dialog for wifi-menu rm -fr /mnt/boot/{*,.*} mount /dev/"$SDX2" /mnt/boot fi touch /mnt/reinstallflag wget https://raw.githubusercontent.com/colinjmatt/archlinuxautomation/master/arch-linux-chroot-install.sh -P /mnt/ # Download part 2 ready to start in chroot sed -i s/SDX3=/SDX3="$SDX3"/g /mnt/arch-linux-chroot-install.sh # Amend script entry so GRUB knows about the encrypted volume clear echo "All mounts active and reinstallation of base system complete." sleep 2 break;; "*") echo "Invalid option, please try again." sleep 2;; esac done cp /mirrorlist /mnt/etc/pacman.d/mirrorlist # Update mirror list to only UK for newly installed system genfstab -pU /mnt >> /mnt/etc/fstab # Generate /etc/fstab for currently mounted volumes echo "tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0" >> /mnt/etc/fstab # Make /tmp a ramdisk (add the following line to /mnt/etc/fstab) arch-chroot /mnt /bin/bash "/arch-linux-chroot-install.sh" # Enter the new system and run the second part of the install rm /mnt/arch-linux-chroot-install.sh # Remove install script part 2 as it is no longer needed umount -R /mnt # Unmount all of the new systems partitions swapoff -a # Unmount swap reboot # Reboot system
colinjmatt/archlinuxautomation
arch-linux-base-install.sh
Shell
gpl-3.0
35,553
#!/bin/bash PROBLEM=toh LOG_DIR=~/log ivASP_LOG_DIR=$LOG_DIR/ivASP/$PROBLEM iclingo_LOG_DIR=$LOG_DIR/iclingo/$PROBLEM for f in instances/* do name=`basename $f` echo '-------------------------------------' echo $name echo '#####################################' tail -n 6 "$ivASP_LOG_DIR/$name.txt" echo '+++++++++++++++++' tail -n 6 "$iclingo_LOG_DIR/$name.txt" done echo '-------------------------------------'
lilac/iASP
benchmark/towersofhanoi/compare.sh
Shell
gpl-3.0
443
# Dictionary # From: http://www.64bitjungle.com/linux/some-really-useful-linux-command-line-tricks/ dict() { curl -s dict://dict.org/d:$1 | grep -v '^2[0,2,5]' }
tlvince/lib-bash
dictionary.sh
Shell
gpl-3.0
166
#!/bin/sh -x if [ "$(/usr/bin/whoami)" != 'root' ]; then echo "This script must be executed as root" exit 1 fi cp -f rq.service /etc/systemd/system/ cp -f rq.socket /etc/systemd/system/ cp -f tmpfiles.d-rq.conf /etc/tmpfiles.d/ systemd-tmpfiles --create systemctl enable rq.service systemctl enable rq.socket if [ "$(hostname)" == "localhost.localdomain" ]; then ln -s httpd.conf /etc/httpd/conf.d/00_rq.conf else cp -f httpd-production.conf /etc/apache2/conf.d/userdata/ssl/2_4/rq/rq.annvix.ca/flask.conf fi if [ "$(grep -q rq /etc/crontab >/dev/null 2>&1; echo $?)" == "1" ]; then # cat cron >>/etc/crontab echo "Be sure to update /etc/crontab!" fi
vdanen/rq
config/install.sh
Shell
gpl-3.0
679
#!/usr/bin/env bash # Install Anaconda if [[ "$ANACONDA_PYTHON_VERSION" == "2.7" ]]; then export CONDA_VERSION=2; else export CONDA_VERSION=3; fi if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export CONDA_OS=MacOSX; else export CONDA_OS=Linux; fi wget https://repo.continuum.io/miniconda/Miniconda${CONDA_VERSION}-latest-${CONDA_OS}-x86_64.sh -O miniconda.sh; bash miniconda.sh -b -p $HOME/miniconda export PATH="$HOME/miniconda/bin:$PATH" hash -r conda config --set always_yes yes --set changeps1 no conda update -q conda conda create -q -n test-environment python=$ANACONDA_PYTHON_VERSION source activate test-environment
samuelstjean/nlsam
build_stuff/get_conda.sh
Shell
gpl-3.0
644
######################################### # GNU GPL License v3 # # Author: Amir Yahyavi # ######################################### #!/bin/bash source config.sh source utils.sh set -o xtrace source config.sh &> config.properties set +o xtrace tail -n +2 config.properties > temp.txt; mv temp.txt config.properties cat config.properties | sed s/+//g | sed -e 's/^[ \t]*//' > temp.txt ; mv temp.txt config.properties head -n -1 config.properties > temp.txt ; mv temp.txt config.properties echo "datafiles=(${datafiles[@]})" >> config.properties cat config.properties mv config.properties $solrj_path
yahyavi/solrcloud
scripts/genprop.sh
Shell
gpl-3.0
640
err() { ALL_OFF="\e[1;0m" BOLD="\e[1;1m" RED="${BOLD}\e[1;31m" local mesg=$1; shift printf "${RED}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } msg() { ALL_OFF="\e[1;0m" BOLD="\e[1;1m" GREEN="${BOLD}\e[1;32m" local mesg=$1; shift printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } check_pkgs() { local remove="" for pkg in ${packages} ; do for rmpkg in $(pacman -Qq | grep ${pkg}) ; do if [ "${pkg}" == "${rmpkg}" ] ; then removepkgs="${removepkgs} ${rmpkg}" fi done done packages="${removepkgs}" } post_upgrade() { # Importing Build servers signature #same as above dirmngr </dev/null msg "Get Manjaro ARM Build Server's signature..." pacman-key -r B338D5DF pacman-key --lsign-key B338D5DF msg "Get Oberon's signature for the manjaro keyring.." pacman-key -r 663CA268 pacman-key --lsign-key 663CA268 #Add GPU temp udev rule # msg "Adding udev rule for gpu temp..." # echo 'SUBSYSTEM=="vchiq", GROUP="video", MODE="0660"' > /etc/udev/rules.d/99-input.rules }
manjaro-arm/packages-core
manjaro-system/manjaro-update-system.sh
Shell
gpl-3.0
1,123
#!/bin/bash #PBS -l walltime=3:00:00 #PBS -l select=1:ncpus=1:mem=1gb #PBS -q pqtouldrid ## select Python script to run RUNFILE=1mR_inf.py ## Copy from starting directory and move to space for running job: cp $PBS_O_WORKDIR/$RUNFILE $TMPDIR ## load Anaconda Python module load anaconda3/4.3.1 ## run the python file chosen python $TMPDIR/$RUNFILE ## copy outputted graphs back to original directory job script is located in cp $TMPDIR/*.png $PBS_O_WORKDIR/1mR_inf_results cp $TMPDIR/*.npz $PBS_O_WORKDIR/1mR_inf_results
OrganicDreamer/gillespie-translation-asRNA
asrna-tune-queue/queued-production/run_1mR_inf.sh
Shell
gpl-3.0
526
#! /bin/sh # Run only when the interface is not "lo": if [ $1 = "lo" ]; then exit 0 fi # Run whenever an interface gets "up", not otherwise: if [ $2 != "up" ]; then exit 0 fi # Restart Vidalia because it does not automatically reconnect to the new # Tor instance. Use kill+start as: # - X-GNOME-AutoRestart does not exist in Lenny's Gnome # - we do not start Vidalia automatically anymore and *this* is the time # when it is supposed to start. restart-vidalia
kolohe/amnesia
config/chroot_local-includes/etc/NetworkManager/dispatcher.d/60-vidalia.sh
Shell
gpl-3.0
471
#!/bin/bash # set environmental variables source ../../bin/setsgenvars.sh echo Compiling findcp echo $SGENFC findcp.f90 -o findcp.x $SGENFLAG $SGENLIB $SGENFC findcp.f90 -o findcp.x $SGENFLAG $SGENLIB echo Cleaning up rm opttools.mod echo Copying executable to surfgen directory cp findcp.x $SGENDIR echo Done
virtualzx-nad/surfgen
utilities/findcp/install.sh
Shell
gpl-3.0
316
#!/bin/bash echo "# All good cases should say 'validates'" for xml in *_ex*.xml; do echo -n "xsd: " xmllint --noout --schema image-api.xsd $xml echo -n "rng: " xmllint --noout --relaxng image-api.rng $xml done echo "# All bad cases should say 'fails to validate'" for xml in *bad*xml; do echo -n "xsd: " xmllint --noout --schema image-api.xsd $xml 2>&1 | grep -v "Schemas validity error" echo -n "rng: " xmllint --noout --relaxng image-api.rng $xml 2>&1 | grep -v "Relax-NG validity error" done
zimeon/iiif
tests/testdata/info_json_1_0/check_examples.sh
Shell
gpl-3.0
516
#!/bin/bash ############################################################### # set locale temporarily to english # due to some non-english locale issues export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 export LANGUAGE=en_US.UTF-8 export LC_CTYPE=en_US.UTF-8 ############################################################### # written by George Liu (eva2000) centminmod.com ############################################################### # variables ############################################################### ACMEVER='1.0.77' DT=$(date +"%d%m%y-%H%M%S") ACMEDEBUG='n' ACMEDEBUG_LOG='y' ACMEBINARY='/root/.acme.sh/acme.sh' ACMEGITURL='https://github.com/Neilpang/acme.sh.git' ACMEBACKUPDIR='/usr/local/nginx/conf/acmevhostbackup' ACMESH_BACKUPDIR='/home/acmesh-backups' ACMECERTHOME='/root/.acme.sh/' ACMETWO_API='n' ACMETWOAPI_BRANCH='2' ACME_MUSTSTAPLE='n' # options for KEYLENGTH # 2048, 3072, 4096, 8192, ec-256, ec-384 KEYLENGTH='2048' # every 60 days for auto renewal of SSL certificate RENEWDAYS='60' # https://community.letsencrypt.org/t/the-acme-sh-will-change-default-ca-to-zerossl-on-august-1st-2021/144052 # set to default CA letsencrypt always ACME_DEFAULT_CA='letsencrypt' ACME_PREFERRED_CHAIN=' --preferred-chain "ISRG"' # if set to yes, will issue and setup both RSA 2048bit + # ECDSA 256bit SSL certificates as outlined at # https://community.centminmod.com/posts/39989/ DUALCERTS='n' KEYLENGTH_DUAL='ec-256' ECC_ACMEHOMESUFFIXDUAL='_ecc' ECC_SUFFIXDUAL='-ecc' ECCFLAG_DUAL=' --ecc' STAGING_OPT=' --staging --server letsencrypt_test' CENTMINLOGDIR='/root/centminlogs' USE_NGINXMAINEXTLOGFORMAT='n' DIR_TMP='/svr-setup' MAIN_HOSTNAMEVHOSTFILE='/usr/local/nginx/conf/conf.d/virtual.conf' MAIN_HOSTNAMEVHOSTSSLFILE='/usr/local/nginx/conf/conf.d/virtual.ssl.conf' MAIN_HOSTNAME=$(awk '/server_name / {print $2}' "$MAIN_HOSTNAMEVHOSTFILE" | awk 'gsub(";$"," ")') OPENSSL_VERSION=$(ls -rt "$DIR_TMP" | awk '/openssl-1/' | grep -v 'tar.gz' | tail -1 | sed -e 's|openssl-||') CLOUDFLARE_AUTHORIGINPULLCERT='https://gist.githubusercontent.com/centminmod/020e3580eb03f1c36ced83b94fe4e1c5/raw/origin.crt' FORCE_IPVFOUR='y' # curl/wget commands through script force IPv4 ############################################################### # pushover API # to ensure these settings persist DO NOT change them in this # script but set these variables in persistent config file at # /etc/centminmod/acmetool-config.ini PUSHALERT='n' papiurl=https://api.pushover.net/1/messages.json # registered pushover.net users will find their Pushover email # aliases for notifications at https://pushover.net/ pushover_email='' ############################################################### # Cloudflare DNS API for DNS Mode # https://github.com/Neilpang/acme.sh/tree/master/dnsapi # login to your Cloudflare account to get your API Key in # My Settings section of your account # to ensure these settings persist DO NOT change them in this # script but set these variables in persistent config file at # /etc/centminmod/acmetool-config.ini # set to CF_DNSAPI='y' and fill in CF_KEY and CF_EMAIL settings CF_DNSAPI='n' # global CF API Key CF_KEY='' CF_EMAIL='' # new CF API Tokens # need read access to Zone.Zone, and write access to Zone.DNS # across all Zones # Cloudflare Account ID from any of your Cloudflare domain's # main dashboard's right side column listing CF_Token='' CF_Account_ID='' ############################################################### UNATTENDED='n' NOTICE='n' CHECKVERSION='y' SCRIPTCHECKURL='https://acmetool.centminmod.com' ############################################################### # Settings for centmin.sh menu option 2 and option 22 for # the details of the self-signed SSL certificate that is auto # generated. The default values where vhostname variable is # auto added based on what you input for your site name # # -subj "/C=US/ST=California/L=Los Angeles/O=${vhostname}/OU=${vhostname}/CN=${vhostname}" # # You can only customise the first 5 variables for # C = Country 2 digit code # ST = state # L = Location as in city # 0 = organisation # OU = organisational unit # # if left blank # defaults to same as vhostname that is your domain # if set it overrides that SELFSIGNEDSSL_C='US' SELFSIGNEDSSL_ST='California' SELFSIGNEDSSL_L='Los Angeles' SELFSIGNEDSSL_O='' SELFSIGNEDSSL_OU='' ############################################################### shopt -s expand_aliases for g in "" e f; do alias ${g}grep="LC_ALL=C ${g}grep" # speed-up grep, egrep, fgrep done CENTOSVER=$(awk '{ print $3 }' /etc/redhat-release) SCRIPT_DIR=$(readlink -f $(dirname ${BASH_SOURCE[0]})) ##################### checkver( ){ LATESTVER=$(curl -s $SCRIPTCHECKURL | head -n1 | cut -c1-6| tr -d '\r') CURRENTVER=$ACMEVER if [[ "$CURRENTVER" != "$LATESTVER" ]]; then echo echo "------------------------------------------------------------------------------" echo "Version Check:" echo "------------------------------------------------------------------------------" echo "!!! there maybe a newer version of $0 available !!!" echo "https://community.centminmod.com/posts/34492/" echo "update using centmin.sh menu option 23 submenu option 2" echo echo "or via command: cmupdate" echo echo "Always ensure Current Version is higher or equal to Latest Version" echo "------------------------------------------------------------------------------" echo "Current acmetool.sh Version: $CURRENTVER" echo "Latest acmetool.sh Version: $LATESTVER" echo "------------------------------------------------------------------------------" echo fi } if [[ "$CHECKVERSION" = [yY] && "$UNATTENDED" != [yY] ]]; then checkver fi if [[ "$NOTICE" = [yY] && "$UNATTENDED" != [yY] ]]; then echo echo "-------------------------------------------------" echo "acmetool.sh is in beta testing phase" echo "please read & provide bug reports &" echo "feedback for this tool via the forums" echo "https://centminmod.com/acmetool" echo "-------------------------------------------------" echo read -ep "continue [y/n] ? " _proceed if [[ "$_proceed" != [yY] ]]; then echo echo "aborting..." echo exit fi fi if [ "$CENTOSVER" == 'release' ]; then CENTOSVER=$(awk '{ print $4 }' /etc/redhat-release | cut -d . -f1,2) if [[ "$(awk '{ print $4 }' /etc/redhat-release | cut -d . -f1)" = '7' ]]; then CENTOS_SEVEN='7' fi fi if [[ "$(awk '{ print $3 }' /etc/redhat-release | cut -d . -f1)" = '6' ]]; then CENTOS_SIX='6' fi if [ "$CENTOSVER" == 'Enterprise' ]; then CENTOSVER=$(awk '{ print $7 }' /etc/redhat-release) OLS='y' fi if [[ -f /etc/system-release && "$(awk '{print $1,$2,$3}' /etc/system-release)" = 'Amazon Linux AMI' ]]; then CENTOS_SIX='6' fi if [ -f /etc/almalinux-release ]; then CENTOSVER=$(awk '{ print $3 }' /etc/almalinux-release) CENTOS_EIGHT='8' ALMALINUX_EIGHT='8' fi if [ ! -d "$DIR_TMP" ]; then mkdir -p "$DIR_TMP" fi if [ ! -d "$CENTMINLOGDIR" ]; then mkdir -p "$CENTMINLOGDIR" fi if [ ! -d "$ACMEBACKUPDIR" ]; then mkdir -p "$ACMEBACKUPDIR" fi if [ ! -d "$ACMESH_BACKUPDIR" ]; then mkdir -p "$ACMESH_BACKUPDIR" fi if [ -f "/etc/centminmod/acmetool-config.ini" ]; then dos2unix -q "/etc/centminmod/acmetool-config.ini" . "/etc/centminmod/acmetool-config.ini" fi if [ -f "/etc/centminmod/custom_config.inc" ]; then # default is at /etc/centminmod/custom_config.inc dos2unix -q "/etc/centminmod/custom_config.inc" . "/etc/centminmod/custom_config.inc" fi if [[ "$FORCE_IPVFOUR" != [yY] ]]; then ipv_forceopt="" else ipv_forceopt='4' fi if [[ "$ACME_DEFAULT_CA" = 'buypass' ]]; then ACME_PREFERRED_CHAIN='' RENEWDAYS='160' elif [[ "$ACME_DEFAULT_CA" != 'letsencrypt' ]]; then ACME_PREFERRED_CHAIN='' fi ############################################################### # Setup Colours black='\E[30;40m' red='\E[31;40m' green='\E[32;40m' yellow='\E[33;40m' blue='\E[34;40m' magenta='\E[35;40m' cyan='\E[36;40m' white='\E[37;40m' boldblack='\E[1;30;40m' boldred='\E[1;31;40m' boldgreen='\E[1;32;40m' boldyellow='\E[1;33;40m' boldblue='\E[1;34;40m' boldmagenta='\E[1;35;40m' boldcyan='\E[1;36;40m' boldwhite='\E[1;37;40m' Reset="tput sgr0" # Reset text attributes to normal #+ without clearing screen. cecho () # Coloured-echo. # Argument $1 = message # Argument $2 = color { message=$1 color=$2 echo -e "$color$message" ; $Reset return } ############################################################### # functions ##################### if [[ "$ACMEDEBUG" = [yY] && "$ACMEDEBUG_LOG" = [nN] ]]; then ACMEDEBUG_OPT='--debug 2' else ACMEDEBUG_OPT="" fi if [[ "$ACMEDEBUG_LOG" = [yY] && "$ACMEDEBUG" = [nN] ]] || [[ "$ACMEDEBUG_LOG" = [yY] && "$ACMEDEBUG" = [yY] ]]; then ACMEDEBUG_OPT="--log ${CENTMINLOGDIR}/acmetool.sh-debug-log-$DT.log --log-level 2" else ACMEDEBUG_OPT="" fi if [[ "$ACMETWO_API" = [yY] ]]; then ACME_APIENDPOINTTEST="" ACME_APIENDPOINT="" STAGING_OPT=' --staging --server letsencrypt_test' else ACME_APIENDPOINTTEST="" ACME_APIENDPOINT="" STAGING_OPT=' --staging --server letsencrypt_test' fi if [[ "$ACME_MUSTSTAPLE" = [yY] ]]; then ACMEOCSP=' --ocsp' else ACMEOCSP='' fi if [[ "$KEYLENGTH" = 'ec-256' || "$KEYLENGTH" = 'ec-384' ]]; then ECCFLAG=' --ecc' ECC_SUFFIX='-ecc' ECC_ACMEHOMESUFFIX='_ecc' else ECCFLAG="" ECC_SUFFIX="" ECC_ACMEHOMESUFFIX="" fi # Global Cloudflare DNS acme.sh support routine # if CF_DNSAPI_GLOBAL enabled for Cloudflare DNS mode, use Cloudflare API for setting # up DNS mode validation via TXT DNS record creation if [[ "$CF_DNSAPI_GLOBAL" = [yY] ]] && [[ ! -z "$CF_KEY" && ! -z "$CF_Email" ]] && [[ -z "$CF_Token" && -z "$CF_Account_ID" ]]; then # if global api set and token not set export CF_Key="$CF_KEY" export CF_Email="$CF_EMAIL" DNSAPI_OPT_GLOBAL=' --dns dns_cf' sed -i "s|^#CF_|CF_|" "$ACMECERTHOME"account.conf sed -i "s|CF_Key=\".*|CF_Key=\"$CF_KEY\"|" "$ACMECERTHOME"account.conf sed -i "s|CF_Email=\".*|CF_Email=\"$CF_EMAIL\"|" "$ACMECERTHOME"account.conf elif [[ "$CF_DNSAPI_GLOBAL" = [yY] ]] && [[ ! -z "$CF_Token" && ! -z "$CF_Account_ID" ]] && [[ -z "$CF_KEY" && -z "$CF_Email" ]]; then # if token set and global api not set export CF_Token="$CF_Token" export CF_Account_ID="$CF_Account_ID" DNSAPI_OPT_GLOBAL=' --dns dns_cf' sed -i "s|^#CF_|CF_|" "$ACMECERTHOME"account.conf sed -i "s|CF_Token=\".*|CF_Token=\"$CF_Token\"|" "$ACMECERTHOME"account.conf sed -i "s|CF_Account_ID=\".*|CF_Account_ID=\"$CF_Account_ID\"|" "$ACMECERTHOME"account.conf elif [[ "$CF_DNSAPI_GLOBAL" = [yY] ]] && [[ ! -z "$CF_Token" && ! -z "$CF_Account_ID" ]] && [[ ! -z "$CF_KEY" && ! -z "$CF_Email" ]]; then # if both global api key and token set, prefer token api method export CF_Token="$CF_Token" export CF_Account_ID="$CF_Account_ID" DNSAPI_OPT_GLOBAL=' --dns dns_cf' sed -i "s|^#CF_|CF_|" "$ACMECERTHOME"account.conf sed -i "s|CF_Token=\".*|CF_Token=\"$CF_Token\"|" "$ACMECERTHOME"account.conf sed -i "s|CF_Account_ID=\".*|CF_Account_ID=\"$CF_Account_ID\"|" "$ACMECERTHOME"account.conf else DNSAPI_OPT_GLOBAL="" fi # extended custom nginx log format = main_ext for nginx amplify metric support # https://github.com/nginxinc/nginx-amplify-doc/blob/master/amplify-guide.md#additional-nginx-metrics if [ -f /usr/local/nginx/conf/nginx.conf ]; then if [[ "$USE_NGINXMAINEXTLOGFORMAT" = [yY] && "$(grep 'main_ext' /usr/local/nginx/conf/nginx.conf)" ]]; then NGX_LOGFORMAT='main_ext' else NGX_LOGFORMAT='combined' fi else NGX_LOGFORMAT='combined' fi ##################### fix_acme_endpoint() { if [ -d /root/.acme.sh/ ]; then find /root/.acme.sh/ -type f -name "*.csr" | while read f; do configname=$(echo "$f" | sed -e 's|\.csr|\.conf|g') if [[ -f "$configname" && "$(grep "Le_API='https://acme-v01.api" $configname)" ]]; then echo "-------------------------------------------------------------" echo "Check Le_API variable in $configname" echo "-------------------------------------------------------------" echo grep '\.api' "$configname" echo echo "-------------------------------------------------------------" echo "Update Le_API in $configname" echo "-------------------------------------------------------------" echo sed -i "s|Le_API='https:\/\/acme-v01.api|Le_API='https:\/\/acme-v02.api|" "$configname" grep 'Le_API=' "$configname" echo fi done fi } ##################### listlogs() { echo echo "log files saved at ${CENTMINLOGDIR}" ls -lAhrt "${CENTMINLOGDIR}" | grep "${DT%??}" echo } ##################### check_cfdns_api() { echo "Verifying working Cloudflare DNS API Credentials" if [[ ! -z "$CF_KEY" && ! -z "$CF_Email" ]] && [[ -z "$CF_Token" && -z "$CF_Account_ID" ]]; then echo "CF Global API Key detected" cfapi_check=$(curl -4sX GET "https://api.cloudflare.com/client/v4/zones" -H "X-Auth-Email: $CF_Email" -H "X-Auth-Key: $CF_KEY" -H "Content-Type: application/json" | jq -r '.success') if [[ "$cfapi_check" = 'true' ]]; then echo "Ok: CF Global API works" cflist_zones=$(curl -4sX GET "https://api.cloudflare.com/client/v4/zones" -H "X-Auth-Email: $CF_Email" -H "X-Auth-Key: $CF_KEY" -H "Content-Type: application/json" | jq -r '.result[] | "\(.name) \(.id) \(.status) \(.paused)"') # get specific zone details # curl -4sX GET "https://api.cloudflare.com/client/v4/zones/$CF_Zone_ID" -H "X-Auth-Email: $CF_Email" -H "X-Auth-Key: $CF_KEY" -H "Content-Type: application/json" | jq -r else echo "Error: CF Global API not working" fi elif [[ -z "$CF_KEY" && -z "$CF_Email" ]] && [[ ! -z "$CF_Token" && ! -z "$CF_Account_ID" ]]; then echo "CF API Tokens detected" cfapi_check=$(curl -4sX GET "https://api.cloudflare.com/client/v4/user/tokens/verify" -H "Authorization: Bearer $CF_Token" -H "Content-Type:application/json" | jq -r '.success') if [[ "$cfapi_check" = 'true' ]]; then echo "Ok: CF API Token works" else echo "Error: CF API Token not working" fi else echo "No Cloudflare Global API Key or API Token detected" fi } ##################### check_domains() { if [ -d /root/.acme.sh ]; then echo "----------------------------------------------" echo "check domain DNS" echo "----------------------------------------------" for c in $(find /usr/local/nginx/conf/ssl/ -name '*-acme.cer' -o -name '*-acme-ecc.cer'); do domain_tocheck=$(basename $c | sed -e 's|-acme.cer||' -e 's|-acme-ecc.cer||') echo "$domain_tocheck" done | uniq | while read d; do domain_arecord=$(dig @8.8.8.8 A $d +short) domain_aaaarecord=$(dig @8.8.8.8 AAAA $d +short) echo "--------------------------------------------------------------------" echo "Checking: $d" echo "A record: ${domain_arecord:-not found}" echo "AAAA record: ${domain_aaaarecord:-not found}" if [[ "$domain_arecord" ]]; then echo echo "curl -${ipv_forceopt}Ivs https://${d} 2>&1 | egrep 'Connected to|SSL connection using|subject:|start date:|expire date:'" curl -${ipv_forceopt}Ivs https://${d} 2>&1 | egrep 'Connected to|SSL connection using|subject:|start date:|expire date:' | sed -e 's|\*\s\s||g' -e 's|\*\s||g' fi if [[ "$domain_aaaarecord" ]]; then echo echo "curl -6Ivs https://${d} 2>&1 | egrep 'Connected to|SSL connection using|subject:|start date:|expire date:'" curl -6Ivs https://${d} 2>&1 | egrep 'Connected to|SSL connection using|subject:|start date:|expire date:' | sed -e 's|\*\s\s||g' -e 's|\*\s||g' fi echo "--------------------------------------------------------------------" echo done fi } ##################### checkdate() { if [ -d /root/.acme.sh ]; then echo "----------------------------------------------" echo "nginx installed" echo "----------------------------------------------" for c in $(find /usr/local/nginx/conf/ssl/ -name '*-acme.cer' -o -name '*-acme-ecc.cer'); do if [ -f $c ]; then expiry=$(openssl x509 -enddate -noout -in $c | cut -d'=' -f2 | awk '{print $2 " " $1 " " $4}') fingerprint=$(openssl x509 -fingerprint -noout -in $c | sed 's|:||g' | awk -F "=" '// {print $2}') epochExpirydate=$(date -d"${expiry}" +%s) epochToday=$(date +%s) secondsToExpire=$(echo ${epochExpirydate} - ${epochToday} | bc) daysToExpire=$(echo "${secondsToExpire} / 60 / 60 / 24" | bc) certDomain=$(openssl x509 -subject -noout -in $c | sed -n '/^subject/s/^.*CN=//p') checkRevokeCaa=$(curl --connect-timeout 1 -sX POST -d "fqdn=$certDomain" https://checkhost.unboundtest.com/checkhost | grep "because it is affected by" | wc -l) echo echo "$c" echo "SHA1 Fingerprint=${fingerprint}" echo "certificate expires in $daysToExpire days on $expiry" if [[ "$checkRevokeCaa" -eq 1 ]]; then echo "certificate should be renewed ASAP due to CAA bug" echo "https://community.letsencrypt.org/t/2020-02-29-caa-rechecking-bug/114591" fi fi done echo echo "----------------------------------------------" echo "acme.sh obtained" echo "----------------------------------------------" for ca in $(find ${ACMECERTHOME} -name '*.cer'| egrep -v 'fullchain.cer|ca.cer'); do if [ -f $ca ]; then expiry=$(openssl x509 -enddate -noout -in $ca | cut -d'=' -f2 | awk '{print $2 " " $1 " " $4}') fingerprint=$(openssl x509 -fingerprint -noout -in $ca | sed 's|:||g' | awk -F "=" '// {print $2}') epochExpirydate=$(date -d"${expiry}" +%s) epochToday=$(date +%s) secondsToExpire=$(echo ${epochExpirydate} - ${epochToday} | bc) daysToExpire=$(echo "${secondsToExpire} / 60 / 60 / 24" | bc) certDomain=$(openssl x509 -subject -noout -in $c | sed -n '/^subject/s/^.*CN=//p') checkRevokeCaa=$(curl --connect-timeout 1 -sX POST -d "fqdn=$certDomain" https://checkhost.unboundtest.com/checkhost | grep "because it is affected by" | wc -l) echo echo "$ca" echo "SHA1 Fingerprint=${fingerprint}" conf=$(echo $ca | sed 's|.cer$|.conf|') if [[ "$(grep -q 'acme-staging.api' $conf; echo $?)" != '0' ]]; then echo "[ below certifcate transparency link is only valid ~1hr after issuance ]" echo "https://crt.sh/?sha1=${fingerprint}" fi echo "certificate expires in $daysToExpire days on $expiry" if [[ "$checkRevokeCaa" -eq 1 ]]; then echo "certificate should be renewed ASAP due to CAA bug" echo "https://community.letsencrypt.org/t/2020-02-29-caa-rechecking-bug/114591" fi fi done echo fi } ##################### check_dns() { vhostname_dns="$1" # if CHECKIDN = 0 then internationalized domain name which not supported by letsencrypt CHECKIDN=$(echo $vhostname_dns | idn | grep '^xn--' >/dev/null 2>&1; echo $?) if [[ "$CHECKIDN" = '0' ]]; then TOPLEVELCHECK=$(dig soa @8.8.8.8 $vhostname_dns | grep -v ^\; | grep SOA | awk '{print $1}' | sed 's/\.$//' | idn) else TOPLEVELCHECK=$(dig soa @8.8.8.8 $vhostname_dns | grep -v ^\; | grep SOA | awk '{print $1}' | sed 's/\.$//') fi if [[ "$TOPLEVELCHECK" = "$vhostname_dns" ]]; then # top level domain TOPLEVEL=y elif [[ -z "$TOPLEVELCHECK" ]]; then # vhost dns not setup TOPLEVEL=z if [[ "$(echo $vhostname_dns | grep -o "\." | wc -l)" -le '1' ]]; then TOPLEVEL=y else TOPLEVEL=n fi else # subdomain or non top level domain TOPLEVEL=n fi } ##################### backup_acme() { vhostbackupname="$1" \cp -af "${ACMECERTHOME}${vhostbackupname}${ECC_ACMEHOMESUFFIX}" "${ACMESH_BACKUPDIR}/${vhostbackupname}${ECC_ACMEHOMESUFFIX}-${DT}" } ##################### pushover_alert() { if [[ "$PUSHALERT" = [yY] ]]; then push_vhostname="$1" dnspush=$2 dnslog=$3 if [[ ! -z "$pushover_email" && ! -f "$dnslog" ]] && [[ "$dnspush" != 'dns' || "$dnspush" != 'dnscf' ]]; then acme_domainconf="${ACMECERTHOME}${push_vhostname}${ECC_ACMEHOMESUFFIX}/${push_vhostname}.conf" acmecreate_date=$(grep "^Le_CertCreateTimeStr" "$acme_domainconf" | cut -d '=' -f 2) acmenextrenew_date=$(grep "^Le_NextRenewTimeStr" "$acme_domainconf" | cut -d '=' -f 2) echo " $push_vhostname SSL Cert Created: $acmecreate_date $push_vhostname SSL Cert Next Renewal Date: $acmenextrenew_date "| mail -s "$push_vhostname SSL Cert Setup `date`" -r "$pushover_email" "$pushover_email" elif [[ -f "$dnslog" ]] && [[ "$dnspush" = 'dns' ]]; then cat "$dnslog" | grep -A30 'Add the following TXT record' | perl -pe 's/\x1b.*?[mGKH]//g' | sed 's/\[[^]]*\]//g' | egrep -v 'Please be aware that you prepend|resulting subdomain|and retry again' | mail -s "$push_vhostname DNS Mode Validation Instructions `date`" -r "$pushover_email" "$pushover_email" elif [[ "$dnspush" = 'dnscf' ]]; then cat "$dnslog" | perl -pe 's/\x1b.*?[mGKH]//g' | sed 's/\[[^]]*\]//g' | grep -A60 'Verify each domain' | sed '/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/d' | mail -s "$push_vhostname DNS Mode Validation via Cloudflare API `date`" -r "$pushover_email" "$pushover_email" fi fi } ##################### renew_all() { is_live=$1 for d in $(ls -F "${ACMECERTHOME}" | grep [^.].*[.].*/$ ) ; do d=$(echo $d | cut -d '/' -f 1) ( if [[ "$is_live" = 'live' ]]; then "$SCRIPT_DIR/acmetool.sh" renew "$d" live else "$SCRIPT_DIR/acmetool.sh" renew "$d" fi ) done } ##################### getuseragent() { _dnsagent=$1 # build Centmin Mod's identifying letsencrypt user agent # --user-agent= if [[ "$CENTOS_SIX" = '6' ]]; then LE_OSVER=centos6 elif [[ "$CENTOS_SEVEN" = '7' ]]; then LE_OSVER=centos7 fi if [[ "$_dnsagent" != 'dns' ]]; then LE_USERAGENT="centminmod-$LE_OSVER-acmesh-webroot" else LE_USERAGENT="centminmod-$LE_OSVER-acmesh-dns" fi } ##################### reloadcmd_setup() { if [ ! -f "${ACMECERTHOME}reload.sh" ]; then echo echo "setup ${ACMECERTHOME}reload.sh" cat > "${ACMECERTHOME}reload.sh" <<EOF #/bin/bash pwd cat ${vhostname}.cer > "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" cat ${vhostname}.key > "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" cat ${vhostname}.ca >> "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" cat fullchain.cer > "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIX}.cer" if [ -f /usr/bin/ngxreload ]; then /usr/bin/ngxreload fi EOF chmod +x "${ACMECERTHOME}reload.sh" echo fi } ##################### split_domains() { parse_domains="$1" echo "$parse_domains"| awk '/\,/'; D_ERR=$? if [[ "$D_ERR" = '0' ]]; then SAN=1 DOMAIN_LIST="$(echo "$parse_domains"| sed -e 's|\s||g' | sed -e 's|,| -d |g')" vhostname=$(echo "$parse_domains"| awk -F ',' '{print $1}') # if checkidn_vhost = 0 then internationalized domain name checkidn_splitvhost=$(echo $vhostname | idn | grep '^xn--' >/dev/null 2>&1; echo $?) if [[ "$checkidn_splitvhost" = '0' ]]; then DOMAIN_LIST=$(echo $DOMAIN_LIST | idn) vhostname=$(echo $vhostname | idn) fi DOMAIN_LISTNGX="$(echo "$(echo "$parse_domains"| sed -e 's|,| |g') www.$vhostname")" # take only 1st entry for nginx vhost else SAN=0 DOMAIN_LIST="$parse_domains" vhostname="$parse_domains" # if checkidn_vhost = 0 then internationalized domain name checkidn_splitvhost=$(echo $vhostname | idn | grep '^xn--' >/dev/null 2>&1; echo $?) if [[ "$checkidn_splitvhost" = '0' ]]; then DOMAIN_LIST=$(echo $DOMAIN_LIST | idn) vhostname=$(echo $vhostname | idn) fi fi } ##################### nvcheck() { if [ ! -h /usr/bin/nv ]; then rm -rf /usr/bin/nv if [ -f /usr/local/src/centminmod/tools/nv.sh ]; then ln -s /usr/local/src/centminmod/tools/nv.sh /usr/bin/nv fi chmod +x /usr/bin/nv fi } ##################### vhostsetup() { vhost_domain="$1" HTTPSONLY="$2" if [ ! -f /usr/bin/pwgen ]; then yum -y -q install pwgen fi ftpusername=$(/usr/bin/pwgen -s 15 1) if [ -f /usr/bin/nv ]; then echo if [[ "$vhost_domain" = "$MAIN_HOSTNAME" ]]; then # check if vhost domain name is the registered main server hostname first # create main vhost's ssl vhost config file sslvhostsetup_mainhostname "$vhost_domain" else if [[ "$HTTPSONLY" = 'https' ]]; then echo "/usr/bin/nv -d "${vhost_domain}" -s ydle -u "${ftpusername}"" /usr/bin/nv -d "${vhost_domain}" -s ydle -u "${ftpusername}" else echo "/usr/bin/nv -d "${vhost_domain}" -s y -u "${ftpusername}"" /usr/bin/nv -d "${vhost_domain}" -s y -u "${ftpusername}" fi # initiate the autoprotect.sh include file generation # after nginx vhost is created if [ -f /usr/local/src/centminmod/tools/autoprotect.sh ]; then /usr/local/src/centminmod/tools/autoprotect.sh >/dev/null 2>&1 fi fi # MAIN_HOSTNAME CHECK echo else echo echo "/usr/bin/nv not found" echo fi } ##################### set_default_ca() { cecho "-----------------------------------------------------" $boldgreen echo "set default acme.sh CA to $ACME_DEFAULT_CA:" echo "acme.sh --set-default-ca --server $ACME_DEFAULT_CA" "$ACMEBINARY" --set-default-ca --server "$ACME_DEFAULT_CA" } ##################### install_acme() { echo cecho "-----------------------------------------------------" $boldgreen echo "installing acme.sh client..." cecho "-----------------------------------------------------" $boldgreen mkdir -p /root/tools cd /root/tools if [ ! -d acme.sh ]; then if [[ "$ACMETWO_API" = [yY] ]]; then git clone -b "$ACMETWOAPI_BRANCH" "$ACMEGITURL" else git clone "$ACMEGITURL" fi cd acme.sh elif [ -d acme.sh/.git ]; then rm -rf acme.sh if [[ "$ACMETWO_API" = [yY] ]]; then git clone -b "$ACMETWOAPI_BRANCH" "$ACMEGITURL" else git clone "$ACMEGITURL" fi cd acme.sh fi if [[ "$EMAIL" ]]; then ./acme.sh --install --days $RENEWDAYS --accountemail "$EMAIL" else ./acme.sh --install --days $RENEWDAYS fi if [ -f "/root/.acme.sh/acme.sh.env" ]; then . "/root/.acme.sh/acme.sh.env" fi "$ACMEBINARY" -h echo set_default_ca fix_acme_endpoint cecho "-----------------------------------------------------" $boldgreen echo "check acme auto renew cronjob setup: " cecho "-----------------------------------------------------" $boldgreen crontab -l | grep acme.sh cecho "-----------------------------------------------------" $boldgreen echo "acme.sh installed" cecho "-----------------------------------------------------" $boldgreen } ##################### update_acme() { QUITEOUTPUT=$1 echo cecho "-----------------------------------------------------" $boldgreen echo "updating acme.sh client..." cecho "-----------------------------------------------------" $boldgreen mkdir -p /root/tools cd /root/tools if [ ! -d acme.sh ]; then if [[ "$ACMETWO_API" = [yY] ]]; then git clone -b "$ACMETWOAPI_BRANCH" "$ACMEGITURL" else git clone "$ACMEGITURL" fi cd acme.sh elif [ -d acme.sh/.git ]; then rm -rf acme.sh if [[ "$ACMETWO_API" = [yY] ]]; then git clone -b "$ACMETWOAPI_BRANCH" "$ACMEGITURL" else git clone "$ACMEGITURL" fi cd acme.sh fi if [[ "$EMAIL" ]]; then ./acme.sh --install --days $RENEWDAYS --accountemail "$EMAIL" else ./acme.sh --install --days $RENEWDAYS fi if [ -f "/root/.acme.sh/acme.sh.env" ]; then . "/root/.acme.sh/acme.sh.env" fi "$ACMEBINARY" -v if [[ "$QUITEOUTPUT" != 'quite' ]]; then echo set_default_ca fix_acme_endpoint cecho "-----------------------------------------------------" $boldgreen echo "check acme auto renew cronjob setup: " cecho "-----------------------------------------------------" $boldgreen crontab -l | grep acme.sh else set_default_ca fix_acme_endpoint fi cecho "-----------------------------------------------------" $boldgreen echo "acme.sh updated" cecho "-----------------------------------------------------" $boldgreen } ##################### setup_acme() { # configure acme.sh defaults echo } ##################### check_acmeinstall() { # check if acme.sh is installed if [[ ! -d /root/.acme.sh || ! -f /root/.acme.sh/acme.sh.env ]]; then echo echo "acme.sh missing... installing acme.sh now..." install_acme echo fi } ##################### sslopts_check() { if [ -f "${DIR_TMP}/openssl-${OPENSSL_VERSION}/crypto/chacha20poly1305/chacha20.c" ]; then # check /svr-setup/openssl-1.0.2f/crypto/chacha20poly1305/chacha20.c exists OPEENSSL_CFPATCHED='y' elif [ -f "${DIR_TMP}/openssl-${OPENSSL_VERSION}/crypto/chacha/chacha_enc.c" ]; then # for openssl 1.1.0 native chacha20 support OPEENSSL_CFPATCHED='y' fi if [[ "$(nginx -V 2>&1 | grep LibreSSL | head -n1)" ]] || [[ "$OPEENSSL_CFPATCHED" = [yY] ]]; then if [[ -f "${DIR_TMP}/openssl-${OPENSSL_VERSION}/crypto/chacha20poly1305/chacha20.c" ]]; then CHACHACIPHERS='ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:' elif [[ -f "${DIR_TMP}/openssl-${OPENSSL_VERSION}/crypto/chacha/chacha_enc.c" ]]; then CHACHACIPHERS='ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:' else CHACHACIPHERS='ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:' fi else CHACHACIPHERS="" fi DETECTOPENSSL_ONEZERO=$(echo $OPENSSL_VERSION | cut -d . -f1-2) DETECTOPENSSL_ONEONE=$(echo $OPENSSL_VERSION | cut -d . -f1-3 | grep -o 1.1.1) if [[ "$DETECTOPENSSL_ONEZERO" = '1.1' ]] || [[ "$DETECTOPENSSL_ONEONE" = '1.1.1' ]]; then # openssl 1.1.0 unsupported flag enable-tlsext if [[ "$(grep -w 'tls1_3' "${DIR_TMP}/openssl-${OPENSSL_VERSION}/configdata.pm")" ]]; then TLSONETHREEOPT=' enable-tls1_3' TLSONETHREE_DETECT='y' else TLSONETHREEOPT="" TLSONETHREE_DETECT='n' fi fi if [[ "$TLSONETHREE_DETECT" = [yY] ]]; then TLSONETHREE_CIPHERS='TLS13-AES-128-GCM-SHA256:TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:' else TLSONETHREE_CIPHERS="" fi if [[ "$(nginx -V 2>&1 | grep -Eo 'with-http_v2_module')" = 'with-http_v2_module' ]] && [[ "$(nginx -V 2>&1 | grep -Eo 'with-http_spdy_module')" = 'with-http_spdy_module' ]]; then HTTPTWO=y LISTENOPT='ssl spdy http2' COMP_HEADER='spdy_headers_comp 5' SPDY_HEADER='add_header Alternate-Protocol 443:npn-spdy/3;' # removed in nginx 1.19.7+ # http://hg.nginx.org/nginx/rev/827202ca1269 # http://hg.nginx.org/nginx/rev/f790816a0e87 #HTTPTWO_MAXFIELDSIZE='http2_max_field_size 16k;' #HTTPTWO_MAXHEADERSIZE='http2_max_header_size 32k;' #HTTPTWO_MAXREQUESTS='http2_max_requests 50000;' elif [[ "$(nginx -V 2>&1 | grep -Eo 'with-http_v2_module')" = 'with-http_v2_module' ]]; then HTTPTWO=y # check if backlogg directive is supported for listen 443 port - only needs to be added once globally for all nginx vhosts # CHECK_HTTPSBACKLOG=$(grep -rn listen /usr/local/nginx/conf/conf.d/ | grep -v '#' | grep 443 | grep ' ssl' | grep ' http2' | grep backlog | awk -F ': ' '{print $2}' | grep -o backlog) # if [[ "$CHECK_HTTPSBACKLOG" != 'backlog' ]]; then # if [[ ! -f /proc/user_beancounters ]]; then # GETSOMAXCON_VALUE=$(sysctl net.core.somaxconn | awk -F '= ' '{print $2}') # SET_NGINXBACKLOG=$(($GETSOMAXCON_VALUE/16)) # ADD_BACKLOG=" backlog=$SET_NGINXBACKLOG" # fi # fi if [[ "$(grep -rn listen /usr/local/nginx/conf/conf.d/*.conf | grep -v '#' | grep 443 | grep ' ssl' | grep ' http2' | grep -o reuseport )" != 'reuseport' ]]; then # check if reuseport is supported for listen 443 port - only needs to be added once globally for all nginx vhosts NGXVHOST_CHECKREUSEPORT=$(grep --color -Ro SO_REUSEPORT /usr/src/kernels/* | head -n1 | awk -F ":" '{print $2}') if [[ "$NGXVHOST_CHECKREUSEPORT" = 'SO_REUSEPORT' ]]; then ADD_REUSEPORT=' reuseport' else ADD_REUSEPORT="" fi LISTENOPT="ssl http2${ADD_REUSEPORT}${ADD_BACKLOG}" else LISTENOPT="ssl http2${ADD_BACKLOG}" fi COMP_HEADER='#spdy_headers_comp 5' SPDY_HEADER='#add_header Alternate-Protocol 443:npn-spdy/3;' # removed in nginx 1.19.7+ # http://hg.nginx.org/nginx/rev/827202ca1269 # http://hg.nginx.org/nginx/rev/f790816a0e87 #HTTPTWO_MAXFIELDSIZE='http2_max_field_size 16k;' #HTTPTWO_MAXHEADERSIZE='http2_max_header_size 32k;' #HTTPTWO_MAXREQUESTS='http2_max_requests 50000;' else HTTPTWO=n LISTENOPT='ssl spdy' COMP_HEADER='spdy_headers_comp 5' SPDY_HEADER='add_header Alternate-Protocol 443:npn-spdy/3;' fi } ##################### detectcustom_webroot() { CUSTOM_WEBROOT=$1 DETECT_VHOSTNAME=$2 DETECTSSLVHOST_CONFIGFILENAME="${DETECT_VHOSTNAME}.ssl.conf" DETECTSSLVHOST_CONFIG="/usr/local/nginx/conf/conf.d/${DETECTSSLVHOST_CONFIGFILENAME}" if [ -f "$DETECTSSLVHOST_CONFIG" ]; then CURRENT_WEBROOT=$(awk '/root /{print $2}' /usr/local/nginx/conf/conf.d/${DETECT_VHOSTNAME}.ssl.conf | sed -e 's|;||') fi # ensure WEBROOTPATH only allocates CUSTOM_WEBROOT if detectcustom_webroot passes # 2 values for $1 and $2 otherwise if only 1 value passed for $1 assume it's the vhostname # when there is not custom web root path required. if [[ "$CUSTOM_WEBROOT" && "$DETECT_VHOSTNAME" ]]; then WEBROOTPATH="$CUSTOM_WEBROOT" elif [[ "$CUSTOM_WEBROOT" && -z "$DETECT_VHOSTNAME" ]]; then WEBROOTPATH="/home/nginx/domains/${CUSTOM_WEBROOT}/public" fi } ##################### switch_httpsdefault() { echo echo "setting HTTPS default in /usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" echo if [ -f "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" ]; then echo "sed -i 's|^##x# HTTPS-DEFAULT|#x# HTTPS-DEFAULT|g' \"/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf\"" echo "sed -i \"s|#x# server {| server {|\" \"/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf\"" echo "sed -i \"s|#x# $DEDI_LISTEN| $DEDI_LISTEN|\" \"/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf\"" echo "sed -i \"s|#x# server_name ${vhostname} www.${vhostname};| server_name ${vhostname} www.${vhostname};|\" \"/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf\"" echo "sed -i \"s|#x# return 302 https://${vhostname}\$request_uri;| return 302 https://${vhostname}\$request_uri;|\" \"/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf\"" echo "sed -i \"s|#x# root /home/nginx/domains/${vhostname}/public;| root /home/nginx/domains/${vhostname}/public;|\" \"/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf\"" echo "sed -i \"s|#x# include \/usr\/local\/nginx\/conf\/staticfiles.conf;| include \/usr\/local\/nginx\/conf\/staticfiles.conf;|\" \"/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf\"" echo "sed -i \"s|#x# }| }|\" \"/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf\"" sed -i 's|^##x# HTTPS-DEFAULT|#x# HTTPS-DEFAULT|g' "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" sed -i "s|#x# server {| server {|" "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" sed -i "s|#x# $DEDI_LISTEN| $DEDI_LISTEN|" "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" sed -i "s|#x# server_name ${vhostname} www.${vhostname};| server_name ${vhostname} www.${vhostname};|" "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" sed -i "s|#x# return 302 https:\/\/${vhostname}\$request_uri;| return 302 https:\/\/${vhostname}\$request_uri;|" "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" sed -i "s|#x# root /home/nginx/domains/${vhostname}/public;| root /home/nginx/domains/${vhostname}/public;|" "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" sed -i "s|#x# include \/usr\/local\/nginx\/conf\/staticfiles.conf;| include \/usr\/local\/nginx\/conf\/staticfiles.conf;|" "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" sed -i "s|#x# }| }|" "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" # remove duplicates sed -i '/^# Centmin Mod Getting Started Guide/d' "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" sed -i '/^# must read http:\/\/centminmod.com\/getstarted.html/d' "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" sed -i '/^# For HTTP\/2 SSL Setup/d' "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" sed -i '/^# read http:\/\/centminmod.com\/nginx_configure_https_ssl_spdy.html/d' "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" sed -i '/^# redirect from www to non-www forced SSL/d' "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" sed -i '/^# uncomment, save file and restart Nginx to enable/d' "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" sed -i '/^# if unsure use return 302 before using return 301/d' "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" sed -i '/^# server {/d' "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" sed -i "/^# server_name ${vhostname} www.${vhostname};/d" "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" sed -i '/^# return 302 https:\/\/$server_name$request_uri;/d' "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" sed -i '/^# }/d' "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" sed -i '/^# listen 80;/d' "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" sed -i "/^# server_name ${vhostname} www.${vhostname};/d" "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" sed -i '/^# return 302 https:\/\/$server_name$request_uri;/d' "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" echo echo "remove /usr/local/nginx/conf/conf.d/$vhostname.conf" rm -rf "/usr/local/nginx/conf/conf.d/$vhostname.conf" >/dev/null 2>&1 echo fi } ##################### gen_selfsigned() { vhostname="$1" if [ ! -f /usr/local/nginx/conf/ssl ]; then mkdir -p /usr/local/nginx/conf/ssl fi if [ ! -d /usr/local/nginx/conf/ssl/${vhostname} ]; then mkdir -p /usr/local/nginx/conf/ssl/${vhostname} fi # cloudflare authenticated origin pull cert # setup https://community.centminmod.com/threads/13847/ if [ ! -d /usr/local/nginx/conf/ssl/cloudflare/${vhostname} ]; then mkdir -p /usr/local/nginx/conf/ssl/cloudflare/${vhostname} wget $CLOUDFLARE_AUTHORIGINPULLCERT -O origin.crt fi if [ ! -f /usr/local/nginx/conf/ssl_include.conf ]; then cat > "/usr/local/nginx/conf/ssl_include.conf"<<EVS ssl_session_cache shared:SSL:10m; ssl_session_timeout 60m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; EVS fi pushd /usr/local/nginx/conf/ssl/${vhostname} cecho "---------------------------------------------------------------" $boldyellow cecho "Generating self signed SSL certificate..." $boldgreen cecho "CSR file can also be used to be submitted for paid SSL certificates" $boldgreen cecho "If using for paid SSL certificates be sure to keep both private key and CSR safe" $boldgreen cecho "creating CSR File: ${vhostname}.csr" $boldgreen cecho "creating private key: ${vhostname}.key" $boldgreen cecho "creating self-signed SSL certificate: ${vhostname}.crt" $boldgreen sleep 9 if [[ -z "$SELFSIGNEDSSL_O" ]]; then SELFSIGNEDSSL_O="$vhostname" else SELFSIGNEDSSL_O="$SELFSIGNEDSSL_O" fi if [[ -z "$SELFSIGNEDSSL_OU" ]]; then SELFSIGNEDSSL_OU="$vhostname" else SELFSIGNEDSSL_OU="$SELFSIGNEDSSL_OU" fi echo "openssl req -new -newkey rsa:2048 -sha256 -nodes -out ${vhostname}.csr -keyout ${vhostname}.key -subj \"/C=${SELFSIGNEDSSL_C}/ST=${SELFSIGNEDSSL_ST}/L=${SELFSIGNEDSSL_L}/O=${SELFSIGNEDSSL_O}/OU=${SELFSIGNEDSSL_OU}/CN=${vhostname}\"" openssl req -new -newkey rsa:2048 -sha256 -nodes -out ${vhostname}.csr -keyout ${vhostname}.key -subj "/C=${SELFSIGNEDSSL_C}/ST=${SELFSIGNEDSSL_ST}/L=${SELFSIGNEDSSL_L}/O=${SELFSIGNEDSSL_O}/OU=${SELFSIGNEDSSL_OU}/CN=${vhostname}" echo "openssl x509 -req -days 36500 -sha256 -in ${vhostname}.csr -signkey ${vhostname}.key -out ${vhostname}.crt" openssl x509 -req -days 36500 -sha256 -in ${vhostname}.csr -signkey ${vhostname}.key -out ${vhostname}.crt echo cecho "---------------------------------------------------------------" $boldyellow cecho "Generating dhparam.pem file - can take a few minutes..." $boldgreen dhparamstarttime=$(TZ=UTC date +%s.%N) openssl dhparam -out dhparam.pem 2048 dhparamendtime=$(TZ=UTC date +%s.%N) DHPARAMTIME=$(echo "$dhparamendtime-$dhparamstarttime"|bc) cecho "dhparam file generation time: $DHPARAMTIME" $boldyellow popd } ##################### sslvhostsetup_mainhostname() { vhostname="$1" if [[ ! -f "${MAIN_HOSTNAMEVHOSTSSLFILE}" && ! -d "/home/nginx/domains/${vhostname}/public" ]]; then echo echo "create ${MAIN_HOSTNAMEVHOSTSSLFILE}" echo # Support secondary dedicated IP configuration for centmin mod # nginx vhost generator, so out of the box, new nginx vhosts # generated will use the defined SECOND_IP=111.222.333.444 where # the IP is a secondary IP addressed added to the server. # You define SECOND_IP variable is centmin mod persistent config # file outlined at https://centminmod.com/upgrade.html#persistent # you manually creat the file at /etc/centminmod/custom_config.inc # and add SECOND_IP=yoursecondary_IPaddress variable to it which # will be registered with nginx vhost generator routine so that # any new nginx vhosts created via centmin.sh menu option 2 or # /usr/bin/nv or centmin.sh menu option 22, will have pre-defined # SECOND_IP ip address set in the nginx vhost's listen directive if [[ -z "$SECOND_IP" ]]; then DEDI_IP="" DEDI_LISTEN="" elif [[ "$SECOND_IP" ]]; then DEDI_IP=$(echo $(echo ${SECOND_IP}:)) DEDI_LISTEN="listen ${DEDI_IP}80;" fi if [ ! -f /usr/local/nginx/conf/ssl ]; then mkdir -p /usr/local/nginx/conf/ssl fi if [ ! -d /usr/local/nginx/conf/ssl/${vhostname} ]; then mkdir -p /usr/local/nginx/conf/ssl/${vhostname} fi # cloudflare authenticated origin pull cert # setup https://community.centminmod.com/threads/13847/ if [ ! -d /usr/local/nginx/conf/ssl/cloudflare/${vhostname} ]; then mkdir -p /usr/local/nginx/conf/ssl/cloudflare/${vhostname} wget $CLOUDFLARE_AUTHORIGINPULLCERT -O origin.crt elif [ -d /usr/local/nginx/conf/ssl/cloudflare/${vhostname} ]; then wget $CLOUDFLARE_AUTHORIGINPULLCERT -O origin.crt fi if [ ! -f /usr/local/nginx/conf/ssl_include.conf ]; then cat > "/usr/local/nginx/conf/ssl_include.conf"<<EVS ssl_session_cache shared:SSL:10m; ssl_session_timeout 60m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; EVS fi if [ ! -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" ]; then cat > "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf"<<EVT ssl_dhparam /usr/local/nginx/conf/ssl/${vhostname}/dhparam.pem; ssl_certificate /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt; ssl_certificate_key /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.key; #ssl_trusted_certificate /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-trusted.crt; EVT fi cd /usr/local/nginx/conf/ssl/${vhostname} cecho "---------------------------------------------------------------" $boldyellow cecho "Generating self signed SSL certificate..." $boldgreen cecho "CSR file can also be used to be submitted for paid SSL certificates" $boldgreen cecho "If using for paid SSL certificates be sure to keep both private key and CSR safe" $boldgreen cecho "creating CSR File: ${vhostname}.csr" $boldgreen cecho "creating private key: ${vhostname}.key" $boldgreen cecho "creating self-signed SSL certificate: ${vhostname}.crt" $boldgreen sleep 9 if [[ -z "$SELFSIGNEDSSL_O" ]]; then SELFSIGNEDSSL_O="$vhostname" else SELFSIGNEDSSL_O="$SELFSIGNEDSSL_O" fi if [[ -z "$SELFSIGNEDSSL_OU" ]]; then SELFSIGNEDSSL_OU="$vhostname" else SELFSIGNEDSSL_OU="$SELFSIGNEDSSL_OU" fi if [[ "$SELFSIGNEDSSL_ECDSA" = [yY] ]]; then # self-signed ssl cert with SANs for ECDSA cat > /tmp/reqecc.cnf <<EOF [req] default_bits = 2048 distinguished_name = req_distinguished_name req_extensions = v3_req prompt = no [req_distinguished_name] C = ${SELFSIGNEDSSL_C} ST = ${SELFSIGNEDSSL_ST} L = ${SELFSIGNEDSSL_L} O = ${vhostname} OU = ${vhostname} CN = ${vhostname} [v3_req] keyUsage = keyEncipherment, dataEncipherment extendedKeyUsage = serverAuth subjectAltName = @alt_names [alt_names] DNS.1 = ${vhostname} DNS.2 = www.${vhostname} EOF cat > /tmp/v3extecc.cnf <<EOF authorityKeyIdentifier=keyid,issuer basicConstraints=CA:FALSE keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment subjectAltName = @alt_names [alt_names] DNS.1 = ${vhostname} DNS.2 = www.${vhostname} EOF openssl ecparam -out ${vhostname}.key -name prime256v1 -genkey openssl req -new -sha256 -key ${vhostname}.key -nodes -out ${vhostname}.csr -config /tmp/reqecc.cnf openssl x509 -req -days 36500 -sha256 -in ${vhostname}.csr -signkey ${vhostname}.key -out ${vhostname}.crt -extfile /tmp/v3extecc.cnf openssl x509 -noout -text < ${vhostname}.crt rm -f /tmp/reqecc.cnf rm -f /tmp/v3extecc.cnf else # self-signed ssl cert with SANs cat > /tmp/req.cnf <<EOF [req] default_bits = 2048 distinguished_name = req_distinguished_name req_extensions = v3_req prompt = no [req_distinguished_name] C = ${SELFSIGNEDSSL_C} ST = ${SELFSIGNEDSSL_ST} L = ${SELFSIGNEDSSL_L} O = ${vhostname} OU = ${vhostname} CN = ${vhostname} [v3_req] keyUsage = keyEncipherment, dataEncipherment extendedKeyUsage = serverAuth subjectAltName = @alt_names [alt_names] DNS.1 = ${vhostname} DNS.2 = www.${vhostname} EOF cat > /tmp/v3ext.cnf <<EOF authorityKeyIdentifier=keyid,issuer basicConstraints=CA:FALSE keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment subjectAltName = @alt_names [alt_names] DNS.1 = ${vhostname} DNS.2 = www.${vhostname} EOF echo cat /tmp/req.cnf echo cat /tmp/v3ext.cnf echo openssl req -new -newkey rsa:2048 -sha256 -nodes -out ${vhostname}.csr -keyout ${vhostname}.key -config /tmp/req.cnf # openssl req -new -newkey rsa:2048 -sha256 -nodes -out ${vhostname}.csr -keyout ${vhostname}.key -subj "/C=${SELFSIGNEDSSL_C}/ST=${SELFSIGNEDSSL_ST}/L=${SELFSIGNEDSSL_L}/O=${vhostname}/OU=${vhostname}/CN=${vhostname}" openssl req -noout -text -in ${vhostname}.csr | grep DNS openssl x509 -req -days 36500 -sha256 -in ${vhostname}.csr -signkey ${vhostname}.key -out ${vhostname}.crt -extfile /tmp/v3ext.cnf # openssl req -x509 -nodes -days 36500 -sha256 -newkey rsa:2048 -keyout ${vhostname}.key -out ${vhostname}.crt -config /tmp/req.cnf rm -f /tmp/req.cnf rm -f /tmp/v3ext.cnf fi echo cecho "---------------------------------------------------------------" $boldyellow cecho "Generating dhparam.pem file - can take a few minutes..." $boldgreen dhparamstarttime=$(TZ=UTC date +%s.%N) openssl dhparam -out dhparam.pem 2048 dhparamendtime=$(TZ=UTC date +%s.%N) DHPARAMTIME=$(echo "$dhparamendtime-$dhparamstarttime"|bc) cecho "dhparam file generation time: $DHPARAMTIME" $boldyellow # main hostname's ssl vhost at virual.ssl.conf cat > "${MAIN_HOSTNAMEVHOSTSSLFILE}"<<ESS # Centmin Mod Getting Started Guide # must read https://centminmod.com/getstarted.html # For HTTP/2 SSL Setup # read https://centminmod.com/nginx_configure_https_ssl_HTTP/2.html # redirect from www to non-www forced SSL # uncomment, save file and restart Nginx to enable # if unsure use return 302 before using return 301 # server { # listen ${DEDI_IP}80; # server_name ${vhostname} www.${vhostname}; # return 302 https://\${vhostname}\$request_uri; # } server { listen ${DEDI_IP}443 default_server $LISTENOPT; server_name $vhostname; include /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf; include /usr/local/nginx/conf/ssl_include.conf; $CFAUTHORIGINPULL_INCLUDES $HTTPTWO_MAXFIELDSIZE $HTTPTWO_MAXHEADERSIZE $HTTPTWO_MAXREQUESTS # mozilla recommended ssl_ciphers ${TLSONETHREE_CIPHERS}ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:${CHACHACIPHERS}DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS; ssl_prefer_server_ciphers on; $SPDY_HEADER # before enabling HSTS line below read centminmod.com/nginx_domain_dns_setup.html#hsts #add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;"; #add_header X-Frame-Options SAMEORIGIN; add_header X-Xss-Protection "1; mode=block" always; add_header X-Content-Type-Options "nosniff" always; #add_header Referrer-Policy "strict-origin-when-cross-origin"; #add_header Permissions-Policy "accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=()"; $COMP_HEADER; ssl_buffer_size 1369; ssl_session_tickets on; # enable ocsp stapling #resolver 8.8.8.8 8.8.4.4 1.1.1.1 1.0.0.1 valid=10m; #resolver_timeout 10s; #ssl_stapling on; #ssl_stapling_verify on; # ngx_pagespeed & ngx_pagespeed handler #include /usr/local/nginx/conf/pagespeed.conf; #include /usr/local/nginx/conf/pagespeedhandler.conf; #include /usr/local/nginx/conf/pagespeedstatslog.conf; # limit_conn limit_per_ip 16; # ssi on; location /nginx_status { stub_status on; access_log off; allow 127.0.0.1; #allow youripaddress; deny all; } access_log /var/log/nginx/localhost.access.ssl.log main buffer=256k flush=5m; error_log /var/log/nginx/localhost.error.ssl.log error; #include /usr/local/nginx/conf/autoprotect/$vhostname/autoprotect-$vhostname.conf; root html; # uncomment cloudflare.conf include if using cloudflare for # server and/or vhost site #include /usr/local/nginx/conf/cloudflare.conf; location / { # block common exploits, sql injections etc #include /usr/local/nginx/conf/block.conf; #Enables directory listings when index file not found #autoindex on; #Shows file listing times as local time #autoindex_localtime on; # Wordpress Permalinks example #try_files \$uri \$uri/ /index.php?q=\$uri&\$args; } include /usr/local/nginx/conf/php.conf; include /usr/local/nginx/conf/staticfiles.conf; include /usr/local/nginx/conf/include_opcache.conf; #include /usr/local/nginx/conf/phpstatus.conf; include /usr/local/nginx/conf/drop.conf; #include /usr/local/nginx/conf/errorpage.conf; include /usr/local/nginx/conf/vts_mainserver.conf; } ESS if [ -f /usr/bin/ngxreload ]; then /usr/bin/ngxreload fi else echo if [ -f "${MAIN_HOSTNAMEVHOSTSSLFILE}" ]; then echo "${MAIN_HOSTNAMEVHOSTSSLFILE} already exists" fi if [ -d "/home/nginx/domains/${vhostname}/public" ]; then echo "$vhostname setup already at /home/nginx/domains/${vhostname}/public" fi echo fi # "${MAIN_HOSTNAMEVHOSTSSLFILE}" doesn't exist } ##################### convert_crtkeyinc() { # if existing or previous /usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf has the ssl cert key and trust files # inline in vhost, need to move them to their own include file for acmetool.sh at # /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf if [[ ! -z "$(egrep 'ssl_dhparam|ssl_certificate|ssl_trusted_certificate' /usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf)" ]]; then egrep 'ssl_dhparam|ssl_certificate|ssl_trusted_certificate' /usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf > /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf fi echo "cat /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" cat /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf sed -i "s|^[ \t]* ssl_dhparam .*| include \/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.crt.key.conf;|g" /usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf sed -i '/ssl_certificate/d' /usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf sed -i '/ssl_trusted_certificate/d' /usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf } ##################### convert_dualcrtkeyinclive() { cat > "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" <<EOF ssl_dhparam /usr/local/nginx/conf/ssl/${vhostname}/dhparam.pem; ssl_certificate /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme.cer; ssl_certificate_key /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme.key; ssl_certificate /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme-ecc.cer; ssl_certificate_key /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme-ecc.key; #ssl_trusted_certificate /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme.cer; #ssl_trusted_certificate /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme-ecc.cer; ssl_trusted_certificate /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-dualcert-rsa-ecc.cer; EOF cat "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme.cer" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme-ecc.cer" > "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-dualcert-rsa-ecc.cer" echo echo "setup ssl_trusted_certificate dual cert version:" echo "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-dualcert-rsa-ecc.cer" echo } ##################### convert_dualcrtkeyinctest() { cat > "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" <<EOF ssl_dhparam /usr/local/nginx/conf/ssl/${vhostname}/dhparam.pem; ssl_certificate /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme.cer; ssl_certificate_key /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme.key; ssl_certificate /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme-ecc.cer; ssl_certificate_key /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme-ecc.key; #ssl_trusted_certificate /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme.cer; #ssl_trusted_certificate /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme-ecc.cer; #ssl_trusted_certificate /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-dualcert-rsa-ecc.cer; EOF cat "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme.cer" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme-ecc.cer" > "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-dualcert-rsa-ecc.cer" echo echo "setup ssl_trusted_certificate dual cert version:" echo "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-dualcert-rsa-ecc.cer" echo } ##################### sslvhostsetup() { HTTPSONLY=$1 CHECKFORWP=$2 echo echo "[self-signed ssl cert check] required by acmetool.sh" echo if [ ! -f /usr/local/nginx/conf/ssl ]; then mkdir -p /usr/local/nginx/conf/ssl fi # check if self-signed ssl certificate files exist and if not generate them # otherwise, if user created the nginx vhost prior to running acmetool.sh with # self-signed ssl cert prompt answered as no, these self-signed ssl certificates # that acmetool.sh relies on initially won't exist and result in file not found # errors https://community.centminmod.com/posts/36759/ if [[ ! -d "/usr/local/nginx/conf/ssl/${vhostname}" || ! -f "/usr/local/nginx/conf/ssl/${vhostname}/dhparam.pem" || ! -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt" ]]; then gen_selfsigned "$vhostname" else if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/dhparam.pem" ]; then echo "[self-signed ssl] /usr/local/nginx/conf/ssl/${vhostname}/dhparam.pem exists" fi if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt" ]; then echo "[self-signed ssl] /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt exists" fi if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.key" ]; then echo "[self-signed ssl] /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.key exists" fi fi echo echo "[sslvhostsetup] create /usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" echo # Support secondary dedicated IP configuration for centmin mod # nginx vhost generator, so out of the box, new nginx vhosts # generated will use the defined SECOND_IP=111.222.333.444 where # the IP is a secondary IP addressed added to the server. # You define SECOND_IP variable is centmin mod persistent config # file outlined at https://centminmod.com/upgrade.html#persistent # you manually creat the file at /etc/centminmod/custom_config.inc # and add SECOND_IP=yoursecondary_IPaddress variable to it which # will be registered with nginx vhost generator routine so that # any new nginx vhosts created via centmin.sh menu option 2 or # /usr/bin/nv or centmin.sh menu option 22, will have pre-defined # SECOND_IP ip address set in the nginx vhost's listen directive if [[ -z "$SECOND_IP" ]]; then DEDI_IP="" DEDI_LISTEN="" elif [[ "$SECOND_IP" ]]; then DEDI_IP=$(echo $(echo ${SECOND_IP}:)) DEDI_LISTEN="listen ${DEDI_IP}80;" fi if [ ! -f /usr/local/nginx/conf/ssl_include.conf ]; then cat > "/usr/local/nginx/conf/ssl_include.conf"<<EVS ssl_session_cache shared:SSL:10m; ssl_session_timeout 60m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; EVS fi if [ ! -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" ]; then cat > "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf"<<EVT ssl_dhparam /usr/local/nginx/conf/ssl/${vhostname}/dhparam.pem; ssl_certificate /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt; ssl_certificate_key /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.key; #ssl_trusted_certificate /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-trusted.crt; EVT fi detectcustom_webroot $CUSTOM_WEBROOT $vhostname ### ############################################################## if [[ "$HTTPSONLY" = 'https' && "$CHECKFORWP" = 'wp' ]]; then echo "[wp] backup & remove /usr/local/nginx/conf/conf.d/$vhostname.conf" cp -a "/usr/local/nginx/conf/conf.d/$vhostname.conf" "${ACMEBACKUPDIR}/$vhostname.conf-backup-removal-https-default-${DT}" >/dev/null 2>&1 >/dev/null 2>&1 #rm -rf "/usr/local/nginx/conf/conf.d/$vhostname.conf" >/dev/null 2>&1 # remove 1st 12 lines of wp generated yourdomain.com.ssl.conf # and insert http to https redirect # single ssl vhost at yourdomain.com.ssl.conf echo "[wp] create /usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" cat > "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf-wp1"<<ESU # Centmin Mod Getting Started Guide # must read https://centminmod.com/getstarted.html # For HTTP/2 SSL Setup # read https://centminmod.com/nginx_configure_https_ssl_spdy.html # redirect from www to non-www forced SSL # uncomment, save file and restart Nginx to enable # if unsure use return 302 before using return 301 ##x# HTTPS-DEFAULT #x# server { #x# $DEDI_LISTEN #x# server_name ${vhostname} www.${vhostname}; #x# return 302 https://${vhostname}\$request_uri; #x# root /home/nginx/domains/$vhostname/public; #x# include /usr/local/nginx/conf/staticfiles.conf; #x# } ESU echo "cp -a "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf-wp2"" cp -a "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf-wp2" echo "sed -i '1,12d' "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf-wp2"" sed -i '1,12d' "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf-wp2" echo "cat "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf-wp1" "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf-wp2" > "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf"" cat "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf-wp1" "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf-wp2" > "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" rm -rf "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf-wp1" rm -rf "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf-wp2" if [[ ! -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" && -f "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" ]]; then # if existing or previous /usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf has the ssl cert key and trust files # inline in vhost, need to move them to their own include file for acmetool.sh at # /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf convert_crtkeyinc elif [[ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" && -f "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" ]]; then convert_crtkeyinc fi ### ############################################################## elif [[ "$HTTPSONLY" = 'https' && -z "$CHECKFORWP" ]]; then echo "[non-wp] backup & remove /usr/local/nginx/conf/conf.d/$vhostname.conf" cp -a "/usr/local/nginx/conf/conf.d/$vhostname.conf" "${ACMEBACKUPDIR}/$vhostname.conf-backup-removal-https-default-${DT}" >/dev/null 2>&1 >/dev/null 2>&1 #rm -rf "/usr/local/nginx/conf/conf.d/$vhostname.conf" >/dev/null 2>&1 if [[ ! -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" && -f "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" ]]; then # if existing or previous /usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf has the ssl cert key and trust files # inline in vhost, need to move them to their own include file for acmetool.sh at # /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf convert_crtkeyinc elif [[ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" && -f "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" ]]; then convert_crtkeyinc fi if [[ -f "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" && ! "$(grep '^#x# return 302' "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf")" ]]; then # insert http to https redirect if yourdomain.com.ssl.conf exists # single ssl vhost at yourdomain.com.ssl.conf if [ -f "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" ]; then if [[ ! "$(grep '^#x# HTTPS-DEFAULT' "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf")" ]]; then cat > "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf-nonwp1"<<ESV # Centmin Mod Getting Started Guide # must read https://centminmod.com/getstarted.html # For HTTP/2 SSL Setup # read https://centminmod.com/nginx_configure_https_ssl_spdy.html # redirect from www to non-www forced SSL # uncomment, save file and restart Nginx to enable # if unsure use return 302 before using return 301 ##x# HTTPS-DEFAULT #x# server { #x# $DEDI_LISTEN #x# server_name ${vhostname} www.${vhostname}; #x# return 302 https://${vhostname}\$request_uri; #x# root /home/nginx/domains/$vhostname/public; #x# include /usr/local/nginx/conf/staticfiles.conf; #x# } ESV echo "cp -a "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf-nonwp2"" cp -a "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf-nonwp2" echo "cat "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf-nonwp1" "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf-nonwp2" > "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf"" cat "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf-nonwp1" "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf-nonwp2" > "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" rm -rf "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf-nonwp1" rm -rf "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf-nonwp2" fi # check for ^#x# HTTPS-DEFAULT to indicate an exisiting HTTPS default ssl vhost fi elif [ ! -f "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" ]; then # single ssl vhost at yourdomain.com.ssl.conf echo "create /usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" cat > "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf"<<ESS # Centmin Mod Getting Started Guide # must read https://centminmod.com/getstarted.html # For HTTP/2 SSL Setup # read https://centminmod.com/nginx_configure_https_ssl_spdy.html # redirect from www to non-www forced SSL # uncomment, save file and restart Nginx to enable # if unsure use return 302 before using return 301 ##x# HTTPS-DEFAULT #x# server { #x# $DEDI_LISTEN #x# server_name ${vhostname} www.${vhostname}; #x# return 302 https://${vhostname}\$request_uri; #x# root /home/nginx/domains/$vhostname/public; #x# include /usr/local/nginx/conf/staticfiles.conf; #x# } server { listen ${DEDI_IP}443 $LISTENOPT; server_name $vhostname www.$vhostname; include /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf; include /usr/local/nginx/conf/ssl_include.conf; $CFAUTHORIGINPULL_INCLUDES $HTTPTWO_MAXFIELDSIZE $HTTPTWO_MAXHEADERSIZE $HTTPTWO_MAXREQUESTS # mozilla recommended ssl_ciphers ${TLSONETHREE_CIPHERS}ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:${CHACHACIPHERS}DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS; ssl_prefer_server_ciphers on; $SPDY_HEADER # before enabling HSTS line below read centminmod.com/nginx_domain_dns_setup.html#hsts #add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;"; #add_header X-Frame-Options SAMEORIGIN; add_header X-Xss-Protection "1; mode=block" always; add_header X-Content-Type-Options "nosniff" always; #add_header Referrer-Policy "strict-origin-when-cross-origin"; #add_header Permissions-Policy "accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=()"; $COMP_HEADER; ssl_buffer_size 1369; ssl_session_tickets on; # enable ocsp stapling #resolver 8.8.8.8 8.8.4.4 1.1.1.1 1.0.0.1 valid=10m; #resolver_timeout 10s; #ssl_stapling on; #ssl_stapling_verify on; # ngx_pagespeed & ngx_pagespeed handler #include /usr/local/nginx/conf/pagespeed.conf; #include /usr/local/nginx/conf/pagespeedhandler.conf; #include /usr/local/nginx/conf/pagespeedstatslog.conf; # limit_conn limit_per_ip 16; # ssi on; access_log /home/nginx/domains/$vhostname/log/access.log $NGX_LOGFORMAT buffer=256k flush=5m; error_log /home/nginx/domains/$vhostname/log/error.log; include /usr/local/nginx/conf/autoprotect/$vhostname/autoprotect-$vhostname.conf; root /home/nginx/domains/$vhostname/public; # uncomment cloudflare.conf include if using cloudflare for # server and/or vhost site #include /usr/local/nginx/conf/cloudflare.conf; include /usr/local/nginx/conf/503include-main.conf; location / { include /usr/local/nginx/conf/503include-only.conf; # block common exploits, sql injections etc #include /usr/local/nginx/conf/block.conf; # Enables directory listings when index file not found #autoindex on; # Shows file listing times as local time #autoindex_localtime on; # Wordpress Permalinks example #try_files \$uri \$uri/ /index.php?q=\$uri&\$args; } include /usr/local/nginx/conf/php.conf; include /usr/local/nginx/conf/staticfiles.conf; include /usr/local/nginx/conf/drop.conf; #include /usr/local/nginx/conf/errorpage.conf; include /usr/local/nginx/conf/vts_server.conf; } ESS fi ### ############################################################## elif [[ "$HTTPSONLY" != 'https' && -z "$CHECKFORWP" ]]; then if [[ ! -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" && -f "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" ]]; then # if existing or previous /usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf has the ssl cert key and trust files # inline in vhost, need to move them to their own include file for acmetool.sh at # /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf convert_crtkeyinc elif [[ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" && -f "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" ]]; then convert_crtkeyinc fi if [ -f "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" ]; then echo echo "skip /usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf creation" echo "already exists" echo elif [ ! -f "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" ]; then cat > "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf"<<ESS # Centmin Mod Getting Started Guide # must read https://centminmod.com/getstarted.html # For HTTP/2 SSL Setup # read https://centminmod.com/nginx_configure_https_ssl_HTTP/2.html # redirect from www to non-www forced SSL # uncomment, save file and restart Nginx to enable # if unsure use return 302 before using return 301 # server { # listen ${DEDI_IP}80; # server_name ${vhostname} www.${vhostname}; # return 302 https://${vhostname}\$request_uri; # } server { listen ${DEDI_IP}443 $LISTENOPT; server_name $vhostname www.$vhostname; include /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf; include /usr/local/nginx/conf/ssl_include.conf; $CFAUTHORIGINPULL_INCLUDES $HTTPTWO_MAXFIELDSIZE $HTTPTWO_MAXHEADERSIZE $HTTPTWO_MAXREQUESTS # mozilla recommended ssl_ciphers ${TLSONETHREE_CIPHERS}ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:${CHACHACIPHERS}DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS; ssl_prefer_server_ciphers on; $SPDY_HEADER # before enabling HSTS line below read centminmod.com/nginx_domain_dns_setup.html#hsts #add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;"; #add_header X-Frame-Options SAMEORIGIN; add_header X-Xss-Protection "1; mode=block" always; add_header X-Content-Type-Options "nosniff" always; #add_header Referrer-Policy "strict-origin-when-cross-origin"; #add_header Permissions-Policy "accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=()"; $COMP_HEADER; ssl_buffer_size 1369; ssl_session_tickets on; # enable ocsp stapling #resolver 8.8.8.8 8.8.4.4 1.1.1.1 1.0.0.1 valid=10m; #resolver_timeout 10s; #ssl_stapling on; #ssl_stapling_verify on; # ngx_pagespeed & ngx_pagespeed handler #include /usr/local/nginx/conf/pagespeed.conf; #include /usr/local/nginx/conf/pagespeedhandler.conf; #include /usr/local/nginx/conf/pagespeedstatslog.conf; # limit_conn limit_per_ip 16; # ssi on; access_log /home/nginx/domains/$vhostname/log/access.log $NGX_LOGFORMAT buffer=256k flush=5m; error_log /home/nginx/domains/$vhostname/log/error.log; include /usr/local/nginx/conf/autoprotect/$vhostname/autoprotect-$vhostname.conf; root $WEBROOTPATH; # uncomment cloudflare.conf include if using cloudflare for # server and/or vhost site #include /usr/local/nginx/conf/cloudflare.conf; include /usr/local/nginx/conf/503include-main.conf; location / { include /usr/local/nginx/conf/503include-only.conf; # block common exploits, sql injections etc #include /usr/local/nginx/conf/block.conf; # Enables directory listings when index file not found #autoindex on; # Shows file listing times as local time #autoindex_localtime on; # Wordpress Permalinks example #try_files \$uri \$uri/ /index.php?q=\$uri&\$args; } include /usr/local/nginx/conf/php.conf; include /usr/local/nginx/conf/staticfiles.conf; include /usr/local/nginx/conf/drop.conf; #include /usr/local/nginx/conf/errorpage.conf; include /usr/local/nginx/conf/vts_server.conf; } ESS fi # if ssl vhost exists fi if [ -f /usr/bin/ngxreload ]; then /usr/bin/ngxreload fi } ##################### issue_acme() { check_acmeinstall # split domains for SAN SSL certs split_domains "$vhostname" if [[ "$vhostname" != "$MAIN_HOSTNAME" ]]; then SSLVHOST_CONFIGFILENAME="${vhostname}.ssl.conf" SSLVHOST_CONFIG="/usr/local/nginx/conf/conf.d/${SSLVHOST_CONFIGFILENAME}" WEBROOTPATH_OPT="/home/nginx/domains/${vhostname}/public" VHOST_ALREADYSET='n' elif [[ "$vhostname" = "$MAIN_HOSTNAME" ]]; then SSLVHOST_CONFIGFILENAME="${MAIN_HOSTNAMEVHOSTSSLFILE}" SSLVHOST_CONFIG="/usr/local/nginx/conf/conf.d/${MAIN_HOSTNAMEVHOSTSSLFILE}" WEBROOTPATH_OPT="/usr/local/nginx/html" if [ -d "/home/nginx/domains/${vhostname}/public" ]; then echo "$vhostname setup already at /home/nginx/domains/${vhostname}/public" VHOST_ALREADYSET='y' fi fi # if webroot path directory does not exists # + ssl vhost file does not exist if [[ ! -d "$WEBROOTPATH_OPT" && ! -f "$SSLVHOST_CONFIG" ]]; then echo echo "${vhostname} nginx vhost + pureftp virtual ftp user setup" if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then vhostsetup "${vhostname}" https else vhostsetup "${vhostname}" fi # if webroot path directory exists # + ssl vhost file does not exist # + no ssl_certificate line exists in the non-https vhost file elif [[ -d "$WEBROOTPATH_OPT" && ! -f "$SSLVHOST_CONFIG" ]] && [[ "$(grep -sq ssl_certificate /usr/local/nginx/conf/conf.d/${vhostname}.conf; echo $?)" != '0' ]]; then sslopts_check if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then sslvhostsetup https else sslvhostsetup fi # if webroot path directory exists # + ssl vhost file does not exist # + ssl_certificates line exists in non-https vhost file elif [[ -d "$WEBROOTPATH_OPT" ]] && [[ "$(grep -sq ssl_certificate /usr/local/nginx/conf/conf.d/${vhostname}.conf; echo $?)" = '0' ]] && [[ ! -f "$SSLVHOST_CONFIG" ]]; then if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then sslvhostsetup https else sslvhostsetup fi mv "$SSLVHOST_CONFIG" "${ACMEBACKUPDIR}/${SSLVHOST_CONFIGFILENAME}-acmebackup-${DT}-disabled" SSLVHOST_CONFIG="${ACMEBACKUPDIR}/${SSLVHOST_CONFIGFILENAME}-acmebackup-${DT}-disabled" fi # if webroot path directory exists # + vhostname value exists # + ssl vhost file exists # + not main hostname VHOST_ALREADYSET if [[ -d "$WEBROOTPATH_OPT" && ! -z "$vhostname" && -f "$SSLVHOST_CONFIG" && "$VHOST_ALREADYSET" != 'y' ]]; then check_dns "$vhostname" if [[ "$TOPLEVEL" = [yY] ]]; then if [[ "$SAN" = '1' ]]; then DOMAINOPT="-d $DOMAIN_LIST -d www.${vhostname}" else DOMAINOPT="-d ${vhostname} -d www.${vhostname}" fi else if [[ "$SAN" = '1' ]]; then DOMAINOPT="-d $DOMAIN_LIST" else DOMAINOPT="-d ${vhostname}" fi fi if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then # if https default via d or lived option, then backup non-https vhostname.conf to backup directory # and remove the non-https vhostname.conf file echo "backup & remove /usr/local/nginx/conf/conf.d/$vhostname.conf" cp -a "/usr/local/nginx/conf/conf.d/$vhostname.conf" "${ACMEBACKUPDIR}/$vhostname.conf-backup-removal-https-default-${DT}" >/dev/null 2>&1 #rm -rf "/usr/local/nginx/conf/conf.d/$vhostname.conf" >/dev/null 2>&1 # if existing https vhostname.ssl.conf file exists replace it with one with proper http to https redirect if [ -f "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf" ]; then # sslvhostsetup https $vhostname sslopts_check sslvhostsetup https if [[ "$(grep '^#x# return 302' "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf")" ]]; then switch_httpsdefault fi fi elif [[ "$testcert" = 'wplived' || "$testcert" = 'wptestd' ]]; then # if https default via d or lived option, then backup non-https vhostname.conf to backup directory # and remove the non-https vhostname.conf file echo "backup & remove /usr/local/nginx/conf/conf.d/$vhostname.conf" cp -a "/usr/local/nginx/conf/conf.d/$vhostname.conf" "${ACMEBACKUPDIR}/$vhostname.conf-backup-removal-https-default-${DT}" >/dev/null 2>&1 #rm -rf "/usr/local/nginx/conf/conf.d/$vhostname.conf" >/dev/null 2>&1 # if existing https vhostname.ssl.conf file exists replace it with one with proper http to https redirect if [ -f "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf" ]; then # sslvhostsetup https $vhostname sslopts_check sslvhostsetup https wp if [[ "$(grep '^#x# return 302' "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf")" ]]; then switch_httpsdefault fi fi else cp -a "/usr/local/nginx/conf/conf.d/$vhostname.conf" "${ACMEBACKUPDIR}/$vhostname.conf-acmebackup-$DT" >/dev/null 2>&1 fi cp -a "$SSLVHOST_CONFIG" "${ACMEBACKUPDIR}/$SSLVHOST_CONFIGFILENAME-acmebackup-$DT" if [[ "$testcert" != 'lived' || "$testcert" != 'd' || "$testcert" != 'wplived' || "$testcert" != 'wpd' ]]; then if [ -f "/usr/local/nginx/conf/conf.d/$vhostname.conf" ]; then sed -i "s|server_name .*|server_name $DOMAIN_LISTNGX;|" "/usr/local/nginx/conf/conf.d/$vhostname.conf" echo "grep 'root' "/usr/local/nginx/conf/conf.d/$vhostname.conf"" grep 'root' "/usr/local/nginx/conf/conf.d/$vhostname.conf" fi if [[ ! -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" && -f "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" ]]; then # if existing or previous /usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf has the ssl cert key and trust files # inline in vhost, need to move them to their own include file for acmetool.sh at # /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf convert_crtkeyinc fi fi sed -i "s|server_name .*|server_name $DOMAIN_LISTNGX;|" "$SSLVHOST_CONFIG" echo "grep 'root' $SSLVHOST_CONFIG" grep 'root' "$SSLVHOST_CONFIG" /usr/bin/ngxreload >/dev/null 2>&1 echo echo "-----------------------------------------------------------" echo "issue & install letsencrypt ssl certificate for $vhostname" echo "-----------------------------------------------------------" # if the option flag = live is not passed on command line, the issuance uses the # staging test ssl certificates echo "testcert value = $testcert" if [[ "$testcert" = 'live' || "$testcert" = 'lived' || "$testcert" != 'd' ]] && [[ "$testcert" != 'wplive' && "$testcert" != 'wplived' && "$testcert" != 'wptestd' ]] && [[ "$testcert" != 'wptest' ]] && [[ ! -z "$testcert" ]]; then echo ""$ACMEBINARY"${ACME_APIENDPOINT}${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT}${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} LECHECK=$? # only enable resolver and ssl_stapling for live ssl certificate deployments if [[ -f "$SSLVHOST_CONFIG" && "$LECHECK" = '0' ]]; then sed -i "s|#resolver |resolver |" "$SSLVHOST_CONFIG" sed -i "s|#resolver_timeout|resolver_timeout|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling on|ssl_stapling on|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling_verify|ssl_stapling_verify|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "$SSLVHOST_CONFIG" if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" ]; then sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" fi # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' ]]; then echo echo "get 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY"${ACME_APIENDPOINT}${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT}${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} DUAL_LECHECK=$? if [[ "$DUAL_LECHECK" = '0' ]]; then echo echo "success: 2nd SSL cert issued for dual ssl cert config" echo else echo echo "failed: 2nd SSL cert issuance failed for dual ssl cert config" echo fi fi # dual cert routine end if [[ "$testcert" = 'lived' || "$testcert" = 'wplived' ]]; then echo echo "switch to HTTPS default after verification" echo switch_httpsdefault fi fi elif [[ "$testcert" = 'wplive' || "$testcert" = 'wplived' || "$testcert" != 'wptestd' ]] && [[ "$testcert" != 'wptest' ]] && [[ "$testcert" != 'd' ]] && [[ ! -z "$testcert" ]]; then echo "wp routine detected use reissue instead via --force" echo ""$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} LECHECK=$? # only enable resolver and ssl_stapling for live ssl certificate deployments if [[ -f "$SSLVHOST_CONFIG" && "$LECHECK" = '0' ]]; then sed -i "s|#resolver |resolver |" "$SSLVHOST_CONFIG" sed -i "s|#resolver_timeout|resolver_timeout|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling on|ssl_stapling on|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling_verify|ssl_stapling_verify|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "$SSLVHOST_CONFIG" if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" ]; then sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" fi # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' ]]; then echo echo "get 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} DUAL_LECHECK=$? if [[ "$DUAL_LECHECK" = '0' ]]; then echo echo "success: 2nd SSL cert issued for dual ssl cert config" echo else echo echo "failed: 2nd SSL cert issuance failed for dual ssl cert config" echo fi fi # dual cert routine end if [[ "$testcert" = 'lived' || "$testcert" = 'wplived' ]]; then echo echo "switch to HTTPS default after verification" echo switch_httpsdefault fi fi else testcert_dual=y echo ""$ACMEBINARY"${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} LECHECK=$? if [[ "$LECHECK" = '0' ]]; then # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' ]]; then echo echo "get 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY"${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} DUAL_LECHECK=$? if [[ "$DUAL_LECHECK" = '0' ]]; then echo echo "success: 2nd SSL cert issued for dual ssl cert config" echo else echo echo "failed: 2nd SSL cert issuance failed for dual ssl cert config" echo fi fi # dual cert routine end if [[ "$testcert" = 'wptestd' || "$testcert" = 'd' ]]; then echo echo "switch to HTTPS default after verification" echo switch_httpsdefault fi fi fi # LECHECK=$? echo "LECHECK = $LECHECK" if [[ "$LECHECK" = '0' ]]; then if [[ "$KEYLENGTH" = 'ec-256' || "$KEYLENGTH" = 'ec-384' ]]; then sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.key|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.key|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-trusted.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" else sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.key|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.key|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-trusted.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" fi egrep 'ssl_dhparam|ssl_certificate|ssl_certificate_key|ssl_trusted_certificate' "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" | tee /usr/local/nginx/conf/ssl/${vhostname}/acme-vhost-config.txt echo echo "-----------------------------------------------------------" echo "install cert" echo "-----------------------------------------------------------" # ensure directory exists before installing and copying ssl cert files # to /usr/local/nginx/conf/ssl/${vhostname} if [ ! -d "/usr/local/nginx/conf/ssl/${vhostname}" ]; then mkdir -p "/usr/local/nginx/conf/ssl/${vhostname}" fi echo ""$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIX}.key"${ECCFLAG}" "$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIX}.key"${ECCFLAG} if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" ]; then chmod 0644 "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" fi if [ -f "${CENTMINLOGDIR}/centminmod_${DT}_nginx_addvhost_nv-remove-cmds-${vhostname}.log" ]; then echo "rm -rf ${ACMECERTHOME}/${vhostname}" >> "${CENTMINLOGDIR}/centminmod_${DT}_nginx_addvhost_nv-remove-cmds-${vhostname}.log" fi # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' && "$DUAL_LECHECK" -eq '0' ]]; then echo echo "install 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIXDUAL}.key"${ECCFLAG_DUAL}" "$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIXDUAL}.key"${ECCFLAG_DUAL} if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" ]; then chmod 0644 "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" fi if [[ "$testcert_dual" = [yY] ]]; then convert_dualcrtkeyinctest else convert_dualcrtkeyinclive fi fi # dual cert routine end # allow it to be repopulated each time with $vhostname # rm -rf /root/.acme.sh/reload.sh echo echo "letsencrypt ssl certificate setup completed" echo "ssl certs located at: /usr/local/nginx/conf/ssl/${vhostname}" pushover_alert $vhostname backup_acme $vhostname echo echo "openssl x509 -noout -text < "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer"" openssl x509 -noout -text < "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" listlogs echo elif [[ "$LECHECK" = '1' ]]; then listlogs echo elif [[ "$LECHECK" = '2' ]]; then echo echo "issue skipped as ssl cert still valid" listlogs echo fi # reloadcmd_setup fi } ##################### reissue_acme() { check_acmeinstall # split domains for SAN SSL certs split_domains "$vhostname" if [[ "$vhostname" != "$MAIN_HOSTNAME" ]]; then SSLVHOST_CONFIGFILENAME="${vhostname}.ssl.conf" SSLVHOST_CONFIG="/usr/local/nginx/conf/conf.d/${SSLVHOST_CONFIGFILENAME}" WEBROOTPATH_OPT="/home/nginx/domains/${vhostname}/public" VHOST_ALREADYSET='n' elif [[ "$vhostname" = "$MAIN_HOSTNAME" ]]; then SSLVHOST_CONFIGFILENAME="${MAIN_HOSTNAMEVHOSTSSLFILE}" SSLVHOST_CONFIG="/usr/local/nginx/conf/conf.d/${MAIN_HOSTNAMEVHOSTSSLFILE}" WEBROOTPATH_OPT="/usr/local/nginx/html" if [ -d "/home/nginx/domains/${vhostname}/public" ]; then echo "$vhostname setup already at /home/nginx/domains/${vhostname}/public" VHOST_ALREADYSET='y' fi fi # if webroot path directory does not exists # + ssl vhost file does not exist if [[ ! -d "$WEBROOTPATH_OPT" && ! -f "$SSLVHOST_CONFIG" ]]; then echo echo "${vhostname} nginx vhost + pureftp virtual ftp user setup" if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then vhostsetup "${vhostname}" https else vhostsetup "${vhostname}" fi # if webroot path directory exists # + ssl vhost file does not exist # + no ssl_certificate line exists in the non-https vhost file elif [[ -d "$WEBROOTPATH_OPT" && ! -f "$SSLVHOST_CONFIG" ]] && [[ "$(grep -sq ssl_certificate /usr/local/nginx/conf/conf.d/${vhostname}.conf; echo $?)" != '0' ]]; then sslopts_check if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then sslvhostsetup https else sslvhostsetup fi # if webroot path directory exists # + ssl vhost file does not exist # + ssl_certificates line exists in non-https vhost file elif [[ -d "$WEBROOTPATH_OPT" ]] && [[ "$(grep -sq ssl_certificate /usr/local/nginx/conf/conf.d/${vhostname}.conf; echo $?)" = '0' ]] && [[ ! -f "$SSLVHOST_CONFIG" ]]; then if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then sslvhostsetup https else sslvhostsetup fi mv "$SSLVHOST_CONFIG" "${ACMEBACKUPDIR}/${SSLVHOST_CONFIGFILENAME}-acmebackup-${DT}-disabled" SSLVHOST_CONFIG="${ACMEBACKUPDIR}/${SSLVHOST_CONFIGFILENAME}-acmebackup-${DT}-disabled" fi # if webroot path directory exists # + vhostname value exists # + ssl vhost file exists # + not main hostname VHOST_ALREADYSET if [[ -d "$WEBROOTPATH_OPT" && ! -z "$vhostname" && -f "$SSLVHOST_CONFIG" && "$VHOST_ALREADYSET" != 'y' ]]; then check_dns "$vhostname" if [[ "$TOPLEVEL" = [yY] ]]; then if [[ "$SAN" = '1' ]]; then DOMAINOPT="-d $DOMAIN_LIST -d www.${vhostname}" else DOMAINOPT="-d ${vhostname} -d www.${vhostname}" fi else if [[ "$SAN" = '1' ]]; then DOMAINOPT="-d $DOMAIN_LIST" else DOMAINOPT="-d ${vhostname}" fi fi if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then # if https default via d or lived option, then backup non-https vhostname.conf to backup directory # and remove the non-https vhostname.conf file echo "backup & remove /usr/local/nginx/conf/conf.d/$vhostname.conf" cp -a "/usr/local/nginx/conf/conf.d/$vhostname.conf" "${ACMEBACKUPDIR}/$vhostname.conf-backup-removal-https-default-${DT}" >/dev/null 2>&1 #rm -rf "/usr/local/nginx/conf/conf.d/$vhostname.conf" >/dev/null 2>&1 # if existing https vhostname.ssl.conf file exists replace it with one with proper http to https redirect if [ -f "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf" ]; then # sslvhostsetup https $vhostname sslopts_check sslvhostsetup https if [[ "$(grep '^#x# return 302' "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf")" ]]; then switch_httpsdefault fi fi elif [[ "$testcert" = 'wplived' || "$testcert" = 'wptestd' ]]; then # if https default via d or lived option, then backup non-https vhostname.conf to backup directory # and remove the non-https vhostname.conf file echo "backup & remove /usr/local/nginx/conf/conf.d/$vhostname.conf" cp -a "/usr/local/nginx/conf/conf.d/$vhostname.conf" "${ACMEBACKUPDIR}/$vhostname.conf-backup-removal-https-default-${DT}" >/dev/null 2>&1 #rm -rf "/usr/local/nginx/conf/conf.d/$vhostname.conf" >/dev/null 2>&1 # if existing https vhostname.ssl.conf file exists replace it with one with proper http to https redirect if [ -f "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf" ]; then # sslvhostsetup https $vhostname sslopts_check sslvhostsetup https wp if [[ "$(grep '^#x# return 302' "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf")" ]]; then switch_httpsdefault fi fi else cp -a "/usr/local/nginx/conf/conf.d/$vhostname.conf" "${ACMEBACKUPDIR}/$vhostname.conf-acmebackup-$DT" >/dev/null 2>&1 fi cp -a "$SSLVHOST_CONFIG" "${ACMEBACKUPDIR}/$SSLVHOST_CONFIGFILENAME-acmebackup-$DT" if [[ "$testcert" != 'lived' || "$testcert" != 'd' || "$testcert" != 'wplived' || "$testcert" != 'wpd' ]]; then if [ -f "/usr/local/nginx/conf/conf.d/$vhostname.conf" ]; then sed -i "s|server_name .*|server_name $DOMAIN_LISTNGX;|" "/usr/local/nginx/conf/conf.d/$vhostname.conf" echo "grep 'root' "/usr/local/nginx/conf/conf.d/$vhostname.conf"" grep 'root' "/usr/local/nginx/conf/conf.d/$vhostname.conf" fi if [[ ! -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" && -f "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" ]]; then # if existing or previous /usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf has the ssl cert key and trust files # inline in vhost, need to move them to their own include file for acmetool.sh at # /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf convert_crtkeyinc fi fi sed -i "s|server_name .*|server_name $DOMAIN_LISTNGX;|" "$SSLVHOST_CONFIG" echo "grep 'root' $SSLVHOST_CONFIG" grep 'root' "$SSLVHOST_CONFIG" /usr/bin/ngxreload >/dev/null 2>&1 echo echo "-----------------------------------------------------------" echo "reissue & install letsencrypt ssl certificate for $vhostname" echo "-----------------------------------------------------------" echo ""$ACMEBINARY" --force --createDomainKey $DOMAINOPT -k "$KEYLENGTH" --useragent "$LE_USERAGENT"" "$ACMEBINARY" --force --createDomainKey $DOMAINOPT -k "$KEYLENGTH" --useragent "$LE_USERAGENT" # if the option flag = live is not passed on command line, the issuance uses the # staging test ssl certificates echo "testcert value = $testcert" if [[ "$testcert" = 'live' || "$testcert" = 'lived' || "$testcert" != 'd' ]] && [[ "$testcert" != 'wplive' && "$testcert" != 'wplived' && "$testcert" != 'wptestd' ]] && [[ "$testcert" != 'wptest' ]] && [[ ! -z "$testcert" ]]; then echo ""$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} LECHECK=$? # only enable resolver and ssl_stapling for live ssl certificate deployments if [[ -f "$SSLVHOST_CONFIG" && "$LECHECK" = '0' ]]; then sed -i "s|#resolver |resolver |" "$SSLVHOST_CONFIG" sed -i "s|#resolver_timeout|resolver_timeout|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling on|ssl_stapling on|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling_verify|ssl_stapling_verify|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "$SSLVHOST_CONFIG" if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" ]; then sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" fi # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' ]]; then echo echo "get 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} DUAL_LECHECK=$? if [[ "$DUAL_LECHECK" = '0' ]]; then echo echo "success: 2nd SSL cert issued for dual ssl cert config" echo else echo echo "failed: 2nd SSL cert issuance failed for dual ssl cert config" echo fi fi # dual cert routine end if [[ "$testcert" = 'lived' || "$testcert" = 'wplived' ]]; then echo echo "switch to HTTPS default after verification" echo switch_httpsdefault fi fi elif [[ "$testcert" = 'wplive' || "$testcert" = 'wplived' || "$testcert" != 'wptestd' ]] && [[ "$testcert" != 'wptest' ]] && [[ "$testcert" != 'd' ]] && [[ ! -z "$testcert" ]]; then echo "wp routine" echo ""$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} LECHECK=$? # only enable resolver and ssl_stapling for live ssl certificate deployments if [[ -f "$SSLVHOST_CONFIG" && "$LECHECK" = '0' ]]; then sed -i "s|#resolver |resolver |" "$SSLVHOST_CONFIG" sed -i "s|#resolver_timeout|resolver_timeout|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling on|ssl_stapling on|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling_verify|ssl_stapling_verify|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "$SSLVHOST_CONFIG" if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" ]; then sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" fi # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' ]]; then echo echo "get 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} DUAL_LECHECK=$? if [[ "$DUAL_LECHECK" = '0' ]]; then echo echo "success: 2nd SSL cert issued for dual ssl cert config" echo else echo echo "failed: 2nd SSL cert issuance failed for dual ssl cert config" echo fi fi # dual cert routine end if [[ "$testcert" = 'lived' || "$testcert" = 'wplived' ]]; then echo echo "switch to HTTPS default after verification" echo switch_httpsdefault fi fi else testcert_dual=y echo ""$ACMEBINARY" --force${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY" --force${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} LECHECK=$? if [[ "$LECHECK" = '0' ]]; then # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' ]]; then echo echo "get 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY" --force${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY" --force${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} DUAL_LECHECK=$? if [[ "$DUAL_LECHECK" = '0' ]]; then echo echo "success: 2nd SSL cert issued for dual ssl cert config" echo else echo echo "failed: 2nd SSL cert issuance failed for dual ssl cert config" echo fi fi # dual cert routine end if [[ "$testcert" = 'wptestd' || "$testcert" = 'd' ]]; then echo echo "switch to HTTPS default after verification" echo switch_httpsdefault fi fi fi # LECHECK=$? echo "LECHECK = $LECHECK" if [[ "$LECHECK" = '0' ]]; then if [[ "$KEYLENGTH" = 'ec-256' || "$KEYLENGTH" = 'ec-384' ]]; then sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.key|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.key|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-trusted.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" else sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.key|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.key|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-trusted.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" fi egrep 'ssl_dhparam|ssl_certificate|ssl_certificate_key|ssl_trusted_certificate' "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" | tee /usr/local/nginx/conf/ssl/${vhostname}/acme-vhost-config.txt echo echo "-----------------------------------------------------------" echo "install cert" echo "-----------------------------------------------------------" # ensure directory exists before installing and copying ssl cert files # to /usr/local/nginx/conf/ssl/${vhostname} if [ ! -d "/usr/local/nginx/conf/ssl/${vhostname}" ]; then mkdir -p "/usr/local/nginx/conf/ssl/${vhostname}" fi echo ""$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIX}.key"${ECCFLAG}" "$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIX}.key"${ECCFLAG} if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" ]; then chmod 0644 "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" fi # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' && "$DUAL_LECHECK" -eq '0' ]]; then echo echo "install 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIXDUAL}.key"${ECCFLAG_DUAL}" "$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIXDUAL}.key"${ECCFLAG_DUAL} if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" ]; then chmod 0644 "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" fi if [[ "$testcert_dual" = [yY] ]]; then convert_dualcrtkeyinctest else convert_dualcrtkeyinclive fi fi # dual cert routine end # allow it to be repopulated each time with $vhostname # rm -rf /root/.acme.sh/reload.sh echo echo "letsencrypt ssl certificate setup completed" echo "ssl certs located at: /usr/local/nginx/conf/ssl/${vhostname}" pushover_alert $vhostname backup_acme $vhostname echo echo "openssl x509 -noout -text < "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer"" openssl x509 -noout -text < "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" listlogs echo elif [[ "$LECHECK" = '1' ]]; then listlogs echo elif [[ "$LECHECK" = '2' ]]; then echo echo "reissue / renewal skipped as ssl cert still valid" listlogs echo fi # reloadcmd_setup fi } ##################### reissue_acme_only() { check_acmeinstall # split domains for SAN SSL certs split_domains "$vhostname" if [[ "$vhostname" != "$MAIN_HOSTNAME" ]]; then SSLVHOST_CONFIGFILENAME="${vhostname}.ssl.conf" SSLVHOST_CONFIG="/usr/local/nginx/conf/conf.d/${SSLVHOST_CONFIGFILENAME}" WEBROOTPATH_OPT="/home/nginx/domains/${vhostname}/public" VHOST_ALREADYSET='n' elif [[ "$vhostname" = "$MAIN_HOSTNAME" ]]; then SSLVHOST_CONFIGFILENAME="${MAIN_HOSTNAMEVHOSTSSLFILE}" SSLVHOST_CONFIG="/usr/local/nginx/conf/conf.d/${MAIN_HOSTNAMEVHOSTSSLFILE}" WEBROOTPATH_OPT="/usr/local/nginx/html" if [ -d "/home/nginx/domains/${vhostname}/public" ]; then echo "$vhostname setup already at /home/nginx/domains/${vhostname}/public" VHOST_ALREADYSET='y' fi fi # if webroot path directory does not exists # + ssl vhost file does not exist # but skip creating nginx vhost as reissue-only is for reissue of SSL certificate # and doesn't touch existing Nginx vhosts if [[ ! -d "$WEBROOTPATH_OPT" && ! -f "$SSLVHOST_CONFIG" ]]; then echo echo "${vhostname} nginx vhost doesn't already exist at" echo "$SSLVHOST_CONFIG" echo "reissue-only command is for use with existing nginx HTTPS SSL based vhosts only" echo "aborting..." exit # if webroot path directory exists # + ssl vhost file does not exist # + no ssl_certificate line exists in the non-https vhost file elif [[ -d "$WEBROOTPATH_OPT" && ! -f "$SSLVHOST_CONFIG" ]] && [[ "$(grep -sq ssl_certificate /usr/local/nginx/conf/conf.d/${vhostname}.conf; echo $?)" != '0' ]]; then echo echo "${vhostname} nginx HTTPS SSL vhost doesn't already exist at" echo "$SSLVHOST_CONFIG" echo "reissue-only command is for use with existing nginx HTTPS SSL based vhosts only" echo "aborting..." exit # if webroot path directory exists # + ssl vhost file does not exist # + ssl_certificates line exists in non-https vhost file elif [[ -d "$WEBROOTPATH_OPT" ]] && [[ "$(grep -sq ssl_certificate /usr/local/nginx/conf/conf.d/${vhostname}.conf; echo $?)" = '0' ]] && [[ ! -f "$SSLVHOST_CONFIG" ]]; then echo echo "${vhostname} nginx HTTPS SSL vhost doesn't already exist at" echo "$SSLVHOST_CONFIG" echo "reissue-only command is for use with existing nginx HTTPS SSL based vhosts only" echo "aborting..." exit fi # if webroot path directory exists # + vhostname value exists # + ssl vhost file exists # + not main hostname VHOST_ALREADYSET if [[ -d "$WEBROOTPATH_OPT" && ! -z "$vhostname" && -f "$SSLVHOST_CONFIG" && "$VHOST_ALREADYSET" != 'y' ]]; then check_dns "$vhostname" if [[ "$TOPLEVEL" = [yY] ]]; then if [[ "$SAN" = '1' ]]; then DOMAINOPT="-d $DOMAIN_LIST -d www.${vhostname}" else DOMAINOPT="-d ${vhostname} -d www.${vhostname}" fi else if [[ "$SAN" = '1' ]]; then DOMAINOPT="-d $DOMAIN_LIST" else DOMAINOPT="-d ${vhostname}" fi fi if [[ ! -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" && -f "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" ]]; then # if existing or previous /usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf has the ssl cert key and trust files # inline in vhost, need to move them to their own include file for acmetool.sh at # /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf convert_crtkeyinc fi # do not modify existing nginx vhosts for reissue-only options # sed -i "s|server_name .*|server_name $DOMAIN_LISTNGX;|" "$SSLVHOST_CONFIG" echo "grep 'root' $SSLVHOST_CONFIG" grep 'root' "$SSLVHOST_CONFIG" /usr/bin/ngxreload >/dev/null 2>&1 echo echo "-----------------------------------------------------------" echo "reissue & install letsencrypt ssl certificate for $vhostname" echo "-----------------------------------------------------------" echo ""$ACMEBINARY" --force --createDomainKey $DOMAINOPT -k "$KEYLENGTH" --useragent "$LE_USERAGENT"" "$ACMEBINARY" --force --createDomainKey $DOMAINOPT -k "$KEYLENGTH" --useragent "$LE_USERAGENT" # if the option flag = live is not passed on command line, the issuance uses the # staging test ssl certificates echo "testcert value = $testcert" if [[ "$testcert" = 'live' ]]; then echo ""$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} LECHECK=$? # only enable resolver and ssl_stapling for live ssl certificate deployments if [[ -f "$SSLVHOST_CONFIG" && "$LECHECK" = '0' ]]; then sed -i "s|#resolver |resolver |" "$SSLVHOST_CONFIG" sed -i "s|#resolver_timeout|resolver_timeout|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling on|ssl_stapling on|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling_verify|ssl_stapling_verify|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "$SSLVHOST_CONFIG" if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" ]; then sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" fi # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' ]]; then echo echo "get 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} DUAL_LECHECK=$? if [[ "$DUAL_LECHECK" = '0' ]]; then echo echo "success: 2nd SSL cert issued for dual ssl cert config" echo else echo echo "failed: 2nd SSL cert issuance failed for dual ssl cert config" echo fi fi # dual cert routine end fi else testcert_dual=y echo ""$ACMEBINARY" --force${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY" --force${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} LECHECK=$? if [[ "$LECHECK" = '0' ]]; then # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' ]]; then echo echo "get 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY" --force${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY" --force${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} DUAL_LECHECK=$? if [[ "$DUAL_LECHECK" = '0' ]]; then echo echo "success: 2nd SSL cert issued for dual ssl cert config" echo else echo echo "failed: 2nd SSL cert issuance failed for dual ssl cert config" echo fi fi # dual cert routine end fi fi # LECHECK=$? echo "LECHECK = $LECHECK" if [[ "$LECHECK" = '0' ]]; then if [[ "$KEYLENGTH" = 'ec-256' || "$KEYLENGTH" = 'ec-384' ]]; then sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.key|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.key|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-trusted.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" else sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.key|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.key|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-trusted.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" fi egrep 'ssl_dhparam|ssl_certificate|ssl_certificate_key|ssl_trusted_certificate' "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" | tee /usr/local/nginx/conf/ssl/${vhostname}/acme-vhost-config.txt echo echo "-----------------------------------------------------------" echo "install cert" echo "-----------------------------------------------------------" # ensure directory exists before installing and copying ssl cert files # to /usr/local/nginx/conf/ssl/${vhostname} if [ ! -d "/usr/local/nginx/conf/ssl/${vhostname}" ]; then mkdir -p "/usr/local/nginx/conf/ssl/${vhostname}" fi echo ""$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIX}.key"${ECCFLAG}" "$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIX}.key"${ECCFLAG} if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" ]; then chmod 0644 "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" fi # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' && "$DUAL_LECHECK" -eq '0' ]]; then echo echo "install 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIXDUAL}.key"${ECCFLAG_DUAL}" "$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIXDUAL}.key"${ECCFLAG_DUAL} if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" ]; then chmod 0644 "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" fi if [[ "$testcert_dual" = [yY] ]]; then convert_dualcrtkeyinctest else convert_dualcrtkeyinclive fi fi # dual cert routine end # allow it to be repopulated each time with $vhostname # rm -rf /root/.acme.sh/reload.sh echo echo "letsencrypt ssl certificate setup completed" echo "ssl certs located at: /usr/local/nginx/conf/ssl/${vhostname}" pushover_alert $vhostname backup_acme $vhostname echo echo "openssl x509 -noout -text < "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer"" openssl x509 -noout -text < "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" listlogs echo elif [[ "$LECHECK" = '1' ]]; then listlogs echo elif [[ "$LECHECK" = '2' ]]; then echo echo "reissue / renewal skipped as ssl cert still valid" listlogs echo fi # reloadcmd_setup fi } renew_acme() { check_acmeinstall # split domains for SAN SSL certs split_domains "$vhostname" if [[ "$vhostname" != "$MAIN_HOSTNAME" ]]; then SSLVHOST_CONFIGFILENAME="${vhostname}.ssl.conf" SSLVHOST_CONFIG="/usr/local/nginx/conf/conf.d/${SSLVHOST_CONFIGFILENAME}" WEBROOTPATH_OPT="/home/nginx/domains/${vhostname}/public" VHOST_ALREADYSET='n' elif [[ "$vhostname" = "$MAIN_HOSTNAME" ]]; then SSLVHOST_CONFIGFILENAME="${MAIN_HOSTNAMEVHOSTSSLFILE}" SSLVHOST_CONFIG="/usr/local/nginx/conf/conf.d/${MAIN_HOSTNAMEVHOSTSSLFILE}" WEBROOTPATH_OPT="/usr/local/nginx/html" if [ -d "/home/nginx/domains/${vhostname}/public" ]; then echo "$vhostname setup already at /home/nginx/domains/${vhostname}/public" VHOST_ALREADYSET='y' fi fi # if webroot path directory does not exists # + ssl vhost file does not exist if [[ ! -d "$WEBROOTPATH_OPT" && ! -f "$SSLVHOST_CONFIG" ]]; then echo echo "${vhostname} nginx vhost + pureftp virtual ftp user setup" if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then vhostsetup "${vhostname}" https else vhostsetup "${vhostname}" fi # if webroot path directory exists # + ssl vhost file does not exist # + no ssl_certificate line exists in the non-https vhost file elif [[ -d "$WEBROOTPATH_OPT" && ! -f "$SSLVHOST_CONFIG" ]] && [[ "$(grep -sq ssl_certificate /usr/local/nginx/conf/conf.d/${vhostname}.conf; echo $?)" != '0' ]]; then sslopts_check if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then sslvhostsetup https else sslvhostsetup fi # if webroot path directory exists # + ssl vhost file does not exist # + ssl_certificates line exists in non-https vhost file elif [[ -d "$WEBROOTPATH_OPT" ]] && [[ "$(grep -sq ssl_certificate /usr/local/nginx/conf/conf.d/${vhostname}.conf; echo $?)" = '0' ]] && [[ ! -f "$SSLVHOST_CONFIG" ]]; then if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then sslvhostsetup https else sslvhostsetup fi mv "$SSLVHOST_CONFIG" "${ACMEBACKUPDIR}/${SSLVHOST_CONFIGFILENAME}-acmebackup-${DT}-disabled" SSLVHOST_CONFIG="${ACMEBACKUPDIR}/${SSLVHOST_CONFIGFILENAME}-acmebackup-${DT}-disabled" fi # if webroot path directory exists # + vhostname value exists # + ssl vhost file exists # + not main hostname VHOST_ALREADYSET if [[ -d "$WEBROOTPATH_OPT" && ! -z "$vhostname" && -f "$SSLVHOST_CONFIG" && "$VHOST_ALREADYSET" != 'y' ]]; then check_dns "$vhostname" if [[ "$TOPLEVEL" = [yY] ]]; then if [[ "$SAN" = '1' ]]; then DOMAINOPT="-d $DOMAIN_LIST -d www.${vhostname}" else DOMAINOPT="-d ${vhostname} -d www.${vhostname}" fi else if [[ "$SAN" = '1' ]]; then DOMAINOPT="-d $DOMAIN_LIST" else DOMAINOPT="-d ${vhostname}" fi fi if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then # if https default via d or lived option, then backup non-https vhostname.conf to backup directory # and remove the non-https vhostname.conf file echo "backup & remove /usr/local/nginx/conf/conf.d/$vhostname.conf" cp -a "/usr/local/nginx/conf/conf.d/$vhostname.conf" "${ACMEBACKUPDIR}/$vhostname.conf-backup-removal-https-default-${DT}" >/dev/null 2>&1 #rm -rf "/usr/local/nginx/conf/conf.d/$vhostname.conf" >/dev/null 2>&1 # if existing https vhostname.ssl.conf file exists replace it with one with proper http to https redirect if [ -f "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf" ]; then # sslvhostsetup https $vhostname sslopts_check sslvhostsetup https if [[ "$(grep '^#x# return 302' "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf")" ]]; then switch_httpsdefault fi fi elif [[ "$testcert" = 'wplived' || "$testcert" = 'wptestd' ]]; then # if https default via d or lived option, then backup non-https vhostname.conf to backup directory # and remove the non-https vhostname.conf file echo "backup & remove /usr/local/nginx/conf/conf.d/$vhostname.conf" cp -a "/usr/local/nginx/conf/conf.d/$vhostname.conf" "${ACMEBACKUPDIR}/$vhostname.conf-backup-removal-https-default-${DT}" >/dev/null 2>&1 #rm -rf "/usr/local/nginx/conf/conf.d/$vhostname.conf" >/dev/null 2>&1 # if existing https vhostname.ssl.conf file exists replace it with one with proper http to https redirect if [ -f "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf" ]; then # sslvhostsetup https $vhostname sslopts_check sslvhostsetup https wp if [[ "$(grep '^#x# return 302' "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf")" ]]; then switch_httpsdefault fi fi else cp -a "/usr/local/nginx/conf/conf.d/$vhostname.conf" "${ACMEBACKUPDIR}/$vhostname.conf-acmebackup-$DT" >/dev/null 2>&1 fi cp -a "$SSLVHOST_CONFIG" "${ACMEBACKUPDIR}/$SSLVHOST_CONFIGFILENAME-acmebackup-$DT" if [[ "$testcert" != 'lived' || "$testcert" != 'd' || "$testcert" != 'wplived' || "$testcert" != 'wpd' ]]; then if [ -f "/usr/local/nginx/conf/conf.d/$vhostname.conf" ]; then sed -i "s|server_name .*|server_name $DOMAIN_LISTNGX;|" "/usr/local/nginx/conf/conf.d/$vhostname.conf" echo "grep 'root' "/usr/local/nginx/conf/conf.d/$vhostname.conf"" grep 'root' "/usr/local/nginx/conf/conf.d/$vhostname.conf" fi if [[ ! -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" && -f "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" ]]; then # if existing or previous /usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf has the ssl cert key and trust files # inline in vhost, need to move them to their own include file for acmetool.sh at # /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf convert_crtkeyinc fi fi sed -i "s|server_name .*|server_name $DOMAIN_LISTNGX;|" "$SSLVHOST_CONFIG" echo "grep 'root' $SSLVHOST_CONFIG" grep 'root' "$SSLVHOST_CONFIG" /usr/bin/ngxreload >/dev/null 2>&1 echo echo "-----------------------------------------------------------" echo "renew & install letsencrypt ssl certificate for $vhostname" echo "-----------------------------------------------------------" # if the option flag = live is not passed on command line, the issuance uses the # staging test ssl certificates echo "testcert value = $testcert" if [[ "$testcert" = 'live' || "$testcert" = 'lived' || "$testcert" != 'd' ]] && [[ "$testcert" != 'wplive' && "$testcert" != 'wplived' && "$testcert" != 'wptestd' ]] && [[ "$testcert" != 'wptest' ]] && [[ ! -z "$testcert" ]]; then echo ""$ACMEBINARY"${ACME_APIENDPOINT}${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT}${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} LECHECK=$? # only enable resolver and ssl_stapling for live ssl certificate deployments if [[ -f "$SSLVHOST_CONFIG" && "$LECHECK" = '0' ]]; then sed -i "s|#resolver |resolver |" "$SSLVHOST_CONFIG" sed -i "s|#resolver_timeout|resolver_timeout|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling on|ssl_stapling on|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling_verify|ssl_stapling_verify|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "$SSLVHOST_CONFIG" if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" ]; then sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" fi # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' ]]; then echo echo "get 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY"${ACME_APIENDPOINT}${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT}${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} DUAL_LECHECK=$? if [[ "$DUAL_LECHECK" = '0' ]]; then echo echo "success: 2nd SSL cert issued for dual ssl cert config" echo else echo echo "failed: 2nd SSL cert issuance failed for dual ssl cert config" echo fi fi # dual cert routine end if [[ "$testcert" = 'lived' || "$testcert" = 'wplived' ]]; then echo echo "switch to HTTPS default after verification" echo switch_httpsdefault fi fi elif [[ "$testcert" = 'wplive' || "$testcert" = 'wplived' || "$testcert" != 'wptestd' ]] && [[ "$testcert" != 'wptest' ]] && [[ "$testcert" != 'd' ]] && [[ ! -z "$testcert" ]]; then echo "wp routine detected use reissue instead via --force" echo ""$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} LECHECK=$? # only enable resolver and ssl_stapling for live ssl certificate deployments if [[ -f "$SSLVHOST_CONFIG" && "$LECHECK" = '0' ]]; then sed -i "s|#resolver |resolver |" "$SSLVHOST_CONFIG" sed -i "s|#resolver_timeout|resolver_timeout|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling on|ssl_stapling on|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling_verify|ssl_stapling_verify|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "$SSLVHOST_CONFIG" if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" ]; then sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" fi # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' ]]; then echo echo "get 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} DUAL_LECHECK=$? if [[ "$DUAL_LECHECK" = '0' ]]; then echo echo "success: 2nd SSL cert issued for dual ssl cert config" echo else echo echo "failed: 2nd SSL cert issuance failed for dual ssl cert config" echo fi fi # dual cert routine end if [[ "$testcert" = 'lived' || "$testcert" = 'wplived' ]]; then echo echo "switch to HTTPS default after verification" echo switch_httpsdefault fi fi else testcert_dual=y echo ""$ACMEBINARY"${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} LECHECK=$? if [[ "$LECHECK" = '0' ]]; then # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' ]]; then echo echo "get 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY"${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$WEBROOTPATH_OPT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} DUAL_LECHECK=$? if [[ "$DUAL_LECHECK" = '0' ]]; then echo echo "success: 2nd SSL cert issued for dual ssl cert config" echo else echo echo "failed: 2nd SSL cert issuance failed for dual ssl cert config" echo fi fi # dual cert routine end if [[ "$testcert" = 'wptestd' || "$testcert" = 'd' ]]; then echo echo "switch to HTTPS default after verification" echo switch_httpsdefault fi fi fi # LECHECK=$? echo "LECHECK = $LECHECK" if [[ "$LECHECK" = '0' ]]; then if [[ "$KEYLENGTH" = 'ec-256' || "$KEYLENGTH" = 'ec-384' ]]; then sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.key|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.key|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-trusted.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" else sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.key|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.key|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-trusted.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" fi egrep 'ssl_dhparam|ssl_certificate|ssl_certificate_key|ssl_trusted_certificate' "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" | tee /usr/local/nginx/conf/ssl/${vhostname}/acme-vhost-config.txt echo echo "-----------------------------------------------------------" echo "install cert" echo "-----------------------------------------------------------" # ensure directory exists before installing and copying ssl cert files # to /usr/local/nginx/conf/ssl/${vhostname} if [ ! -d "/usr/local/nginx/conf/ssl/${vhostname}" ]; then mkdir -p "/usr/local/nginx/conf/ssl/${vhostname}" fi echo ""$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIX}.key"${ECCFLAG}" "$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIX}.key"${ECCFLAG} if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" ]; then chmod 0644 "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" fi # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' && "$DUAL_LECHECK" -eq '0' ]]; then echo echo "install 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIXDUAL}.key"${ECCFLAG_DUAL}" "$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIXDUAL}.key"${ECCFLAG_DUAL} if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" ]; then chmod 0644 "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" fi if [[ "$testcert_dual" = [yY] ]]; then convert_dualcrtkeyinctest else convert_dualcrtkeyinclive fi fi # dual cert routine end # allow it to be repopulated each time with $vhostname # rm -rf /root/.acme.sh/reload.sh echo echo "letsencrypt ssl certificate setup completed" echo "ssl certs located at: /usr/local/nginx/conf/ssl/${vhostname}" pushover_alert $vhostname backup_acme $vhostname echo echo "openssl x509 -noout -text < "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer"" openssl x509 -noout -text < "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" listlogs echo elif [[ "$LECHECK" = '1' ]]; then listlogs echo elif [[ "$LECHECK" = '2' ]]; then echo echo "renewal skipped as ssl cert still valid" listlogs echo fi # reloadcmd_setup fi } ##################### # custom webrooot ##################### webroot_issueacme() { check_acmeinstall # split domains for SAN SSL certs split_domains "$vhostname" CUSTOM_WEBROOT="$customwebroot" detectcustom_webroot $CUSTOM_WEBROOT $vhostname if [[ "$vhostname" != "$MAIN_HOSTNAME" ]]; then SSLVHOST_CONFIGFILENAME="${vhostname}.ssl.conf" SSLVHOST_CONFIG="/usr/local/nginx/conf/conf.d/${SSLVHOST_CONFIGFILENAME}" WEBROOTPATH_OPT="/home/nginx/domains/${vhostname}/public" VHOST_ALREADYSET='n' elif [[ "$vhostname" = "$MAIN_HOSTNAME" ]]; then SSLVHOST_CONFIGFILENAME="${MAIN_HOSTNAMEVHOSTSSLFILE}" SSLVHOST_CONFIG="/usr/local/nginx/conf/conf.d/${MAIN_HOSTNAMEVHOSTSSLFILE}" WEBROOTPATH_OPT="/usr/local/nginx/html" if [ -d "/home/nginx/domains/${vhostname}/public" ]; then echo "$vhostname setup already at /home/nginx/domains/${vhostname}/public" VHOST_ALREADYSET='y' fi fi # if webroot path directory does not exists # + ssl vhost file does not exist if [[ ! -d "$CUSTOM_WEBROOT" && ! -f "$SSLVHOST_CONFIG" ]]; then echo echo "${vhostname} nginx vhost + pureftp virtual ftp user setup" if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then vhostsetup "${vhostname}" https else vhostsetup "${vhostname}" fi # if webroot path directory exists # + ssl vhost file does not exist elif [[ -d "$CUSTOM_WEBROOT" && ! -f "$SSLVHOST_CONFIG" ]]; then echo echo "${vhostname} nginx vhost + pureftp virtual ftp user setup" if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then vhostsetup "${vhostname}" https else vhostsetup "${vhostname}" fi # if webroot path directory exists # + ssl vhost file does not exist # + ssl_certificate line does not exist in non-https vhost elif [[ -d "$CUSTOM_WEBROOT" && ! -f "$SSLVHOST_CONFIG" ]] && [[ "$(grep -sq ssl_certificate /usr/local/nginx/conf/conf.d/${vhostname}.conf; echo $?)" != '0' ]]; then sslopts_check if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then sslvhostsetup https else sslvhostsetup fi # if webroot path directory exists # + ssl vhost file does not exist # + ssl_certificate line exists in non-https vhost elif [[ -d "$CUSTOM_WEBROOT" ]] && [[ "$(grep -sq ssl_certificate /usr/local/nginx/conf/conf.d/${vhostname}.conf; echo $?)" = '0' ]] && [[ ! -f "$SSLVHOST_CONFIG" ]]; then if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then sslvhostsetup https else sslvhostsetup fi mv "$SSLVHOST_CONFIG" "${ACMEBACKUPDIR}/${SSLVHOST_CONFIGFILENAME}-acmebackup-${DT}-disabled" SSLVHOST_CONFIG="${ACMEBACKUPDIR}/${SSLVHOST_CONFIGFILENAME}-acmebackup-${DT}-disabled" fi if [ ! -d "$WEBROOTPATH" ]; then echo "mkdir -p $WEBROOTPATH" mkdir -p "$WEBROOTPATH" chown -R nginx:nginx $WEBROOTPATH echo "\cp -Raf "/home/nginx/domains/${vhostname}/public/"* $WEBROOTPATH" \cp -Raf "/home/nginx/domains/${vhostname}/public/"* "$WEBROOTPATH" elif [[ -d "WEBROOTPATH" ]]; then echo "$WEBROOTPATH already exists" echo "ls -lah $WEBROOTPATH" ls -lah "$WEBROOTPATH" if [ -z "$(ls "$WEBROOTPATH")" ]; then echo "\cp -Raf "/home/nginx/domains/${vhostname}/public/"* $WEBROOTPATH" \cp -Raf "/home/nginx/domains/${vhostname}/public/"* "$WEBROOTPATH" fi fi if [[ "$CUSTOM_WEBROOT" ]]; then # if using custom webroot need to adjust web root in both ssl and non-ssl vhost files if [ -f "$SSLVHOST_CONFIG" ]; then echo "adjusting $SSLVHOST_CONFIG" echo "change web root: " echo "from: $CURRENT_WEBROOT" echo "to: $WEBROOTPATH" sed -e "s|root .*|root $WEBROOTPATH;|" "$SSLVHOST_CONFIG" | grep 'root ' sed -i "s|root .*|root $WEBROOTPATH;|" "$SSLVHOST_CONFIG" fi # if using custom webroot need to adjust web root in both ssl and non-ssl vhost files if [ -f "/usr/local/nginx/conf/conf.d/${vhostname}.conf" ]; then echo echo "adjusting /usr/local/nginx/conf/conf.d/${vhostname}.conf" echo "change web root: " echo "from: $CURRENT_WEBROOT" echo "to: $WEBROOTPATH" sed -e "s|root .*|root $WEBROOTPATH;|" "/usr/local/nginx/conf/conf.d/${vhostname}.conf" | grep 'root ' sed -i "s|root .*|root $WEBROOTPATH;|" "/usr/local/nginx/conf/conf.d/${vhostname}.conf" echo fi fi if [[ -d "$CUSTOM_WEBROOT" && ! -z "$vhostname" && -f "$SSLVHOST_CONFIG" && "$VHOST_ALREADYSET" != 'y' ]]; then check_dns "$vhostname" if [[ "$TOPLEVEL" = [yY] ]]; then if [[ "$SAN" = '1' ]]; then DOMAINOPT="-d $DOMAIN_LIST -d www.${vhostname}" else DOMAINOPT="-d ${vhostname} -d www.${vhostname}" fi else if [[ "$SAN" = '1' ]]; then DOMAINOPT="-d $DOMAIN_LIST" else DOMAINOPT="-d ${vhostname}" fi fi if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then # if https default via d or lived option, then backup non-https vhostname.conf to backup directory # and remove the non-https vhostname.conf file echo "backup & remove /usr/local/nginx/conf/conf.d/$vhostname.conf" cp -a "/usr/local/nginx/conf/conf.d/$vhostname.conf" "${ACMEBACKUPDIR}/$vhostname.conf-backup-removal-https-default-${DT}" >/dev/null 2>&1 #rm -rf "/usr/local/nginx/conf/conf.d/$vhostname.conf" >/dev/null 2>&1 # if existing https vhostname.ssl.conf file exists replace it with one with proper http to https redirect if [ -f "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf" ]; then # sslvhostsetup https $vhostname sslopts_check sslvhostsetup https if [[ "$(grep '^#x# return 302' "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf")" ]]; then switch_httpsdefault fi fi elif [[ "$testcert" = 'wplived' || "$testcert" = 'wptestd' ]]; then # if https default via d or lived option, then backup non-https vhostname.conf to backup directory # and remove the non-https vhostname.conf file echo "backup & remove /usr/local/nginx/conf/conf.d/$vhostname.conf" cp -a "/usr/local/nginx/conf/conf.d/$vhostname.conf" "${ACMEBACKUPDIR}/$vhostname.conf-backup-removal-https-default-${DT}" >/dev/null 2>&1 #rm -rf "/usr/local/nginx/conf/conf.d/$vhostname.conf" >/dev/null 2>&1 # if existing https vhostname.ssl.conf file exists replace it with one with proper http to https redirect if [ -f "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf" ]; then # sslvhostsetup https $vhostname sslopts_check sslvhostsetup https wp if [[ "$(grep '^#x# return 302' "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf")" ]]; then switch_httpsdefault fi fi else cp -a "/usr/local/nginx/conf/conf.d/$vhostname.conf" "${ACMEBACKUPDIR}/$vhostname.conf-acmebackup-$DT" >/dev/null 2>&1 fi cp -a "$SSLVHOST_CONFIG" "${ACMEBACKUPDIR}/$SSLVHOST_CONFIGFILENAME-acmebackup-$DT" if [[ "$testcert" != 'lived' || "$testcert" != 'd' || "$testcert" != 'wplived' || "$testcert" != 'wpd' ]]; then if [ -f "/usr/local/nginx/conf/conf.d/$vhostname.conf" ]; then sed -i "s|server_name .*|server_name $DOMAIN_LISTNGX;|" "/usr/local/nginx/conf/conf.d/$vhostname.conf" echo "grep 'root' "/usr/local/nginx/conf/conf.d/$vhostname.conf"" grep 'root' "/usr/local/nginx/conf/conf.d/$vhostname.conf" fi if [[ ! -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" && -f "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" ]]; then # if existing or previous /usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf has the ssl cert key and trust files # inline in vhost, need to move them to their own include file for acmetool.sh at # /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf convert_crtkeyinc fi fi sed -i "s|server_name .*|server_name $DOMAIN_LISTNGX;|" "$SSLVHOST_CONFIG" echo "grep 'root' $SSLVHOST_CONFIG" grep 'root' "$SSLVHOST_CONFIG" /usr/bin/ngxreload >/dev/null 2>&1 echo echo "-----------------------------------------------------------" echo "issue & install letsencrypt ssl certificate for $vhostname" echo "-----------------------------------------------------------" # if the option flag = live is not passed on command line, the issuance uses the # staging test ssl certificates echo "testcert value = $testcert" if [[ "$testcert" = 'live' || "$testcert" = 'lived' || "$testcert" != 'd' || "$testcert" != 'wplive' && "$testcert" != 'wplived' && "$testcert" != 'wptestd' ]] && [[ ! -z "$testcert" ]]; then echo ""$ACMEBINARY"${ACME_APIENDPOINT}${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT}${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} LECHECK=$? # only enable resolver and ssl_stapling for live ssl certificate deployments if [[ -f "$SSLVHOST_CONFIG" && "$LECHECK" = '0' ]]; then sed -i "s|#resolver |resolver |" "$SSLVHOST_CONFIG" sed -i "s|#resolver_timeout|resolver_timeout|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling on|ssl_stapling on|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling_verify|ssl_stapling_verify|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "$SSLVHOST_CONFIG" if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" ]; then sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" fi # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' ]]; then echo echo "get 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY"${ACME_APIENDPOINT}${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT}${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} DUAL_LECHECK=$? if [[ "$DUAL_LECHECK" = '0' ]]; then echo echo "success: 2nd SSL cert issued for dual ssl cert config" echo else echo echo "failed: 2nd SSL cert issuance failed for dual ssl cert config" echo fi fi # dual cert routine end if [[ "$testcert" = 'lived' || "$testcert" = 'wplived' ]]; then echo echo "switch to HTTPS default after verification" echo switch_httpsdefault fi fi elif [[ "$testcert" = 'wplive' || "$testcert" = 'wplived' || "$testcert" != 'wptestd' ]] && [[ "$testcert" != 'wptest' ]] && [[ "$testcert" != 'd' ]] && [[ ! -z "$testcert" ]]; then echo "wp routine detected use reissue instead via --force" echo ""$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} LECHECK=$? # only enable resolver and ssl_stapling for live ssl certificate deployments if [[ -f "$SSLVHOST_CONFIG" && "$LECHECK" = '0' ]]; then sed -i "s|#resolver |resolver |" "$SSLVHOST_CONFIG" sed -i "s|#resolver_timeout|resolver_timeout|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling on|ssl_stapling on|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling_verify|ssl_stapling_verify|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "$SSLVHOST_CONFIG" if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" ]; then sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" fi # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' ]]; then echo echo "get 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} DUAL_LECHECK=$? if [[ "$DUAL_LECHECK" = '0' ]]; then echo echo "success: 2nd SSL cert issued for dual ssl cert config" echo else echo echo "failed: 2nd SSL cert issuance failed for dual ssl cert config" echo fi fi # dual cert routine end if [[ "$testcert" = 'lived' || "$testcert" = 'wplived' ]]; then echo echo "switch to HTTPS default after verification" echo switch_httpsdefault fi fi else testcert_dual=y echo ""$ACMEBINARY"${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} LECHECK=$? if [[ "$LECHECK" = '0' ]]; then # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' ]]; then echo echo "get 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY"${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} DUAL_LECHECK=$? if [[ "$DUAL_LECHECK" = '0' ]]; then echo echo "success: 2nd SSL cert issued for dual ssl cert config" echo else echo echo "failed: 2nd SSL cert issuance failed for dual ssl cert config" echo fi fi # dual cert routine end if [[ "$testcert" = 'wptestd' || "$testcert" = 'd' ]]; then echo echo "switch to HTTPS default after verification" echo switch_httpsdefault fi fi fi # LECHECK=$? echo "LECHECK = $LECHECK" if [[ "$LECHECK" = '0' ]]; then if [[ "$KEYLENGTH" = 'ec-256' || "$KEYLENGTH" = 'ec-384' ]]; then sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.key|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.key|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-trusted.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" else sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.key|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.key|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-trusted.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" fi egrep 'ssl_dhparam|ssl_certificate|ssl_certificate_key|ssl_trusted_certificate' "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" | tee /usr/local/nginx/conf/ssl/${vhostname}/acme-vhost-config.txt echo echo "-----------------------------------------------------------" echo "install cert" echo "-----------------------------------------------------------" # ensure directory exists before installing and copying ssl cert files # to /usr/local/nginx/conf/ssl/${vhostname} if [ ! -d "/usr/local/nginx/conf/ssl/${vhostname}" ]; then mkdir -p "/usr/local/nginx/conf/ssl/${vhostname}" fi echo ""$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIX}.key"${ECCFLAG}" "$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIX}.key"${ECCFLAG} if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" ]; then chmod 0644 "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" fi if [ -f "${CENTMINLOGDIR}/centminmod_${DT}_nginx_addvhost_nv-remove-cmds-${vhostname}.log" ]; then echo "rm -rf ${ACMECERTHOME}/${vhostname}" >> "${CENTMINLOGDIR}/centminmod_${DT}_nginx_addvhost_nv-remove-cmds-${vhostname}.log" fi # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' && "$DUAL_LECHECK" -eq '0' ]]; then echo echo "install 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIXDUAL}.key"${ECCFLAG_DUAL}" "$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIXDUAL}.key"${ECCFLAG_DUAL} if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" ]; then chmod 0644 "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" fi if [[ "$testcert_dual" = [yY] ]]; then convert_dualcrtkeyinctest else convert_dualcrtkeyinclive fi fi # dual cert routine end # allow it to be repopulated each time with $vhostname # rm -rf /root/.acme.sh/reload.sh echo echo "letsencrypt ssl certificate setup completed" echo "ssl certs located at: /usr/local/nginx/conf/ssl/${vhostname}" pushover_alert $vhostname backup_acme $vhostname echo echo "openssl x509 -noout -text < "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer"" openssl x509 -noout -text < "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" listlogs echo elif [[ "$LECHECK" = '1' ]]; then listlogs echo elif [[ "$LECHECK" = '2' ]]; then echo echo "issue skipped as ssl cert still valid" listlogs echo fi # reloadcmd_setup fi } ##################### webroot_reissueacme() { check_acmeinstall # split domains for SAN SSL certs split_domains "$vhostname" CUSTOM_WEBROOT="$customwebroot" detectcustom_webroot $CUSTOM_WEBROOT $vhostname if [[ "$vhostname" != "$MAIN_HOSTNAME" ]]; then SSLVHOST_CONFIGFILENAME="${vhostname}.ssl.conf" SSLVHOST_CONFIG="/usr/local/nginx/conf/conf.d/${SSLVHOST_CONFIGFILENAME}" WEBROOTPATH_OPT="/home/nginx/domains/${vhostname}/public" VHOST_ALREADYSET='n' elif [[ "$vhostname" = "$MAIN_HOSTNAME" ]]; then SSLVHOST_CONFIGFILENAME="${MAIN_HOSTNAMEVHOSTSSLFILE}" SSLVHOST_CONFIG="/usr/local/nginx/conf/conf.d/${MAIN_HOSTNAMEVHOSTSSLFILE}" WEBROOTPATH_OPT="/usr/local/nginx/html" if [ -d "/home/nginx/domains/${vhostname}/public" ]; then echo "$vhostname setup already at /home/nginx/domains/${vhostname}/public" VHOST_ALREADYSET='y' fi fi # if webroot path directory does not exists # + ssl vhost file does not exist if [[ ! -d "$CUSTOM_WEBROOT" && ! -f "$SSLVHOST_CONFIG" ]]; then echo echo "${vhostname} nginx vhost + pureftp virtual ftp user setup" if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then vhostsetup "${vhostname}" https else vhostsetup "${vhostname}" fi # if webroot path directory exists # + ssl vhost file does not exist elif [[ -d "$CUSTOM_WEBROOT" && ! -f "$SSLVHOST_CONFIG" ]]; then echo echo "${vhostname} nginx vhost + pureftp virtual ftp user setup" if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then vhostsetup "${vhostname}" https else vhostsetup "${vhostname}" fi # if webroot path directory exists # + ssl vhost file does not exist # + ssl_certificate line does not exist in non-https vhost elif [[ -d "$CUSTOM_WEBROOT" && ! -f "$SSLVHOST_CONFIG" ]] && [[ "$(grep -sq ssl_certificate /usr/local/nginx/conf/conf.d/${vhostname}.conf; echo $?)" != '0' ]]; then sslopts_check if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then sslvhostsetup https else sslvhostsetup fi # if webroot path directory exists # + ssl vhost file does not exist # + ssl_certificate line exists in non-https vhost elif [[ -d "$CUSTOM_WEBROOT" ]] && [[ "$(grep -sq ssl_certificate /usr/local/nginx/conf/conf.d/${vhostname}.conf; echo $?)" = '0' ]] && [[ ! -f "$SSLVHOST_CONFIG" ]]; then if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then sslvhostsetup https else sslvhostsetup fi mv "$SSLVHOST_CONFIG" "${ACMEBACKUPDIR}/${SSLVHOST_CONFIGFILENAME}-acmebackup-${DT}-disabled" SSLVHOST_CONFIG="${ACMEBACKUPDIR}/${SSLVHOST_CONFIGFILENAME}-acmebackup-${DT}-disabled" fi if [ ! -d "$WEBROOTPATH" ]; then echo "mkdir -p $WEBROOTPATH" mkdir -p "$WEBROOTPATH" chown -R nginx:nginx $WEBROOTPATH echo "\cp -Raf "/home/nginx/domains/${vhostname}/public/"* $WEBROOTPATH" \cp -Raf "/home/nginx/domains/${vhostname}/public/"* "$WEBROOTPATH" elif [[ -d "WEBROOTPATH" ]]; then echo "$WEBROOTPATH already exists" echo "ls -lah $WEBROOTPATH" ls -lah "$WEBROOTPATH" if [ -z "$(ls "$WEBROOTPATH")" ]; then echo "\cp -Raf "/home/nginx/domains/${vhostname}/public/"* $WEBROOTPATH" \cp -Raf "/home/nginx/domains/${vhostname}/public/"* "$WEBROOTPATH" fi fi if [[ "$CUSTOM_WEBROOT" ]]; then # if using custom webroot need to adjust web root in both ssl and non-ssl vhost files if [ -f "$SSLVHOST_CONFIG" ]; then echo "adjusting $SSLVHOST_CONFIG" echo "change web root: " echo "from: $CURRENT_WEBROOT" echo "to: $WEBROOTPATH" sed -e "s|root .*|root $WEBROOTPATH;|" "$SSLVHOST_CONFIG" | grep 'root ' sed -i "s|root .*|root $WEBROOTPATH;|" "$SSLVHOST_CONFIG" fi # if using custom webroot need to adjust web root in both ssl and non-ssl vhost files if [ -f "/usr/local/nginx/conf/conf.d/${vhostname}.conf" ]; then echo echo "adjusting /usr/local/nginx/conf/conf.d/${vhostname}.conf" echo "change web root: " echo "from: $CURRENT_WEBROOT" echo "to: $WEBROOTPATH" sed -e "s|root .*|root $WEBROOTPATH;|" "/usr/local/nginx/conf/conf.d/${vhostname}.conf" | grep 'root ' sed -i "s|root .*|root $WEBROOTPATH;|" "/usr/local/nginx/conf/conf.d/${vhostname}.conf" echo fi fi if [[ -d "$CUSTOM_WEBROOT" && ! -z "$vhostname" && -f "$SSLVHOST_CONFIG" && "$VHOST_ALREADYSET" != 'y' ]]; then check_dns "$vhostname" if [[ "$TOPLEVEL" = [yY] ]]; then if [[ "$SAN" = '1' ]]; then DOMAINOPT="-d $DOMAIN_LIST -d www.${vhostname}" else DOMAINOPT="-d ${vhostname} -d www.${vhostname}" fi else if [[ "$SAN" = '1' ]]; then DOMAINOPT="-d $DOMAIN_LIST" else DOMAINOPT="-d ${vhostname}" fi fi if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then # if https default via d or lived option, then backup non-https vhostname.conf to backup directory # and remove the non-https vhostname.conf file echo "backup & remove /usr/local/nginx/conf/conf.d/$vhostname.conf" cp -a "/usr/local/nginx/conf/conf.d/$vhostname.conf" "${ACMEBACKUPDIR}/$vhostname.conf-backup-removal-https-default-${DT}" >/dev/null 2>&1 #rm -rf "/usr/local/nginx/conf/conf.d/$vhostname.conf" >/dev/null 2>&1 # if existing https vhostname.ssl.conf file exists replace it with one with proper http to https redirect if [ -f "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf" ]; then # sslvhostsetup https $vhostname sslopts_check sslvhostsetup https if [[ "$(grep '^#x# return 302' "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf")" ]]; then switch_httpsdefault fi fi elif [[ "$testcert" = 'wplived' || "$testcert" = 'wptestd' ]]; then # if https default via d or lived option, then backup non-https vhostname.conf to backup directory # and remove the non-https vhostname.conf file echo "backup & remove /usr/local/nginx/conf/conf.d/$vhostname.conf" cp -a "/usr/local/nginx/conf/conf.d/$vhostname.conf" "${ACMEBACKUPDIR}/$vhostname.conf-backup-removal-https-default-${DT}" >/dev/null 2>&1 #rm -rf "/usr/local/nginx/conf/conf.d/$vhostname.conf" >/dev/null 2>&1 # if existing https vhostname.ssl.conf file exists replace it with one with proper http to https redirect if [ -f "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf" ]; then # sslvhostsetup https $vhostname sslopts_check sslvhostsetup https wp if [[ "$(grep '^#x# return 302' "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf")" ]]; then switch_httpsdefault fi fi else cp -a "/usr/local/nginx/conf/conf.d/$vhostname.conf" "${ACMEBACKUPDIR}/$vhostname.conf-acmebackup-$DT" >/dev/null 2>&1 fi cp -a "$SSLVHOST_CONFIG" "${ACMEBACKUPDIR}/$SSLVHOST_CONFIGFILENAME-acmebackup-$DT" if [[ "$testcert" != 'lived' || "$testcert" != 'd' || "$testcert" != 'wplived' || "$testcert" != 'wpd' ]]; then if [ -f "/usr/local/nginx/conf/conf.d/$vhostname.conf" ]; then sed -i "s|server_name .*|server_name $DOMAIN_LISTNGX;|" "/usr/local/nginx/conf/conf.d/$vhostname.conf" echo "grep 'root' "/usr/local/nginx/conf/conf.d/$vhostname.conf"" grep 'root' "/usr/local/nginx/conf/conf.d/$vhostname.conf" fi if [[ ! -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" && -f "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" ]]; then # if existing or previous /usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf has the ssl cert key and trust files # inline in vhost, need to move them to their own include file for acmetool.sh at # /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf convert_crtkeyinc fi fi sed -i "s|server_name .*|server_name $DOMAIN_LISTNGX;|" "$SSLVHOST_CONFIG" >/dev/null 2>&1 echo "grep 'root' $SSLVHOST_CONFIG" grep 'root' "$SSLVHOST_CONFIG" /usr/bin/ngxreload >/dev/null 2>&1 echo echo "-----------------------------------------------------------" echo "reissue & install letsencrypt ssl certificate for $vhostname" echo "-----------------------------------------------------------" echo ""$ACMEBINARY" --force --createDomainKey $DOMAINOPT -k "$KEYLENGTH" --useragent "$LE_USERAGENT"" "$ACMEBINARY" --force --createDomainKey $DOMAINOPT -k "$KEYLENGTH" --useragent "$LE_USERAGENT" # if the option flag = live is not passed on command line, the issuance uses the # staging test ssl certificates echo "testcert value = $testcert" if [[ "$testcert" = 'live' || "$testcert" = 'lived' || "$testcert" != 'd' || "$testcert" = 'wplive' || "$testcert" = 'wplived' || "$testcert" != 'wptestd' ]] && [[ "$testcert" != 'wptest' ]] && [[ ! -z "$testcert" ]]; then echo ""$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} LECHECK=$? # only enable resolver and ssl_stapling for live ssl certificate deployments if [[ -f "$SSLVHOST_CONFIG" && "$LECHECK" = '0' ]]; then sed -i "s|#resolver |resolver |" "$SSLVHOST_CONFIG" sed -i "s|#resolver_timeout|resolver_timeout|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling on|ssl_stapling on|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling_verify|ssl_stapling_verify|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "$SSLVHOST_CONFIG" if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" ]; then sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" fi # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' ]]; then echo echo "get 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} DUAL_LECHECK=$? if [[ "$DUAL_LECHECK" = '0' ]]; then echo echo "success: 2nd SSL cert issued for dual ssl cert config" echo else echo echo "failed: 2nd SSL cert issuance failed for dual ssl cert config" echo fi fi # dual cert routine end if [[ "$testcert" = 'lived' || "$testcert" = 'wplived' ]]; then echo echo "switch to HTTPS default after verification" echo switch_httpsdefault fi fi else testcert_dual=y echo ""$ACMEBINARY" --force${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY" --force${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} LECHECK=$? if [[ "$LECHECK" = '0' ]]; then # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' ]]; then echo echo "get 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY" --force${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY" --force${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} DUAL_LECHECK=$? if [[ "$DUAL_LECHECK" = '0' ]]; then echo echo "success: 2nd SSL cert issued for dual ssl cert config" echo else echo echo "failed: 2nd SSL cert issuance failed for dual ssl cert config" echo fi fi # dual cert routine end if [[ "$testcert" = 'wptestd' || "$testcert" = 'd' ]]; then echo echo "switch to HTTPS default after verification" echo switch_httpsdefault fi fi fi # LECHECK=$? echo "LECHECK = $LECHECK" if [[ "$LECHECK" = '0' ]]; then if [[ "$KEYLENGTH" = 'ec-256' || "$KEYLENGTH" = 'ec-384' ]]; then sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.key|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.key|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-trusted.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" else sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.key|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.key|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-trusted.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" fi egrep 'ssl_dhparam|ssl_certificate|ssl_certificate_key|ssl_trusted_certificate' "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" | tee /usr/local/nginx/conf/ssl/${vhostname}/acme-vhost-config.txt echo echo "-----------------------------------------------------------" echo "install cert" echo "-----------------------------------------------------------" # ensure directory exists before installing and copying ssl cert files # to /usr/local/nginx/conf/ssl/${vhostname} if [ ! -d "/usr/local/nginx/conf/ssl/${vhostname}" ]; then mkdir -p "/usr/local/nginx/conf/ssl/${vhostname}" fi echo ""$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIX}.key"${ECCFLAG}" "$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIX}.key"${ECCFLAG} if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" ]; then chmod 0644 "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" fi # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' && "$DUAL_LECHECK" -eq '0' ]]; then echo echo "install 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIXDUAL}.key"${ECCFLAG_DUAL}" "$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIXDUAL}.key"${ECCFLAG_DUAL} if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" ]; then chmod 0644 "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" fi if [[ "$testcert_dual" = [yY] ]]; then convert_dualcrtkeyinctest else convert_dualcrtkeyinclive fi fi # dual cert routine end # allow it to be repopulated each time with $vhostname # rm -rf /root/.acme.sh/reload.sh echo echo "letsencrypt ssl certificate setup completed" echo "ssl certs located at: /usr/local/nginx/conf/ssl/${vhostname}" pushover_alert $vhostname backup_acme $vhostname echo echo "openssl x509 -noout -text < "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer"" openssl x509 -noout -text < "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" listlogs echo elif [[ "$LECHECK" = '1' ]]; then listlogs echo elif [[ "$LECHECK" = '2' ]]; then echo echo "reissue / renewal skipped as ssl cert still valid" listlogs echo fi # reloadcmd_setup fi } webroot_renewacme() { check_acmeinstall # split domains for SAN SSL certs split_domains "$vhostname" CUSTOM_WEBROOT="$customwebroot" detectcustom_webroot $CUSTOM_WEBROOT $vhostname if [[ "$vhostname" != "$MAIN_HOSTNAME" ]]; then SSLVHOST_CONFIGFILENAME="${vhostname}.ssl.conf" SSLVHOST_CONFIG="/usr/local/nginx/conf/conf.d/${SSLVHOST_CONFIGFILENAME}" WEBROOTPATH_OPT="/home/nginx/domains/${vhostname}/public" VHOST_ALREADYSET='n' elif [[ "$vhostname" = "$MAIN_HOSTNAME" ]]; then SSLVHOST_CONFIGFILENAME="${MAIN_HOSTNAMEVHOSTSSLFILE}" SSLVHOST_CONFIG="/usr/local/nginx/conf/conf.d/${MAIN_HOSTNAMEVHOSTSSLFILE}" WEBROOTPATH_OPT="/usr/local/nginx/html" if [ -d "/home/nginx/domains/${vhostname}/public" ]; then echo "$vhostname setup already at /home/nginx/domains/${vhostname}/public" VHOST_ALREADYSET='y' fi fi # if webroot path directory does not exists # + ssl vhost file does not exist if [[ ! -d "$CUSTOM_WEBROOT" && ! -f "$SSLVHOST_CONFIG" ]]; then echo echo "${vhostname} nginx vhost + pureftp virtual ftp user setup" if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then vhostsetup "${vhostname}" https else vhostsetup "${vhostname}" fi # if webroot path directory exists # + ssl vhost file does not exist elif [[ -d "$CUSTOM_WEBROOT" && ! -f "$SSLVHOST_CONFIG" ]]; then echo echo "${vhostname} nginx vhost + pureftp virtual ftp user setup" if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then vhostsetup "${vhostname}" https else vhostsetup "${vhostname}" fi # if webroot path directory exists # + ssl vhost file does not exist # + ssl_certificate line does not exist in non-https vhost elif [[ -d "$CUSTOM_WEBROOT" && ! -f "$SSLVHOST_CONFIG" ]] && [[ "$(grep -sq ssl_certificate /usr/local/nginx/conf/conf.d/${vhostname}.conf; echo $?)" != '0' ]]; then sslopts_check if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then sslvhostsetup https else sslvhostsetup fi # if webroot path directory exists # + ssl vhost file does not exist # + ssl_certificate line exists in non-https vhost elif [[ -d "$CUSTOM_WEBROOT" ]] && [[ "$(grep -sq ssl_certificate /usr/local/nginx/conf/conf.d/${vhostname}.conf; echo $?)" = '0' ]] && [[ ! -f "$SSLVHOST_CONFIG" ]]; then if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then sslvhostsetup https else sslvhostsetup fi mv "$SSLVHOST_CONFIG" "${ACMEBACKUPDIR}/${SSLVHOST_CONFIGFILENAME}-acmebackup-${DT}-disabled" SSLVHOST_CONFIG="${ACMEBACKUPDIR}/${SSLVHOST_CONFIGFILENAME}-acmebackup-${DT}-disabled" fi if [ ! -d "$WEBROOTPATH" ]; then echo "mkdir -p $WEBROOTPATH" mkdir -p "$WEBROOTPATH" chown -R nginx:nginx $WEBROOTPATH echo "\cp -Raf "/home/nginx/domains/${vhostname}/public/"* $WEBROOTPATH" \cp -Raf "/home/nginx/domains/${vhostname}/public/"* "$WEBROOTPATH" elif [[ -d "WEBROOTPATH" ]]; then echo "$WEBROOTPATH already exists" echo "ls -lah $WEBROOTPATH" ls -lah "$WEBROOTPATH" if [ -z "$(ls "$WEBROOTPATH")" ]; then echo "\cp -Raf "/home/nginx/domains/${vhostname}/public/"* $WEBROOTPATH" \cp -Raf "/home/nginx/domains/${vhostname}/public/"* "$WEBROOTPATH" fi fi if [[ "$CUSTOM_WEBROOT" ]]; then # if using custom webroot need to adjust web root in both ssl and non-ssl vhost files if [ -f "$SSLVHOST_CONFIG" ]; then echo "adjusting $SSLVHOST_CONFIG" echo "change web root: " echo "from: $CURRENT_WEBROOT" echo "to: $WEBROOTPATH" sed -e "s|root .*|root $WEBROOTPATH;|" "$SSLVHOST_CONFIG" | grep 'root ' sed -i "s|root .*|root $WEBROOTPATH;|" "$SSLVHOST_CONFIG" fi # if using custom webroot need to adjust web root in both ssl and non-ssl vhost files if [ -f "/usr/local/nginx/conf/conf.d/${vhostname}.conf" ]; then echo echo "adjusting /usr/local/nginx/conf/conf.d/${vhostname}.conf" echo "change web root: " echo "from: $CURRENT_WEBROOT" echo "to: $WEBROOTPATH" sed -e "s|root .*|root $WEBROOTPATH;|" "/usr/local/nginx/conf/conf.d/${vhostname}.conf" | grep 'root ' sed -i "s|root .*|root $WEBROOTPATH;|" "/usr/local/nginx/conf/conf.d/${vhostname}.conf" echo fi fi if [[ -d "$CUSTOM_WEBROOT" && ! -z "$vhostname" && -f "$SSLVHOST_CONFIG" && "$VHOST_ALREADYSET" != 'y' ]]; then check_dns "$vhostname" if [[ "$TOPLEVEL" = [yY] ]]; then if [[ "$SAN" = '1' ]]; then DOMAINOPT="-d $DOMAIN_LIST -d www.${vhostname}" else DOMAINOPT="-d ${vhostname} -d www.${vhostname}" fi else if [[ "$SAN" = '1' ]]; then DOMAINOPT="-d $DOMAIN_LIST" else DOMAINOPT="-d ${vhostname}" fi fi if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then # if https default via d or lived option, then backup non-https vhostname.conf to backup directory # and remove the non-https vhostname.conf file echo "backup & remove /usr/local/nginx/conf/conf.d/$vhostname.conf" cp -a "/usr/local/nginx/conf/conf.d/$vhostname.conf" "${ACMEBACKUPDIR}/$vhostname.conf-backup-removal-https-default-${DT}" >/dev/null 2>&1 #rm -rf "/usr/local/nginx/conf/conf.d/$vhostname.conf" >/dev/null 2>&1 # if existing https vhostname.ssl.conf file exists replace it with one with proper http to https redirect if [ -f "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf" ]; then # sslvhostsetup https $vhostname sslopts_check sslvhostsetup https if [[ "$(grep '^#x# return 302' "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf")" ]]; then switch_httpsdefault fi fi elif [[ "$testcert" = 'wplived' || "$testcert" = 'wptestd' ]]; then # if https default via d or lived option, then backup non-https vhostname.conf to backup directory # and remove the non-https vhostname.conf file echo "backup & remove /usr/local/nginx/conf/conf.d/$vhostname.conf" cp -a "/usr/local/nginx/conf/conf.d/$vhostname.conf" "${ACMEBACKUPDIR}/$vhostname.conf-backup-removal-https-default-${DT}" >/dev/null 2>&1 #rm -rf "/usr/local/nginx/conf/conf.d/$vhostname.conf" >/dev/null 2>&1 # if existing https vhostname.ssl.conf file exists replace it with one with proper http to https redirect if [ -f "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf" ]; then # sslvhostsetup https $vhostname sslopts_check sslvhostsetup https wp if [[ "$(grep '^#x# return 302' "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf")" ]]; then switch_httpsdefault fi fi else cp -a "/usr/local/nginx/conf/conf.d/$vhostname.conf" "${ACMEBACKUPDIR}/$vhostname.conf-acmebackup-$DT" >/dev/null 2>&1 fi cp -a "$SSLVHOST_CONFIG" "${ACMEBACKUPDIR}/$SSLVHOST_CONFIGFILENAME-acmebackup-$DT" if [[ "$testcert" != 'lived' || "$testcert" != 'd' || "$testcert" != 'wplived' || "$testcert" != 'wpd' ]]; then if [ -f "/usr/local/nginx/conf/conf.d/$vhostname.conf" ]; then sed -i "s|server_name .*|server_name $DOMAIN_LISTNGX;|" "/usr/local/nginx/conf/conf.d/$vhostname.conf" echo "grep 'root' "/usr/local/nginx/conf/conf.d/$vhostname.conf"" grep 'root' "/usr/local/nginx/conf/conf.d/$vhostname.conf" fi if [[ ! -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" && -f "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" ]]; then # if existing or previous /usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf has the ssl cert key and trust files # inline in vhost, need to move them to their own include file for acmetool.sh at # /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf convert_crtkeyinc fi fi sed -i "s|server_name .*|server_name $DOMAIN_LISTNGX;|" "$SSLVHOST_CONFIG" echo "grep 'root' $SSLVHOST_CONFIG" grep 'root' "$SSLVHOST_CONFIG" /usr/bin/ngxreload >/dev/null 2>&1 echo echo "-----------------------------------------------------------" echo "renew & install letsencrypt ssl certificate for $vhostname" echo "-----------------------------------------------------------" # if the option flag = live is not passed on command line, the issuance uses the # staging test ssl certificates echo "testcert value = $testcert" if [[ "$testcert" = 'live' || "$testcert" = 'lived' || "$testcert" != 'd' || "$testcert" != 'wplive' && "$testcert" != 'wplived' && "$testcert" != 'wptestd' ]] && [[ ! -z "$testcert" ]]; then echo ""$ACMEBINARY"${ACME_APIENDPOINT}${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT}${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} LECHECK=$? # only enable resolver and ssl_stapling for live ssl certificate deployments if [[ -f "$SSLVHOST_CONFIG" && "$LECHECK" = '0' ]]; then sed -i "s|#resolver |resolver |" "$SSLVHOST_CONFIG" sed -i "s|#resolver_timeout|resolver_timeout|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling on|ssl_stapling on|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling_verify|ssl_stapling_verify|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "$SSLVHOST_CONFIG" if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" ]; then sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" fi # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' ]]; then echo echo "get 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY"${ACME_APIENDPOINT}${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT}${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} DUAL_LECHECK=$? if [[ "$DUAL_LECHECK" = '0' ]]; then echo echo "success: 2nd SSL cert issued for dual ssl cert config" echo else echo echo "failed: 2nd SSL cert issuance failed for dual ssl cert config" echo fi fi # dual cert routine end if [[ "$testcert" = 'lived' || "$testcert" = 'wplived' ]]; then echo echo "switch to HTTPS default after verification" echo switch_httpsdefault fi fi elif [[ "$testcert" = 'wplive' || "$testcert" = 'wplived' || "$testcert" != 'wptestd' ]] && [[ "$testcert" != 'wptest' ]] && [[ "$testcert" != 'd' ]] && [[ ! -z "$testcert" ]]; then echo "wp routine detected use reissue instead via --force" echo ""$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} LECHECK=$? # only enable resolver and ssl_stapling for live ssl certificate deployments if [[ -f "$SSLVHOST_CONFIG" && "$LECHECK" = '0' ]]; then sed -i "s|#resolver |resolver |" "$SSLVHOST_CONFIG" sed -i "s|#resolver_timeout|resolver_timeout|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling on|ssl_stapling on|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling_verify|ssl_stapling_verify|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "$SSLVHOST_CONFIG" if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" ]; then sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" fi # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' ]]; then echo echo "get 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${ACME_APIENDPOINT} --force${ACMEOCSP}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} DUAL_LECHECK=$? if [[ "$DUAL_LECHECK" = '0' ]]; then echo echo "success: 2nd SSL cert issued for dual ssl cert config" echo else echo echo "failed: 2nd SSL cert issuance failed for dual ssl cert config" echo fi fi # dual cert routine end if [[ "$testcert" = 'lived' || "$testcert" = 'wplived' ]]; then echo echo "switch to HTTPS default after verification" echo switch_httpsdefault fi fi else testcert_dual=y echo ""$ACMEBINARY"${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} LECHECK=$? if [[ "$LECHECK" = '0' ]]; then # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' ]]; then echo echo "get 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY"${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY"${STAGING_OPT}${DNSAPI_OPT_GLOBAL} --issue $DOMAINOPT --days $RENEWDAYS -w "$CUSTOM_WEBROOT" -k "$KEYLENGTH_DUAL" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} DUAL_LECHECK=$? if [[ "$DUAL_LECHECK" = '0' ]]; then echo echo "success: 2nd SSL cert issued for dual ssl cert config" echo else echo echo "failed: 2nd SSL cert issuance failed for dual ssl cert config" echo fi fi # dual cert routine end if [[ "$testcert" = 'wptestd' || "$testcert" = 'd' ]]; then echo echo "switch to HTTPS default after verification" echo switch_httpsdefault fi fi fi # LECHECK=$? echo "LECHECK = $LECHECK" if [[ "$LECHECK" = '0' ]]; then if [[ "$KEYLENGTH" = 'ec-256' || "$KEYLENGTH" = 'ec-384' ]]; then sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.key|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.key|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-trusted.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" else sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.key|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.key|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-trusted.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" fi egrep 'ssl_dhparam|ssl_certificate|ssl_certificate_key|ssl_trusted_certificate' "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" | tee /usr/local/nginx/conf/ssl/${vhostname}/acme-vhost-config.txt echo echo "-----------------------------------------------------------" echo "install cert" echo "-----------------------------------------------------------" # ensure directory exists before installing and copying ssl cert files # to /usr/local/nginx/conf/ssl/${vhostname} if [ ! -d "/usr/local/nginx/conf/ssl/${vhostname}" ]; then mkdir -p "/usr/local/nginx/conf/ssl/${vhostname}" fi echo ""$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIX}.key"${ECCFLAG}" "$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIX}.key"${ECCFLAG} if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" ]; then chmod 0644 "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" fi # dual cert routine start if [[ "$DUALCERTS" = [yY] && "$KEYLENGTH" = '2048' && "$DUAL_LECHECK" -eq '0' ]]; then echo echo "install 2nd SSL cert issued for dual ssl cert config" echo echo ""$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIXDUAL}.key"${ECCFLAG_DUAL}" "$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIXDUAL}.key"${ECCFLAG_DUAL} if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" ]; then chmod 0644 "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIXDUAL}.key" fi if [[ "$testcert_dual" = [yY] ]]; then convert_dualcrtkeyinctest else convert_dualcrtkeyinclive fi fi # dual cert routine end # allow it to be repopulated each time with $vhostname # rm -rf /root/.acme.sh/reload.sh echo echo "letsencrypt ssl certificate setup completed" echo "ssl certs located at: /usr/local/nginx/conf/ssl/${vhostname}" pushover_alert $vhostname backup_acme $vhostname echo echo "openssl x509 -noout -text < "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer"" openssl x509 -noout -text < "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" listlogs echo elif [[ "$LECHECK" = '1' ]]; then listlogs echo elif [[ "$LECHECK" = '2' ]]; then echo echo "renewal skipped as ssl cert still valid" listlogs echo fi # reloadcmd_setup fi } ##################### awsissue_acme() { echo } ##################### awsreissue_acme() { echo } ##################### awsrenew_acme() { echo } ##################### enter_domainname() { echo read -ep "Enter SSL certificate domain name you want without www. prefix host: " input_domain echo } ##################### enter_webroot() { echo echo "custom web root should be within /home/nginx/domains/yourdomain.com path" echo "i.e. /home/nginx/domains/yourdomain.com/customwebrootpath" echo read -ep "Enter custom webroot path you want: " input_webroot echo echo "you entered custom webroot = $input_webroot" echo "full path location will be at:" echo echo " /home/nginx/domains/${input_domain}/${input_webroot}" echo read -ep "is this path correct ? [y/n]: " webrootpath_correct if [[ "$webrootpath_correct" = [yY] ]]; then input_webroot="/home/nginx/domains/${input_domain}/${input_webroot}" echo "full path location will be at:" echo "$input_webroot" else while [[ "$webrootpath_correct" != [yY] ]]; do echo echo "custom web root should be within /home/nginx/domains/yourdomain.com path" echo "i.e. /home/nginx/domains/yourdomain.com/customwebrootpath" echo read -ep "Enter custom webroot path you want: " input_webroot echo echo "you entered custom webroot = $input_webroot" echo "full path location will be at:" echo echo " /home/nginx/domains/${input_domain}/${input_webroot}" echo read -ep "is this path correct ? [y/n]: " webrootpath_correct echo done if [[ "$webrootpath_correct" = [yY] ]]; then input_webroot="/home/nginx/domains/${input_domain}/${input_webroot}" echo "full path location will be at:" echo "$input_webroot" fi fi echo } ##################### issue_acmedns() { CERTONLY_DNS=$1 STAGE_DNS=$2 check_acmeinstall # split domains for SAN SSL certs split_domains "$vhostname" if [[ "$vhostname" != "$MAIN_HOSTNAME" ]]; then SSLVHOST_CONFIGFILENAME="${vhostname}.ssl.conf" SSLVHOST_CONFIG="/usr/local/nginx/conf/conf.d/${SSLVHOST_CONFIGFILENAME}" WEBROOTPATH_OPT="/home/nginx/domains/${vhostname}/public" VHOST_ALREADYSET='n' elif [[ "$vhostname" = "$MAIN_HOSTNAME" ]]; then SSLVHOST_CONFIGFILENAME="${MAIN_HOSTNAMEVHOSTSSLFILE}" SSLVHOST_CONFIG="/usr/local/nginx/conf/conf.d/${MAIN_HOSTNAMEVHOSTSSLFILE}" WEBROOTPATH_OPT="/usr/local/nginx/html" if [ -d "/home/nginx/domains/${vhostname}/public" ]; then echo "$vhostname setup already at /home/nginx/domains/${vhostname}/public" VHOST_ALREADYSET='y' fi fi ############################################ # DNS mode cert only don't touch nginx vhosts # 0 if [[ "$CERTONLY_DNS" != '1' ]]; then # if webroot path directory does not exists # + ssl vhost file does not exist if [[ ! -d "$WEBROOTPATH_OPT" && ! -f "$SSLVHOST_CONFIG" ]]; then echo echo "${vhostname} nginx vhost + pureftp virtual ftp user setup" if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then vhostsetup "${vhostname}" https else vhostsetup "${vhostname}" fi # if webroot path directory exists # + ssl vhost file does not exist # + no ssl_certificate line exists in the non-https vhost file elif [[ -d "$WEBROOTPATH_OPT" && ! -f "$SSLVHOST_CONFIG" ]] && [[ "$(grep -sq ssl_certificate /usr/local/nginx/conf/conf.d/${vhostname}.conf; echo $?)" != '0' ]]; then sslopts_check if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then sslvhostsetup https else sslvhostsetup fi # if webroot path directory exists # + ssl vhost file does not exist # + ssl_certificates line exists in non-https vhost file elif [[ -d "$WEBROOTPATH_OPT" ]] && [[ "$(grep -sq ssl_certificate /usr/local/nginx/conf/conf.d/${vhostname}.conf; echo $?)" = '0' ]] && [[ ! -f "$SSLVHOST_CONFIG" ]]; then if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then sslvhostsetup https else sslvhostsetup fi mv "$SSLVHOST_CONFIG" "${ACMEBACKUPDIR}/${SSLVHOST_CONFIGFILENAME}-acmebackup-${DT}-disabled" SSLVHOST_CONFIG="${ACMEBACKUPDIR}/${SSLVHOST_CONFIGFILENAME}-acmebackup-${DT}-disabled" fi fi # DNS Mode certonly 0 ############################################ # DNS mode cert only don't touch nginx vhosts # 1 if [[ "$CERTONLY_DNS" != '1' ]]; then # if webroot path directory exists # + vhostname value exists # + ssl vhost file exists # + public webroot path doesn't exist if [[ -d "$WEBROOTPATH_OPT" && ! -z "$vhostname" && -f "$SSLVHOST_CONFIG" && "$VHOST_ALREADYSET" != 'y' ]]; then check_dns "$vhostname" if [[ "$TOPLEVEL" = [yY] ]]; then if [[ "$SAN" = '1' ]]; then DOMAINOPT="-d $DOMAIN_LIST -d www.${vhostname}" else DOMAINOPT="-d ${vhostname} -d www.${vhostname}" fi else if [[ "$SAN" = '1' ]]; then DOMAINOPT="-d $DOMAIN_LIST" else DOMAINOPT="-d ${vhostname}" fi fi if [[ "$testcert" = 'lived' || "$testcert" = 'd' ]]; then # if https default via d or lived option, then backup non-https vhostname.conf to backup directory # and remove the non-https vhostname.conf file echo "backup & remove /usr/local/nginx/conf/conf.d/$vhostname.conf" cp -a "/usr/local/nginx/conf/conf.d/$vhostname.conf" "${ACMEBACKUPDIR}/$vhostname.conf-backup-removal-https-default-${DT}" >/dev/null 2>&1 rm -rf "/usr/local/nginx/conf/conf.d/$vhostname.conf" >/dev/null 2>&1 # if existing https vhostname.ssl.conf file exists replace it with one with proper http to https redirect if [ -f "/usr/local/nginx/conf/conf.d/$vhostname.ssl.conf" ]; then # sslvhostsetup https $vhostname sslopts_check sslvhostsetup https fi else cp -a "/usr/local/nginx/conf/conf.d/$vhostname.conf" "${ACMEBACKUPDIR}/$vhostname.conf-acmebackup-$DT" >/dev/null 2>&1 fi cp -a "$SSLVHOST_CONFIG" "${ACMEBACKUPDIR}/$SSLVHOST_CONFIGFILENAME-acmebackup-$DT" if [[ "$testcert" != 'lived' || "$testcert" != 'd' || "$testcert" != 'wplived' || "$testcert" != 'wpd' ]]; then if [ -f "/usr/local/nginx/conf/conf.d/$vhostname.conf" ]; then sed -i "s|server_name .*|server_name $DOMAIN_LISTNGX;|" "/usr/local/nginx/conf/conf.d/$vhostname.conf" echo "grep 'root' "/usr/local/nginx/conf/conf.d/$vhostname.conf"" grep 'root' "/usr/local/nginx/conf/conf.d/$vhostname.conf" fi # if [[ ! -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" && -f "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf" ]]; then # # if existing or previous /usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf has the ssl cert key and trust files # # inline in vhost, need to move them to their own include file for acmetool.sh at # # /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf # convert_crtkeyinc # fi fi sed -i "s|server_name .*|server_name $DOMAIN_LISTNGX;|" "$SSLVHOST_CONFIG" echo "grep 'root' $SSLVHOST_CONFIG" grep 'root' "$SSLVHOST_CONFIG" /usr/bin/ngxreload >/dev/null 2>&1 fi elif [[ "$CERTONLY_DNS" = '1' ]]; then check_dns "$vhostname" if [[ "$TOPLEVEL" = [yY] ]]; then if [[ "$SAN" = '1' ]]; then DOMAINOPT="-d $DOMAIN_LIST -d www.${vhostname}" else DOMAINOPT="-d ${vhostname} -d www.${vhostname}" fi else if [[ "$SAN" = '1' ]]; then DOMAINOPT="-d $DOMAIN_LIST" else DOMAINOPT="-d ${vhostname}" fi fi fi # DNS Mode certonly 1 echo echo "-----------------------------------------------------------" echo "[DNS mode] issue & install letsencrypt ssl certificate for $vhostname" echo "-----------------------------------------------------------" # if CF_DNSAPI enabled for Cloudflare DNS mode, use Cloudflare API for setting # up DNS mode validation via TXT DNS record creation if [[ "$CF_DNSAPI" = [yY] ]] && [[ ! -z "$CF_KEY" && ! -z "$CF_Email" ]] && [[ -z "$CF_Token" && -z "$CF_Account_ID" ]]; then # if global api set and token not set export CF_Key="$CF_KEY" export CF_Email="$CF_EMAIL" DNSAPI_OPT=' dns_cf' sed -i "s|^#CF_|CF_|" "$ACMECERTHOME"account.conf sed -i "s|CF_Key=\".*|CF_Key=\"$CF_KEY\"|" "$ACMECERTHOME"account.conf sed -i "s|CF_Email=\".*|CF_Email=\"$CF_EMAIL\"|" "$ACMECERTHOME"account.conf elif [[ "$CF_DNSAPI" = [yY] ]] && [[ ! -z "$CF_Token" && ! -z "$CF_Account_ID" ]] && [[ -z "$CF_KEY" && -z "$CF_Email" ]]; then # if token set and global api not set export CF_Token="$CF_Token" export CF_Account_ID="$CF_Account_ID" DNSAPI_OPT=' dns_cf' sed -i "s|^#CF_|CF_|" "$ACMECERTHOME"account.conf sed -i "s|CF_Token=\".*|CF_Token=\"$CF_Token\"|" "$ACMECERTHOME"account.conf sed -i "s|CF_Account_ID=\".*|CF_Account_ID=\"$CF_Account_ID\"|" "$ACMECERTHOME"account.conf elif [[ "$CF_DNSAPI" = [yY] ]] && [[ ! -z "$CF_Token" && ! -z "$CF_Account_ID" ]] && [[ ! -z "$CF_KEY" && ! -z "$CF_Email" ]]; then # if both global api key and token set, prefer token api method export CF_Token="$CF_Token" export CF_Account_ID="$CF_Account_ID" DNSAPI_OPT=' dns_cf' sed -i "s|^#CF_|CF_|" "$ACMECERTHOME"account.conf sed -i "s|CF_Token=\".*|CF_Token=\"$CF_Token\"|" "$ACMECERTHOME"account.conf sed -i "s|CF_Account_ID=\".*|CF_Account_ID=\"$CF_Account_ID\"|" "$ACMECERTHOME"account.conf else DNSAPI_OPT="" fi # if the option flag = live is not passed on command line, the issuance uses the # staging test ssl certificates echo "testcert value = $testcert" if [[ "$CERTONLY_DNS" = '1' && "$STAGE_DNS" = 'live' ]]; then DNS_RENEWSTAGEOPT="" else DNS_RENEWSTAGEOPT=" --staging" fi if [[ -f "$ACMECERTHOME${vhostname}${ECC_ACMEHOMESUFFIX}/${vhostname}.key" ]]; then DNS_ISSUEOPT='--issue --force' else DNS_ISSUEOPT='--issue --force' fi if [[ "$testcert" = 'live' || "$testcert" = 'lived' || "$testcert" != 'd' || "$testcert" = 'wplive' || "$testcert" = 'wplived' || "$testcert" != 'wptestd' ]] && [[ "$testcert" != 'wptest' ]] && [[ ! -z "$testcert" ]]; then echo ""$ACMEBINARY" ${DNS_ISSUEOPT} --dns${DNSAPI_OPT} $DOMAINOPT -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY" ${DNS_ISSUEOPT} --dns${DNSAPI_OPT} $DOMAINOPT -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} 2>&1 | tee "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" LECHECK=$? ############################################ # DNS mode cert only don't touch nginx vhosts # 2 if [[ "$CERTONLY_DNS" != '1' ]]; then # only enable resolver and ssl_stapling for live ssl certificate deployments if [[ -f "$SSLVHOST_CONFIG" && "$LECHECK" = '0' ]]; then sed -i "s|#resolver |resolver |" "$SSLVHOST_CONFIG" sed -i "s|#resolver_timeout|resolver_timeout|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling on|ssl_stapling on|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_stapling_verify|ssl_stapling_verify|" "$SSLVHOST_CONFIG" sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "$SSLVHOST_CONFIG" if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" ]; then sed -i "s|#ssl_trusted_certificate|ssl_trusted_certificate|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" fi fi fi # DNS Mode certonly 2 elif [[ "$CERTONLY_DNS" = '1' && "$STAGE_DNS" = 'live' ]]; then echo ""$ACMEBINARY" ${DNS_ISSUEOPT} --dns${DNSAPI_OPT} $DOMAINOPT -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY" ${DNS_ISSUEOPT} --dns${DNSAPI_OPT} $DOMAINOPT -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} 2>&1 | tee "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" LECHECK=$? else echo ""$ACMEBINARY" --staging ${DNS_ISSUEOPT} --dns${DNSAPI_OPT} $DOMAINOPT -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" "$ACMEBINARY" --staging ${DNS_ISSUEOPT} --dns${DNSAPI_OPT} $DOMAINOPT -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN} 2>&1 | tee "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" LECHECK=$? fi if [[ "$CF_DNSAPI" != [yY] && -z "$CF_KEY" && -z "$CF_Email" ]] || [[ "$CF_DNSAPI" != [yY] && -z "$CF_Token" && -z "$CF_Account_ID" ]]; then if [ -f "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" ]; then # echo " Final Step to complete SSL Certificate Issuance" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" echo " Once DNS updated for $vhostname, run SSH command: " >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" echo "---------------------------------" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" echo " $ACMEBINARY --force --renew --days $RENEWDAYS${DNS_RENEWSTAGEOPT}${ECCFLAG} $DOMAINOPT" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" echo "---------------------------------" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" echo " SSL certs will be located : $ACMECERTHOME${vhostname}${ECC_ACMEHOMESUFFIX}" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" echo "" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" echo " If want to install cert into an **EXISTING** Nginx vhost for ${vhostname}, run SSH command: " >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" # echo "" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" echo "---------------------------------" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" echo " "$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIX}. key"${ECCFLAG}" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" echo "---------------------------------" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" echo " SSL certs will be installed at : /usr/local/nginx/conf/ssl/${vhostname}/" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" echo "" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" fi else if [ -f "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" ]; then echo " If want to install cert into Nginx vhost, run SSH command: " >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" # echo "" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" echo "---------------------------------" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" echo " "$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIX}. key"${ECCFLAG}" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" echo "---------------------------------" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" echo " SSL certs will be installed at : /usr/local/nginx/conf/ssl/${vhostname}/" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" echo "" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" fi fi # if CF_DNSAPI enabled can skip this text ############################################ # DNS mode cert only don't touch nginx vhosts # 3 if [[ "$CERTONLY_DNS" != '1' ]]; then # LECHECK=$? echo "LECHECK = $LECHECK" if [[ "$LECHECK" = '0' ]]; then if [[ "$KEYLENGTH" = 'ec-256' || "$KEYLENGTH" = 'ec-384' ]]; then sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.key|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.key|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-trusted.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme${ECC_SUFFIX}.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" else sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}.key|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.key|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" sed -i "s|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-trusted.crt|\/usr\/local\/nginx\/conf\/ssl\/${vhostname}\/${vhostname}-acme.cer|" "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" fi egrep 'ssl_dhparam|ssl_certificate|ssl_certificate_key|ssl_trusted_certificate' "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt.key.conf" | tee /usr/local/nginx/conf/ssl/${vhostname}/acme-vhost-config.txt echo echo "-----------------------------------------------------------" echo "install cert" echo "-----------------------------------------------------------" # ensure directory exists before installing and copying ssl cert files # to /usr/local/nginx/conf/ssl/${vhostname} if [ ! -d "/usr/local/nginx/conf/ssl/${vhostname}" ]; then mkdir -p "/usr/local/nginx/conf/ssl/${vhostname}" fi echo ""$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIX}.key"${ECCFLAG}" "$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIX}.key"${ECCFLAG} if [ -f "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" ]; then chmod 0644 "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" fi if [ -f "${CENTMINLOGDIR}/centminmod_${DT}_nginx_addvhost_nv-remove-cmds-${vhostname}.log" ]; then echo "rm -rf ${ACMECERTHOME}/${vhostname}" >> "${CENTMINLOGDIR}/centminmod_${DT}_nginx_addvhost_nv-remove-cmds-${vhostname}.log" fi # allow it to be repopulated each time with $vhostname # rm -rf /root/.acme.sh/reload.sh echo echo "letsencrypt ssl certificate setup completed" echo "ssl certs located at: /usr/local/nginx/conf/ssl/${vhostname}" pushover_alert $vhostname backup_acme $vhostname echo echo "openssl x509 -noout -text < "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer"" openssl x509 -noout -text < "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" listlogs echo elif [[ "$LECHECK" = '1' ]]; then listlogs echo elif [[ "$LECHECK" = '2' ]]; then echo echo "issue / renewal skipped as ssl cert still valid" listlogs echo fi # reloadcmd_setup elif [[ "$CERTONLY_DNS" = '1' ]]; then if [[ "$CF_DNSAPI" != [yY] && -z "$CF_KEY" && -z "$CF_Email" ]] || [[ "$CF_DNSAPI" != [yY] && -z "$CF_Token" && -z "$CF_Account_ID" ]]; then echo echo "---------------------------------" echo " DNS mode requires manual steps below" echo "---------------------------------" cat "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" | grep -A30 'Add the following TXT record' | perl -pe 's/\x1b.*?[mGKH]//g' | sed 's/\[[^]]*\]//g' | egrep -v 'Please be aware that you prepend|resulting subdomain|and retry again' pushover_alert $vhostname dns "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" # backup_acme $vhostname echo echo elif [[ "$CF_DNSAPI" = [yY] && ! -z "$CF_KEY" && ! -z "$CF_Email" ]] || [[ "$CF_DNSAPI" = [yY] && ! -z "$CF_Token" && ! -z "$CF_Account_ID" ]]; then echo echo "---------------------------------" echo " DNS mode via Cloudflare DNS API" echo "---------------------------------" echo " setup TXT DNS record via Cloudflare API" cat "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" | perl -pe 's/\x1b.*?[mGKH]//g' | sed 's/\[[^]]*\]//g' | grep -A60 'Verify each domain' | sed '/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/d' echo pushover_alert $vhostname dnscf "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" echo " If want to install cert into Nginx vhost, run SSH command: " >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" # echo "" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" echo "---------------------------------" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" echo " "$ACMEBINARY" --installcert $DOMAINOPT --certpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --keypath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.key" --capath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-acme${ECC_SUFFIX}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-fullchain-acme${ECC_SUFFIX}. key"${ECCFLAG}" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" echo "---------------------------------" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" echo " SSL certs will be installed at (requires manual configuration in intended Nginx vhost config files community.centminmod.com/posts/35135/): /usr/local/nginx/conf/ssl/${vhostname}/" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" echo "" >> "${CENTMINLOGDIR}/acme.sh-dnslog-${vhostname}${ECC_SUFFIX}-${DT}.log" fi # if CF_DNSAPI enabled can skip this text fi # DNS Mode certonly 3 } ##################### manual_mode() { echo cecho "---------------------------------------------------------------------------" $boldgreen cecho "acmetool.sh manual mode" $boldyellow cecho "---------------------------------------------------------------------------" $boldgreen echo "interactive mode to obtain & install letsencrypt ssl certs" echo "you will need to manually install the ssl certs to your nginx" echo "site ssl vhost yourself as this manual mode only obtains ssl cert" echo "and places them in /usr/local/nginx/conf/ssl/yourdomain.com" echo "directory which you reference in your nginx vhost as outlined" echo "at centminmod.com/nginx_configure_https_ssl_spdy.html" cecho "---------------------------------------------------------------------------" $boldgreen echo "the nginx vhost site needs to exist with valid DNS A records" echo "pointing to this server's IP address before continuing..." cecho "---------------------------------------------------------------------------" $boldgreen echo read -ep "continue ? [y/n]: " manual_continue if [[ "$manual_continue" != [yY] ]]; then exit fi echo cecho "---------------------------------------------------------------------------" $boldgreen cecho "step 1: domain verification" $boldyellow cecho "---------------------------------------------------------------------------" $boldgreen echo "type the following manually to get a letsencrypt ssl certificate" echo "replacing -d domain.com -d www.domain.com with yourdomain.com name" echo "at end of output you will be notified if you successfully verified" echo "your domain name and obtained a letsencrypt ssl certificate to" echo "proceed to step 2 which is copying over the ssl certs to nginx" echo "custom directory at /usr/local/nginx/conf/ssl/yourdomain.com" cecho "---------------------------------------------------------------------------" $boldgreen echo "2 commands over 2 lines: " echo getuseragent echo "$0 acmeupdate" echo "$ACMEBINARY --force --issue -d domain.com -d www.domain.com -w /home/nginx/domains/domain.com/public -k "$KEYLENGTH" --useragent "$LE_USERAGENT" $ACMEDEBUG_OPT${ACME_PREFERRED_CHAIN}" echo cecho "---------------------------------------------------------------------------" $boldgreen cecho "step 2: copying ssl cert to /usr/local/nginx/conf/ssl/yourdomain.com" $boldyellow cecho "---------------------------------------------------------------------------" $boldgreen echo "replacing -d domain.com -d www.domain.com with yourdomain.com name" echo "& replacing all instances of domain.com with yourdomain.com name" echo "a log is created for troubleshooting at:" echo "${CENTMINLOGDIR}/acmetool.sh-debug-log-$DT.log" echo "if you do not currently have your domain.com.ssl.conf file, you can use" echo "vhost generator at centminmod.com/vhost.php enter domain name and select" echo "self-signed ssl yes and you should see initial openssl command instructions" echo "for recreating the self-signed ssl cert and the domain.com.ssl.conf vhost file" echo "/usr/local/nginx/conf/conf.d/domain.com.ssl.conf which also creates the required" echo "directory for /usr/local/nginx/conf/ssl/yourdomain.com" cecho "---------------------------------------------------------------------------" $boldgreen echo "1 command over 1 long line: " echo echo "$ACMEBINARY --installcert -d domain.com -d www.domain.com --certpath "/usr/local/nginx/conf/ssl/domain.com/domain.com-acme${ECC_SUFFIX}.cer" --keypath "/usr/local/nginx/conf/ssl/domain.com/domain.com-acme${ECC_SUFFIX}.key" --capath "/usr/local/nginx/conf/ssl/domain.com/domain.com-acme${ECC_SUFFIX}.cer" --reloadCmd /usr/bin/ngxreload --fullchainpath "/usr/local/nginx/conf/ssl/domain.com/domain.com-fullchain-acme${ECC_SUFFIX}.key${ECCFLAG}"" cecho "---------------------------------------------------------------------------" $boldgreen echo cecho "---------------------------------------------------------------------------" $boldgreen cecho "step 3: manually install the ssl certs to your nginx vhost" $boldyellow cecho "---------------------------------------------------------------------------" $boldgreen echo "treat ssl cert like any other and install the ssl cert files" echo "as outlined at centminmod.com/nginx_configure_https_ssl_spdy.html" echo "with path to ssl cert files at /usr/local/nginx/conf/ssl/yourdomain.com" echo "note for ssl_trusted_certificate path is same as ssl_certificate for" echo "letsencrypt ssl so no concatenation of files is needed" cecho "---------------------------------------------------------------------------" $boldgreen echo "replacing all instances of domain.com with yourdomain.com name" echo "your nginx ssl vhost would have the following lines as well as" echo "other ssl settings outlined at centminmod.com/nginx_configure_https_ssl_spdy.html" cecho "---------------------------------------------------------------------------" $boldgreen echo "step 2 above would of created your /usr/local/nginx/conf/conf.d/domain.com.ssl.conf" echo "you then replace paths for ssl_certificate, ssl_certificate_key and " echo "ssl_trusted_certificate with below ones" cecho "---------------------------------------------------------------------------" $boldgreen echo echo "ssl_certificate /usr/local/nginx/conf/ssl/domain.com/domain.com-acme${ECC_SUFFIX}.cer;" echo "ssl_certificate_key /usr/local/nginx/conf/ssl/domain.com/domain.com-acme${ECC_SUFFIX}.key;" echo "ssl_trusted_certificate /usr/local/nginx/conf/ssl/domain.com/domain.com-acme${ECC_SUFFIX}.cer;" echo } ##################### sslmenu_issue() { while : do echo cecho "--------------------------------------------------------" $boldyellow cecho " SSL Issue Management " $boldgreen cecho "--------------------------------------------------------" $boldyellow cecho "1). Issue SSL Cert Staging/Test" $boldgreen cecho "2). Issue SSL Cert Staging/Test HTTPS Default" $boldgreen cecho "3). Issue SSL Cert Live" $boldgreen cecho "4). Issue SSL Cert Live HTTPS Default" $boldgreen cecho "5). Custom Webroot Issue SSL Cert Staging/Test" $boldgreen cecho "6). Custom Webroot Issue SSL Cert Staging/Test HTTPS Default" $boldgreen cecho "7). Custom Webroot Issue SSL Cert Live" $boldgreen cecho "8). Custom Webroot Issue SSL Cert Live HTTPS Default" $boldgreen cecho "9). S3 Issue SSL Cert" $boldgreen cecho "10). S3 Issue SSL Cert" $boldgreen cecho "11). S3 Issue SSL Cert" $boldgreen cecho "12). S3 Issue SSL Cert" $boldgreen cecho "13). Exit" $boldgreen cecho "--------------------------------------------------------" $boldyellow read -ep "Enter option [ 1 - 13 ] " sslmenuissue_options cecho "--------------------------------------------------------" $boldyellow ######################################################### case "$sslmenuissue_options" in 1) MENU3=1 { echo cecho "..." $boldyellow enter_domainname $0 issue $input_domain # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu1.log ;; 2) MENU3=2 { echo cecho "..." $boldyellow enter_domainname $0 issue $input_domain d # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu2.log ;; 3) MENU3=3 { echo cecho "..." $boldyellow enter_domainname $0 issue $input_domain live # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu3.log ;; 4) MENU3=4 { echo cecho "..." $boldyellow enter_domainname $0 issue $input_domain lived # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu4.log ;; 5) MENU3=5 { echo cecho "..." $boldyellow enter_domainname enter_webroot $0 webroot-issue $input_domain $input_webroot # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu5.log ;; 6) MENU3=6 { echo cecho "..." $boldyellow enter_domainname enter_webroot $0 webroot-issue $input_domain $input_webroot d # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu6.log ;; 7) MENU3=7 { echo cecho "..." $boldyellow enter_domainname enter_webroot $0 webroot-issue $input_domain $input_webroot live # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu7.log ;; 8) MENU3=8 { echo cecho "..." $boldyellow enter_domainname enter_webroot $0 webroot-issue $input_domain $input_webroot lived # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu8.log ;; 9) MENU3=9 { echo cecho "..." $boldyellow enter_domainname # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu9.log ;; 10) MENU3=10 { echo cecho "..." $boldyellow enter_domainname # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu10.log ;; 11) MENU3=11 { echo cecho "..." $boldyellow enter_domainname # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu11.log ;; 12) MENU3=12 { echo cecho "..." $boldyellow enter_domainname # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu12.log ;; 13) MENU3=13 break 2 ;; esac done } ##################### sslmenu_renew() { while : do echo cecho "--------------------------------------------------------" $boldyellow cecho " SSL Renew Management " $boldgreen cecho "--------------------------------------------------------" $boldyellow cecho "1). Renew SSL Cert Staging/Test" $boldgreen cecho "2). Renew SSL Cert Staging/Test HTTPS Default" $boldgreen cecho "3). Renew SSL Cert Live" $boldgreen cecho "4). Renew SSL Cert Live HTTPS Default" $boldgreen cecho "5). Custom Webroot Renew SSL Cert Staging/Test" $boldgreen cecho "6). Custom Webroot Renew SSL Cert Staging/Test HTTPS Default" $boldgreen cecho "7). Custom Webroot Renew SSL Cert Live" $boldgreen cecho "8). Custom Webroot Renew SSL Cert Live HTTPS Default" $boldgreen cecho "9). S3 Renew SSL Cert" $boldgreen cecho "10). S3 Renew SSL Cert" $boldgreen cecho "11). S3 Renew SSL Cert" $boldgreen cecho "12). S3 Renew SSL Cert" $boldgreen cecho "13). Exit" $boldgreen cecho "--------------------------------------------------------" $boldyellow read -ep "Enter option [ 1 - 13 ] " sslmenurenew_options cecho "--------------------------------------------------------" $boldyellow ######################################################### case "$sslmenurenew_options" in 1) MENU3=1 { echo cecho "..." $boldyellow enter_domainname $0 renew $input_domain # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu1.log ;; 2) MENU3=2 { echo cecho "..." $boldyellow enter_domainname $0 renew $input_domain d # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu2.log ;; 3) MENU3=3 { echo cecho "..." $boldyellow enter_domainname $0 renew $input_domain live # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu3.log ;; 4) MENU3=4 { echo cecho "..." $boldyellow enter_domainname $0 renew $input_domain lived # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu4.log ;; 5) MENU3=5 { echo cecho "..." $boldyellow enter_domainname enter_webroot $0 webroot-renew $input_domain $input_webroot # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu5.log ;; 6) MENU3=6 { echo cecho "..." $boldyellow enter_domainname enter_webroot $0 webroot-renew $input_domain $input_webroot d # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu6.log ;; 7) MENU3=7 { echo cecho "..." $boldyellow enter_domainname enter_webroot $0 webroot-renew $input_domain $input_webroot live # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu7.log ;; 8) MENU3=8 { echo cecho "..." $boldyellow enter_domainname enter_webroot $0 webroot-renew $input_domain $input_webroot lived # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu8.log ;; 9) MENU3=9 { echo cecho "..." $boldyellow enter_domainname # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu9.log ;; 10) MENU3=10 { echo cecho "..." $boldyellow enter_domainname # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu10.log ;; 11) MENU3=11 { echo cecho "..." $boldyellow enter_domainname # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu11.log ;; 12) MENU3=12 { echo cecho "..." $boldyellow enter_domainname # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu12.log ;; 13) MENU3=13 break 2 ;; esac done } ##################### sslmenu_reissue() { while : do echo cecho "--------------------------------------------------------" $boldyellow cecho " SSL Reissue Management " $boldgreen cecho "--------------------------------------------------------" $boldyellow cecho "1). Reissue SSL Cert Staging/Test" $boldgreen cecho "2). Reissue SSL Cert Staging/Test HTTPS Default" $boldgreen cecho "3). Reissue SSL Cert Live" $boldgreen cecho "4). Reissue SSL Cert Live HTTPS Default" $boldgreen cecho "5). Custom Webroot Reissue SSL Cert Staging/Test" $boldgreen cecho "6). Custom Webroot Reissue SSL Cert Staging/Test HTTPS Default" $boldgreen cecho "7). Custom Webroot Reissue SSL Cert Live" $boldgreen cecho "8). Custom Webroot Reissue SSL Cert Live HTTPS Default" $boldgreen cecho "9). S3 Reissue SSL Cert" $boldgreen cecho "10). S3 Reissue SSL Cert" $boldgreen cecho "11). S3 Reissue SSL Cert" $boldgreen cecho "12). S3 Reissue SSL Cert" $boldgreen cecho "13). Exit" $boldgreen cecho "--------------------------------------------------------" $boldyellow read -ep "Enter option [ 1 - 13 ] " sslmenureissue_options cecho "--------------------------------------------------------" $boldyellow ######################################################### case "$sslmenureissue_options" in 1) MENU3=1 { echo cecho "..." $boldyellow enter_domainname $0 reissue $input_domain # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu1.log ;; 2) MENU3=2 { echo cecho "..." $boldyellow enter_domainname $0 reissue $input_domain d # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu2.log ;; 3) MENU3=3 { echo cecho "..." $boldyellow enter_domainname $0 reissue $input_domain live # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu3.log ;; 4) MENU3=4 { echo cecho "..." $boldyellow enter_domainname $0 reissue $input_domain lived # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu4.log ;; 5) MENU3=5 { echo cecho "..." $boldyellow enter_domainname enter_webroot $0 webroot-reissue $input_domain $input_webroot # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu5.log ;; 6) MENU3=6 { echo cecho "..." $boldyellow enter_domainname enter_webroot $0 webroot-reissue $input_domain $input_webroot d # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu6.log ;; 7) MENU3=7 { echo cecho "..." $boldyellow enter_domainname enter_webroot $0 webroot-reissue $input_domain $input_webroot live # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu7.log ;; 8) MENU3=8 { echo cecho "..." $boldyellow enter_domainname enter_webroot $0 webroot-reissue $input_domain $input_webroot lived # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu8.log ;; 9) MENU3=9 { echo cecho "..." $boldyellow enter_domainname # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu9.log ;; 10) MENU3=10 { echo cecho "..." $boldyellow enter_domainname # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu10.log ;; 11) MENU3=11 { echo cecho "..." $boldyellow enter_domainname # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu11.log ;; 12) MENU3=12 { echo cecho "..." $boldyellow enter_domainname # break 2 } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu12.log ;; 13) MENU3=13 break 2 ;; esac done } ##################### sslmenu() { while : do echo cecho "--------------------------------------------------------" $boldyellow cecho " SSL Management " $boldgreen cecho "--------------------------------------------------------" $boldyellow cecho "1). acemtool.sh install" $boldgreen cecho "2). acmetool.sh update" $boldgreen cecho "3). acmetool.sh setup" $boldgreen cecho "4). Issue SSL Management" $boldgreen cecho "5). Renew SSL Management" $boldgreen cecho "6). Reissue SSL Management" $boldgreen cecho "7). Renew All Staging /Test Certs" $boldgreen cecho "8). Renew ALL Live Certs " $boldgreen cecho "9). Renew All Live Certs HTTPS Default" $boldgreen cecho "10). Exit" $boldgreen cecho "--------------------------------------------------------" $boldyellow read -ep "Enter option [ 1 - 10 ] " sslmenu_options cecho "--------------------------------------------------------" $boldyellow ######################################################### case "$sslmenu_options" in 1) MENU3=1 { echo cecho "..." $boldyellow nvcheck install_acme } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu1.log ;; 2) MENU3=2 { echo cecho "..." $boldyellow nvcheck update_acme } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu2.log ;; 3) MENU3=3 { echo cecho "..." $boldyellow nvcheck setup_acme } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu3.log ;; 4) MENU3=4 { echo cecho "..." $boldyellow sslmenu_issue } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu4.log ;; 5) MENU3=5 { echo cecho "..." $boldyellow sslmenu_renew } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu5.log ;; 6) MENU3=6 { echo cecho "..." $boldyellow sslmenu_reissue } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu6.log ;; 7) MENU3=7 { echo cecho "..." $boldyellow nvcheck testcert="" getuseragent renew_all } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu7.log ;; 8) MENU3=8 { echo cecho "..." $boldyellow nvcheck testcert="live" getuseragent renew_all } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu8.log ;; 9) MENU3=9 { echo cecho "..." $boldyellow echo cecho "..." $boldyellow nvcheck testcert="lived" getuseragent renew_all } 2>&1 | tee ${CENTMINLOGDIR}/acmetool-menu_${SCRIPT_VERSION}_${DT}_menu3-submenu9.log ;; 10) MENU3=10 break ;; esac done } ###################################################### case "$1" in manual ) { manual_mode } 2>&1 | tee "${CENTMINLOGDIR}/acmesh-manual-mode_${DT}.log" ;; acmeinstall ) { nvcheck install_acme } 2>&1 | tee "${CENTMINLOGDIR}/acmesh-install_${DT}.log" ;; acmeupdate ) { nvcheck update_acme } 2>&1 | tee "${CENTMINLOGDIR}/acmesh-update_${DT}.log" ;; acmesetup ) { nvcheck setup_acme } 2>&1 | tee "${CENTMINLOGDIR}/acmesh-setup_${DT}.log" ;; issue ) { nvcheck vhostname="$2" testcert="$3" getuseragent update_acme quite issue_acme } 2>&1 | tee "${CENTMINLOGDIR}/acmesh-issue_${DT}.log" ;; reissue ) { nvcheck vhostname="$2" testcert="$3" getuseragent update_acme quite reissue_acme } 2>&1 | tee "${CENTMINLOGDIR}/acmesh-reissue_${DT}.log" ;; reissue-only ) { nvcheck vhostname="$2" testcert="$3" getuseragent update_acme quite reissue_acme_only } 2>&1 | tee "${CENTMINLOGDIR}/acmesh-reissue-only_${DT}.log" ;; renew ) { nvcheck vhostname="$2" testcert="$3" getuseragent update_acme quite renew_acme } 2>&1 | tee "${CENTMINLOGDIR}/acmesh-renew_${DT}.log" ;; webroot-issue ) { nvcheck vhostname="$2" customwebroot="$3" testcert="$4" getuseragent update_acme quite webroot_issueacme } 2>&1 | tee "${CENTMINLOGDIR}/acmesh-webroot-issue_${DT}.log" ;; webroot-reissue ) { nvcheck vhostname="$2" customwebroot="$3" testcert="$4" getuseragent update_acme quite webroot_reissueacme } 2>&1 | tee "${CENTMINLOGDIR}/acmesh-webroot-reissue_${DT}.log" ;; webroot-renew ) { nvcheck vhostname="$2" customwebroot="$3" testcert="$4" getuseragent update_acme quite webroot_renewacme } 2>&1 | tee "${CENTMINLOGDIR}/acmesh-webroot-renew_${DT}.log" ;; s3issue ) # aws s3 bucket'd { nvcheck vhostname="$2" testcert="$3" getuseragent update_acme quite awsissue_acme } 2>&1 | tee "${CENTMINLOGDIR}/acmesh-awsissue_${DT}.log" ;; s3reissue ) # aws s3 bucket'd { nvcheck vhostname="$2" testcert="$3" getuseragent update_acme quite awsreissue_acme } 2>&1 | tee "${CENTMINLOGDIR}/acmesh-awsreissue_${DT}.log" ;; s3renew ) # aws s3 bucket'd { nvcheck vhostname="$2" testcert="$3" getuseragent update_acme quite awsrenew_acme } 2>&1 | tee "${CENTMINLOGDIR}/acmesh-awsrenew_${DT}.log" ;; renewall ) # aws s3 bucket'd { nvcheck testcert="$2" getuseragent renew_all } 2>&1 | tee "${CENTMINLOGDIR}/acmesh-renewall_${DT}.log" ;; acme-menu ) sslmenu ;; checkdates ) checkdate ;; checkdomains ) check_domains ;; check_cfapi ) check_cfdns_api ;; certonly-issue ) { nvcheck vhostname="$2" testcert="$3" getuseragent dns update_acme quite if [ "$testcert" = 'live' ]; then issue_acmedns 1 live else issue_acmedns 1 fi } 2>&1 | tee "${CENTMINLOGDIR}/acmesh-certonly-issue_${DT}.log" ;; * ) echo echo " $0 {acme-menu|acmeinstall|acmeupdate|acmesetup|manual|issue|reissue|reissue-only|renew|certonly-issue|s3issue|s3reissue|s3renew|renewall|checkdates|checkdomains|check_cfapi}" echo " Usage Commands: $0 acme-menu $0 acmeinstall $0 acmeupdate $0 acmesetup $0 manual $0 issue domainname $0 issue domainname d $0 issue domainname live $0 issue domainname lived $0 reissue domainname $0 reissue domainname d $0 reissue domainname live $0 reissue domainname lived $0 reissue-only domainname $0 reissue-only domainname live $0 renew domainname $0 renew domainname d $0 renew domainname live $0 renew domainname lived $0 webroot-issue domainname /path/to/custom/webroot $0 webroot-issue domainname /path/to/custom/webroot d $0 webroot-issue domainname /path/to/custom/webroot live $0 webroot-issue domainname /path/to/custom/webroot lived $0 webroot-reissue domainname /path/to/custom/webroot $0 webroot-reissue domainname /path/to/custom/webroot d $0 webroot-reissue domainname /path/to/custom/webroot live $0 webroot-reissue domainname /path/to/custom/webroot lived $0 webroot-renew domainname /path/to/custom/webroot $0 webroot-renew domainname /path/to/custom/webroot d $0 webroot-renew domainname /path/to/custom/webroot live $0 webroot-renew domainname /path/to/custom/webroot lived $0 certonly-issue domainname $0 certonly-issue domainname live $0 s3issue domainname $0 s3issue domainname d $0 s3issue domainname live $0 s3issue domainname lived $0 s3reissue domainname $0 s3reissue domainname d $0 s3reissue domainname live $0 s3reissue domainname lived $0 s3renew domainname $0 s3renew domainname d $0 s3renew domainname live $0 s3renew domainname lived $0 renewall $0 renewall live $0 renewall lived $0 checkdates $0 checkdomains $0 check_cfapi " ;; esac
centminmod/centminmod
addons/acmetool.sh
Shell
gpl-3.0
254,437
#!/bin/bash # Script that uses netdiscover -r $firstArg and output only the ip addresses # You can use this output for example to use as input list (-iL) for nmap sudo netdiscover -P -r $1|grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"
Adrian-dps/security-bash-scripts
netdisc.sh
Shell
gpl-3.0
234
#!/usr/bin/env bash #----------------------------------------------------------------------------------------------------------------------- # HELP function #----------------------------------------------------------------------------------------------------------------------- function help { usage="$(basename "$0") [-h] -s <file> -m <file> -p <file> -- runs the Autonomous Wi-Fi Direct (AWD) simulations. where: -h show this help -s scenario config file -m max clients config file -p parameters config file" printf "${usage}\n" exit -1 } #----------------------------------------------------------------------------------------------------------------------- # Check the script's arguments #----------------------------------------------------------------------------------------------------------------------- function check_arguments { if [ "$#" == 1 ] && [ "$1" = "-h" ]; then help elif [ "$#" -ne 6 ]; then echo "Error: Illegal number of arguments" help fi while [[ $# -gt 1 ]] do key="$1" case $key in -s) SCENARIO_CONFIG="$2" shift # past argument ;; -m) MAX_CLIENTS_CONFIG="$2" shift # past argument ;; -p) PARAMETERS_CONFIG="$2" shift # past argument ;; esac shift # past argument or value done if [ -z "$SCENARIO_CONFIG" ] || [ -z "$PARAMETERS_CONFIG" ] || [ -z "$MAX_CLIENTS_CONFIG" ]; then echo "Error: Illegal arguments" help fi } #----------------------------------------------------------------------------------------------------------------------- # MAIN #----------------------------------------------------------------------------------------------------------------------- check_arguments "$@" jar_path="awd-sim.jar" java -jar ${jar_path} ${SCENARIO_CONFIG} ${PARAMETERS_CONFIG} ${MAX_CLIENTS_CONFIG}
bytec0d3/awd-sim
run_bin.sh
Shell
gpl-3.0
1,841
#!/bin/sh OPENSSL=openssl mkdir -p test-ca/newcerts echo echo "---[ Update server certificates ]---------------------------------------" echo cat openssl2.cnf | sed "s/#@CN@/commonName_default = server.w1.fi/" | sed "s/#@ALTNAME@/subjectAltName=DNS:server.w1.fi/" \ > openssl.cnf.tmp $OPENSSL ca -config $PWD/openssl.cnf.tmp -batch -in server.csr -out server.pem -extensions ext_server $OPENSSL pkcs12 -export -out server.pkcs12 -in server.pem -inkey server.key -passout pass: $OPENSSL pkcs12 -export -out server-extra.pkcs12 -in server.pem -inkey server.key -descert -certfile user.pem -passout pass:whatever -name server cat openssl2.cnf | sed "s/#@CN@/commonName_default = server3.w1.fi/" \ > openssl.cnf.tmp $OPENSSL ca -config $PWD/openssl.cnf.tmp -batch -in server-no-dnsname.csr -out server-no-dnsname.pem -extensions ext_server cat openssl2.cnf | sed "s/#@CN@/commonName_default = server5.w1.fi/" \ > openssl.cnf.tmp $OPENSSL ca -config $PWD/openssl.cnf.tmp -batch -in server-eku-client.csr -out server-eku-client.pem -extensions ext_client cat openssl2.cnf | sed "s/#@CN@/commonName_default = server6.w1.fi/" \ > openssl.cnf.tmp $OPENSSL ca -config $PWD/openssl.cnf.tmp -batch -in server-eku-client-server.csr -out server-eku-client-server.pem -extensions ext_client_server echo echo "---[ Update user certificates ]-----------------------------------------" echo cat openssl2.cnf | sed "s/#@CN@/commonName_default = User/" > openssl.cnf.tmp $OPENSSL ca -config $PWD/openssl.cnf.tmp -batch -in user.csr -out user.pem -extensions ext_client rm openssl.cnf.tmp $OPENSSL pkcs12 -export -out user.pkcs12 -in user.pem -inkey user.key -descert -passout pass:whatever $OPENSSL pkcs12 -export -out user2.pkcs12 -in user.pem -inkey user.key -descert -name Test -certfile server.pem -passout pass:whatever $OPENSSL pkcs12 -export -out user3.pkcs12 -in user.pem -inkey user.key -descert -name "my certificates" -certfile ca.pem -passout pass:whatever echo echo "---[ Update OCSP ]------------------------------------------------------" echo $OPENSSL ocsp -CAfile test-ca/cacert.pem -issuer test-ca/cacert.pem -cert server.pem -reqout ocsp-req.der -no_nonce $OPENSSL ocsp -index test-ca/index.txt -rsigner test-ca/cacert.pem -rkey test-ca/private/cakey.pem -CA test-ca/cacert.pem -resp_no_certs -reqin ocsp-req.der -respout ocsp-server-cache.der SIZ=`ls -l ocsp-server-cache.der | cut -f5 -d' '` (echo -n 000; echo "obase=16;$SIZ" | bc) | xxd -r -ps > ocsp-multi-server-cache.der cat ocsp-server-cache.der >> ocsp-multi-server-cache.der echo echo "---[ Additional steps ]-------------------------------------------------" echo echo "test_ap_eap.py: ap_wpa2_eap_ttls_server_cert_hash srv_cert_hash" $OPENSSL x509 -in server.pem -out server.der -outform DER HASH=`sha256sum server.der | cut -f1 -d' '` rm server.der sed -i "s/srv_cert_hash =.*/srv_cert_hash = \"$HASH\"/" ../test_ap_eap.py echo "index.txt: server time+serial" grep -v CN=server.w1.fi index.txt > index.txt.new grep CN=server.w1.fi test-ca/index.txt | tail -1 >> index.txt.new mv index.txt.new index.txt echo "start.sh: openssl ocsp -reqout serial" SERIAL=`grep CN=server.w1.fi test-ca/index.txt | tail -1 | cut -f4` sed -i "s/serial 0x[^ ]* -no_nonce/serial 0x$SERIAL -no_nonce/" ../start.sh
s0lst1c3/eaphammer
local/hostapd-eaphammer/tests/hwsim/auth_serv/update.sh
Shell
gpl-3.0
3,283
#!/usr/bin/env bash #------------------------------------------------------------------------------ # Bash script to execute the Solidity tests by CircleCI. # # The documentation for solidity is hosted at: # # https://docs.soliditylang.org # # ------------------------------------------------------------------------------ # Configuration Environment Variables: # # EVM=version_string Specifies EVM version to compile for (such as homestead, etc) # OPTIMIZE=1 Enables backend optimizer # ABI_ENCODER_V1=1 Forcibly enables ABI coder version 1 # SOLTEST_FLAGS=<flags> Appends <flags> to default SOLTEST_ARGS # # ------------------------------------------------------------------------------ # This file is part of solidity. # # solidity is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # solidity is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with solidity. If not, see <http://www.gnu.org/licenses/> # # (c) 2016-2019 solidity contributors. # ------------------------------------------------------------------------------ set -e OPTIMIZE=${OPTIMIZE:-"0"} EVM=${EVM:-"invalid"} REPODIR="$(realpath "$(dirname "$0")/..")" IFS=" " read -r -a BOOST_TEST_ARGS <<< "$BOOST_TEST_ARGS" IFS=" " read -r -a SOLTEST_FLAGS <<< "$SOLTEST_FLAGS" # shellcheck source=scripts/common.sh source "${REPODIR}/scripts/common.sh" # Test result output directory (CircleCI is reading test results from here) mkdir -p test_results # in case we run with ASAN enabled, we must increase stack size. ulimit -s 16384 get_logfile_basename() { local run="$1" local filename="${EVM}" test "${OPTIMIZE}" = "1" && filename="${filename}_opt" test "${ABI_ENCODER_V1}" = "1" && filename="${filename}_abiv1" filename="${filename}_${run}" echo -ne "${filename}" } [ -z "$CIRCLE_NODE_TOTAL" ] || [ "$CIRCLE_NODE_TOTAL" = 0 ] && CIRCLE_NODE_TOTAL=1 [ -z "$CIRCLE_NODE_INDEX" ] && CIRCLE_NODE_INDEX=0 [ -z "$INDEX_SHIFT" ] && INDEX_SHIFT=0 # Multiply by a prime number to get better spread, just in case # long-running test cases are next to each other. CIRCLE_NODE_INDEX=$(((CIRCLE_NODE_INDEX + 23 * INDEX_SHIFT) % CIRCLE_NODE_TOTAL)) CPUs=3 PIDs=() for run in $(seq 0 $((CPUs - 1))) do BOOST_TEST_ARGS_RUN=( "--color_output=no" "--show_progress=yes" "--logger=JUNIT,error,test_results/$(get_logfile_basename "$run").xml" "${BOOST_TEST_ARGS[@]}" ) SOLTEST_ARGS=("--evm-version=$EVM" "${SOLTEST_FLAGS[@]}") test "${OPTIMIZE}" = "1" && SOLTEST_ARGS+=(--optimize) test "${ABI_ENCODER_V1}" = "1" && SOLTEST_ARGS+=(--abiencoderv1) BATCH_ARGS=("--batches" "$((CPUs * CIRCLE_NODE_TOTAL))" "--selected-batch" "$((CPUs * CIRCLE_NODE_INDEX + run))") echo "Running ${REPODIR}/build/test/soltest ${BOOST_TEST_ARGS_RUN[*]} -- ${SOLTEST_ARGS[*]}" "${REPODIR}/build/test/soltest" -l test_suite "${BOOST_TEST_ARGS_RUN[@]}" -- "${SOLTEST_ARGS[@]}" "${BATCH_ARGS[@]}" & PIDs+=($!) done # wait for individual processes to get their exit status for pid in ${PIDs[*]} do wait "$pid" done
ethereum/solidity
.circleci/soltest.sh
Shell
gpl-3.0
3,527
#!/bin/bash # ***** BEGIN LICENSE BLOCK ***** # Version: MPL 1.1/GPL 2.0/LGPL 2.1 # # The contents of this file are subject to the Mozilla Public License Version # 1.1 (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # http://www.mozilla.org/MPL/ # # Software distributed under the License is distributed on an "AS IS" basis, # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License # for the specific language governing rights and limitations under the # License. # # The Original Code is the Network Security Services (NSS) # # The Initial Developer of the Original Code is Sun Microsystems, Inc. # Portions created by the Initial Developer are Copyright (C) 2006-2009 # the Initial Developer. All Rights Reserved. # # Contributor(s): # # Alternatively, the contents of this file may be used under the terms of # either the GNU General Public License Version 2 or later (the "GPL"), or # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), # in which case the provisions of the GPL or the LGPL are applicable instead # of those above. If you wish to allow use of your version of this file only # under the terms of either the GPL or the LGPL, and not to allow others to # use your version of this file under the terms of the MPL, indicate your # decision by deleting the provisions above and replace them with the notice # and other provisions required by the GPL or the LGPL. If you do not delete # the provisions above, a recipient may use your version of this file under # the terms of any one of the MPL, the GPL or the LGPL. # # ***** END LICENSE BLOCK ***** ###################################################################################### # Server and client certs and crl generator functions. Generated files placed in a <dir> # directory to be accessible through http://<webserver>/iopr/TestCA.crt directory. # This functions is used for manual webserver configuration and it is not a part of # nss test run. # To create certs use the following command: # sh cert_iopr.sh cert_gen <dir> <cert name> [cert req] # Where: # dir - directory where to place created files # cert name - name of created server cert(FQDN) # cert req - cert request to be used for cert generation. # repAndExec() { echo if [ "$1" = "certutil" -a "$2" = "-R" -o "$2" = "-S" ]; then shift echo certutil -s "$CU_SUBJECT" $@ certutil -s "$CU_SUBJECT" $@ RET=$? else echo $@ $@ RET=$? fi return $RET } setExtData() { extData=$1 fldNum=0 extData=`echo $extData | sed 's/,/ /g'` for extDT in $extData; do if [ $fldNum -eq 0 ]; then eval extType=$extDT fldNum=1 continue fi eval data${fldNum}=$extDT fldNum=`expr $fldNum + 1` done } signCert() { dir=$1 crtDir=$2 crtName=$3 crtSN=$4 req=$5 cuAddParam=$6 extList=$7 if [ -z "$certSigner" ]; then certSigner=TestCA fi extCmdLine="" extCmdFile=$dir/extInFile; rm -f $extCmdFile touch $extCmdFile extList=`echo $extList | sed 's/;/ /g'` for ext in $extList; do setExtData $ext [ -z "$extType" ] && echo "incorrect extention format" && return 1 case $extType in ocspDR) extCmdLine="$extCmdLine -6" cat <<EOF >> $extCmdFile 5 9 y EOF break exit 1 ;; AIA) extCmdLine="$extCmdLine -9" cat <<EOF >> $extCmdFile 2 7 $data1 0 n n EOF break ;; *) echo "Unsupported extension type: $extType" break ;; esac done echo "cmdLine: $extCmdLine" echo "cmdFile: "`cat $extCmdFile` repAndExec \ certutil $cuAddParam -C -c $certSigner -m $crtSN -v 599 -d "${dir}" \ -i $req -o "$crtDir/${crtName}.crt" -f "${PW_FILE}" $extCmdLine <$extCmdFile 2>&1 return $RET } createSignedCert() { dir=$1 certDir=$2 certName=$3 certSN=$4 certSubj=$5 keyType=$6 extList=$7 echo Creating cert $certName-$keyType with SN=$certSN CU_SUBJECT="CN=$certName, E=${certName}-${keyType}@bogus.com, O=BOGUS NSS, L=Mountain View, ST=California, C=US" repAndExec \ certutil -R -d $dir -f "${PW_FILE}" -z "${NOISE_FILE}" \ -k $keyType -o $dir/req 2>&1 [ "$RET" -ne 0 ] && return $RET signCert $dir $dir $certName-$keyType $certSN $dir/req "" $extList ret=$? [ "$ret" -ne 0 ] && return $ret rm -f $dir/req repAndExec \ certutil -A -n ${certName}-$keyType -t "u,u,u" -d "${dir}" -f "${PW_FILE}" \ -i "$dir/${certName}-$keyType.crt" 2>&1 [ "$RET" -ne 0 ] && return $RET cp "$dir/${certName}-$keyType.crt" $certDir repAndExec \ pk12util -d $dir -o $certDir/$certName-$keyType.p12 -n ${certName}-$keyType \ -k ${PW_FILE} -W iopr [ "$RET" -ne 0 ] && return $RET return 0 } generateAndExportSSLCerts() { dir=$1 certDir=$2 serverName=$3 servCertReq=$4 if [ "$servCertReq" -a -f $servCertReq ]; then grep REQUEST $servCertReq >/dev/null 2>&1 signCert $dir $certDir ${serverName}_ext 501 $servCertReq `test $? -eq 0 && echo -a` ret=$? [ "$ret" -ne 0 ] && return $ret fi certName=$serverName createSignedCert $dir $certDir $certName 500 "$certSubj" rsa ret=$? [ "$ret" -ne 0 ] && return $ret createSignedCert $dir $certDir $certName 501 "$certSubj" dsa ret=$? [ "$ret" -ne 0 ] && return $ret certName=TestUser510 createSignedCert $dir $certDir $certName 510 "$certSubj" rsa ret=$? [ "$ret" -ne 0 ] && return $ret certName=TestUser511 createSignedCert $dir $certDir $certName 511 "$certSubj" dsa ret=$? [ "$ret" -ne 0 ] && return $ret certName=TestUser512 createSignedCert $dir $certDir $certName 512 "$certSubj" rsa ret=$? [ "$ret" -ne 0 ] && return $ret certName=TestUser513 createSignedCert $dir $certDir $certName 513 "$certSubj" dsa ret=$? [ "$ret" -ne 0 ] && return $ret } generateAndExportOCSPCerts() { dir=$1 certDir=$2 certName=ocspTrustedResponder createSignedCert $dir $certDir $certName 525 "$certSubj" rsa ret=$? [ "$ret" -ne 0 ] && return $ret certName=ocspDesignatedResponder createSignedCert $dir $certDir $certName 526 "$certSubj" rsa ocspDR ret=$? [ "$ret" -ne 0 ] && return $ret certName=ocspTRTestUser514 createSignedCert $dir $certDir $certName 514 "$certSubj" rsa ret=$? [ "$ret" -ne 0 ] && return $ret certName=ocspTRTestUser516 createSignedCert $dir $certDir $certName 516 "$certSubj" rsa ret=$? [ "$ret" -ne 0 ] && return $ret certName=ocspRCATestUser518 createSignedCert $dir $certDir $certName 518 "$certSubj" rsa \ AIA,http://dochinups.red.iplanet.com:2561 ret=$? [ "$ret" -ne 0 ] && return $ret certName=ocspRCATestUser520 createSignedCert $dir $certDir $certName 520 "$certSubj" rsa \ AIA,http://dochinups.red.iplanet.com:2561 ret=$? [ "$ret" -ne 0 ] && return $ret certName=ocspDRTestUser522 createSignedCert $dir $certDir $certName 522 "$certSubj" rsa \ AIA,http://dochinups.red.iplanet.com:2562 ret=$? [ "$ret" -ne 0 ] && return $ret certName=ocspDRTestUser524 createSignedCert $dir $certDir $certName 524 "$certSubj" rsa \ AIA,http://dochinups.red.iplanet.com:2562 ret=$? [ "$ret" -ne 0 ] && return $ret generateAndExportCACert $dir "" TestCA-unknown [ $? -ne 0 ] && return $ret certSigner=TestCA-unknown certName=ocspTRUnkownIssuerCert createSignedCert $dir $certDir $certName 531 "$certSubj" rsa ret=$? [ "$ret" -ne 0 ] && return $ret certName=ocspRCAUnkownIssuerCert createSignedCert $dir $certDir $certName 532 "$certSubj" rsa \ AIA,http://dochinups.red.iplanet.com:2561 ret=$? [ "$ret" -ne 0 ] && return $ret certName=ocspDRUnkownIssuerCert createSignedCert $dir $certDir $certName 533 "$certSubj" rsa \ AIA,http://dochinups.red.iplanet.com:2562 ret=$? [ "$ret" -ne 0 ] && return $ret certSigner="" return 0 } generateAndExportCACert() { dir=$1 certDirL=$2 caName=$3 certName=TestCA [ "$caName" ] && certName=$caName CU_SUBJECT="CN=NSS IOPR Test CA $$, E=${certName}@bogus.com, O=BOGUS NSS, L=Mountain View, ST=California, C=US" repAndExec \ certutil -S -n $certName -t "CTu,CTu,CTu" -v 600 -x -d ${dir} -1 -2 \ -f ${PW_FILE} -z ${NOISE_FILE} -m `expr $$ + 2238` >&1 <<EOF 5 6 9 n y -1 n EOF if [ "$certDirL" ]; then repAndExec \ certutil -L -n $certName -r -d ${dir} -o $certDirL/$certName.crt [ "$RET" -ne 0 ] && return $RET repAndExec \ pk12util -d $dir -o $certDirL/$certName.p12 -n $certName -k ${PW_FILE} -W iopr [ "$RET" -ne 0 ] && return $RET fi } generateCerts() { certDir=$1 serverName=$2 reuseCACert=$3 servCertReq=$4 [ -z "$certDir" ] && echo "Cert directory should not be empty" && exit 1 [ -z "$serverName" ] && echo "Server name should not be empty" && exit 1 mkdir -p $certDir [ $? -ne 0 ] && echo "Can not create dir: $certDir" && exit 1 dir=/tmp/db.$$ if [ -z "$reuseCACert" ]; then if [ -d "$dir" ]; then rm -f $dir fi PW_FILE=$dir/nss.pwd NOISE_FILE=$dir/nss.noise mkdir -p $dir [ $? -ne 0 ] && echo "Can not create dir: $dir" && exit 1 echo nss > $PW_FILE date >> ${NOISE_FILE} 2>&1 repAndExec \ certutil -d $dir -N -f $PW_FILE [ "$RET" -ne 0 ] && return $RET generateAndExportCACert $dir $certDir [ "$RET" -ne 0 ] && return $RET else dir=$reuseCACert PW_FILE=$dir/nss.pwd NOISE_FILE=$dir/nss.noise hasKey=`repAndExec certutil -d $dir -L | grep TestCA | grep CTu` [ -z "$hasKey" ] && echo "reuse CA cert has not priv key" && \ return $RET; fi generateAndExportSSLCerts $dir $certDir $serverName $servCertReq [ "$RET" -ne 0 ] && return $RET generateAndExportOCSPCerts $dir $certDir [ "$RET" -ne 0 ] && return $RET crlUpdate=`date +%Y%m%d%H%M%SZ` crlNextUpdate=`echo $crlUpdate | sed 's/20/21/'` repAndExec \ crlutil -d $dir -G -n "TestCA" -f ${PW_FILE} -o $certDir/TestCA.crl <<EOF_CRLINI update=$crlUpdate nextupdate=$crlNextUpdate addcert 509-511 $crlUpdate addcert 516 $crlUpdate addcert 520 $crlUpdate addcert 524 $crlUpdate EOF_CRLINI [ "$RET" -ne 0 ] && return $RET rm -rf $dir return 0 } if [ -z "$1" -o -z "$2" ]; then echo "$0 <dest dir> <server cert name> [reuse CA cert] [cert req]" exit 1 fi generateCerts $1 $2 "$3" $4 exit $?
bunnyblue/nss-3.12.6-android
mozilla/security/nss/tests/iopr/server_scr/cert_gen.sh
Shell
mpl-2.0
11,202
#!/bin/bash # The purpose of this wrapper script is to set some environment # variables particular to our setup on moby, prior to launching the # FastCGI process. export LD_LIBRARY_PATH=/tdr/bin/lib:/usr/local/lib:/usr/local/lib/mysql # Here's the command that actually launches the FastCGI server. /tdr/bin/esd-dev/script/esd_fastcgi.pl -processes 3
TuftsUniversity/ESD
script/esd_fastcgi_wrapper.sh
Shell
agpl-3.0
354
#!/bin/bash set -e source /pd_build/buildconfig # Install dependencies & firefox. run minimal_apt_get_install chrpath libssl-dev libxft-dev libfreetype6-dev libfreetype6 libfontconfig1-dev libfontconfig1 tesseract-ocr wget openjdk-8-jre-headless xvfb libxi6 libgconf-2-4 firefox # Install ChromeDriver. run wget -N https://github.com/mozilla/geckodriver/releases/download/v0.19.1/geckodriver-v0.19.1-linux64.tar.gz -P /tmp run cd /tmp run tar -xvzf /tmp/geckodriver-v0.19.1-linux64.tar.gz run rm /tmp/geckodriver-v0.19.1-linux64.tar.gz run sudo mv -f /tmp/geckodriver /usr/local/bin/geckodriver run sudo chown root:root /usr/local/bin/geckodriver run sudo chmod 0755 /usr/local/bin/geckodriver
trabacus-softapps/docker-openerpbase-kings
utilities.sh
Shell
agpl-3.0
696
#!/bin/bash ################################################################################ # Build Latest, only runs build without updating software # For Google cloud, Stackdriver/logging should have Write, # Google Storage should have Full # All other APIs None, # # # Copyright (C) 2017 The Board of Trustees of the Leland Stanford Junior # University. # Copyright (C) 2016-2017 Vanessa Sochat. # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public # License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. # ################################################################################ echo "Start Time: $(date)." > /tmp/.shub-log 2>&1 timeout -s KILL 2h sudo python3 -c "from singularity.build.google import run_build; run_build()" >> /tmp/.shub-log 2>&1 ret=$? echo "Return value of ${ret}." >> /tmp/.shub-log 2>&1 if [ $ret -eq 137 ] then echo "Killed: $(date)." >> /tmp/.shub-log 2>&1 else echo "End Time: $(date)." >> /tmp/.shub-log 2>&1 fi # Finish by sending log sudo python3 -c "from singularity.build.google import finish_build; finish_build()"
singularityware/singularity-python
singularity/build/scripts/singularity-build-latest.sh
Shell
agpl-3.0
1,659
#!/bin/bash # Get Elastic 5 in a container (in userspace with podman) podman pull docker.elastic.co/elasticsearch/elasticsearch:5.6.16 podman run --name es_five -p 9205:9200 -e "discovery.type=single-node" -e "xpack.security.enabled=false" -e "ES_JAVA_OPTS=-Xmx1g -Xms1g" elast podman start -a es_five # Get Elastic 7 in a container (in userspace with podman) podman run --name es_seven -p 9200:9200 -e "discovery.type=single-node" -e "ES_JAVA_OPTS=-Xmx1g -Xms1g" elasticsearch:7.7.0 podman start -a es_seven
sinnwerkstatt/landmatrix
tmp_gnd/gnd_elastic.sh
Shell
agpl-3.0
514
#!/bin/sh # show up script version version () { printf "\n%s\n" "TSP Custom killall script[sh] - V1.0" } # Waiting for time out pids=`ps -edf | egrep -v "grep|killall" | grep $1 | awk '{ print $2 }'` if [ -n "$pids" ]; then kill $pids sleep 1 fi
deweerdt/TSP
src/scripts/custom_killall.sh
Shell
lgpl-2.1
269
#!/bin/sh export JAVA_HOME=/usr/lib/jvm/jre-1.7.0 export HADOOP_PREFIX="/home/hadoop/hadoop" export HADOOP_HOME=$HADOOP_PREFIX export HADOOP_COMMON_HOME=$HADOOP_PREFIX export HADOOP_CONF_DIR=$HADOOP_PREFIX/etc/hadoop export HADOOP_HDFS_HOME=$HADOOP_PREFIX export HADOOP_MAPRED_HOME=$HADOOP_PREFIX export HADOOP_YARN_HOME=$HADOOP_PREFIX
deltaforge/nebu-app-hadoop
hadoop/etc/hadoop/exports.sh
Shell
lgpl-3.0
338
echo echo Enumerating files... echo GOOD=true for x in `find -name '*.java'` do if echo $x | grep -iE '(SampleIgneousRobot|cobertura|TemplateIgneousRobot|edu.wpi.first.wpilib.networktables.java)' >/dev/null then true else if head -n 18 $x | grep -iE '(This file is part of the CCRE, the Common Chicken Runtime Engine[.]|Copyright \(c\) FIRST)' >/dev/null then true else echo $x BAD GOOD=false fi fi done echo if $GOOD then echo Done enumerating. All files pass inspection. echo exit 0 else echo Done enumerating. Not ready to commit. You forgot some license headers! echo exit 1 fi
Ja-ake/Common-Chicken-Runtime-Engine
check-headers.sh
Shell
lgpl-3.0
611
export PATH=/Users/admin/_DEV/3rdParties/apache-ant/bin:/Users/admin/_DEV/3rdParties/qt5/5.4/android_armv7/bin/:$PATH mkdir -p android_dist/libs/armeabi-v7a/ cp /Users/admin/_DEV/3rdParties/qt5/5.4/android_armv7/lib/*.so android_dist/libs/armeabi-v7a/ cp /Users/admin/_DEV/3rdParties/qt5/5.4/android_armv7/plugins/sqldrivers/libqsqlite.so android_dist/libs/armeabi-v7a/libplugins_sqldrivers_libqsqlite.so cp /Users/admin/_DEV/3rdParties/qt5/5.4//android_armv7/plugins/imageformats/libqgif.so android_dist/libs/armeabi-v7a/libplugins_imageformats_libqgif.so cp /Users/admin/_DEV/3rdParties/qt5/5.4//android_armv7/plugins/imageformats/libqico.so android_dist/libs/armeabi-v7a/libplugins_imageformats_libqico.so cp /Users/admin/_DEV/3rdParties/qt5/5.4//android_armv7/plugins/imageformats/libqjpeg.so android_dist/libs/armeabi-v7a/libplugins_imageformats_libqjpeg.so cp /Users/admin/_DEV/3rdParties/qt5/5.4//android_armv7/plugins/imageformats/libqmng.so android_dist/libs/armeabi-v7a/libplugins_imageformats_libqmng.so cp /Users/admin/_DEV/3rdParties/qt5/5.4//android_armv7/plugins/imageformats/libqtga.so android_dist/libs/armeabi-v7a/libplugins_imageformats_libqtga.so cp /Users/admin/_DEV/3rdParties/qt5/5.4//android_armv7/plugins/imageformats/libqtiff.so android_dist/libs/armeabi-v7a/libplugins_imageformats_libqtiff.so cp /Users/admin/_DEV/3rdParties/qt5/5.4//android_armv7/plugins/imageformats/libqwbmp.so android_dist/libs/armeabi-v7a/libplugins_imageformats_libqwbmp.so cp /Users/admin/_DEV/3rdParties/qt5/5.4//android_armv7/plugins/platforms/android/libqtforandroid.so android_dist/libs/armeabi-v7a/libplugins_platforms_android_libqtforandroid.so cp /Users/admin/_DEV/3rdParties/qt5/5.4//android_armv7/plugins/platforms/libqeglfs.so android_dist/libs/armeabi-v7a/libplugins_platforms_libqeglfs.so cp /Users/admin/_DEV/3rdParties/qt5/5.4//android_armv7/plugins/platforms/libqminimal.so android_dist/libs/armeabi-v7a/libplugins_platforms_libqminimal.so cp /Users/admin/_DEV/3rdParties/qt5/5.4//android_armv7/plugins/platforms/libqminimalegl.so android_dist/libs/armeabi-v7a/libplugins_platforms_libqminimalegl.so cp /Users/admin/_DEV/3rdParties/qt5/5.4//android_armv7/plugins/platforms/libqoffscreen.so android_dist/libs/armeabi-v7a/libplugins_platforms_libqoffscreen.so cp /Users/admin/_DEV/3rdParties/qt5/5.4//android_armv7/plugins/audio/libqtaudio_opensles.so android_dist/libs/armeabi-v7a/libplugins_audio_libqtaudio_opensles.so cp /Users/admin/_DEV/3rdParties/qt5/5.4//android_armv7/plugins/playlistformats/libqtmultimedia_m3u.so android_dist/libs/armeabi-v7a/libplugins_playlistformats_libqtmultimedia_m3u.so cp /Users/admin/_DEV/3rdParties/qt5/5.4//android_armv7/plugins/mediaservice/libqtmedia_android.so android_dist/libs/armeabi-v7a/libplugins_mediaservice_libqtmedia_android.so cp /Users/admin/_DEV/3rdParties/qt5/5.4//android_armv7/plugins/video/videonode/libqtsgvideonode_android.so android_dist/libs/armeabi-v7a/libplugins_video_videonode_libqtsgvideonode_android.so cp /Users/admin/_DEV/3rdParties/qt5/5.4//android_armv7/plugins/generic/libqevdevkeyboardplugin.so android_dist/libs/armeabi-v7a/libplugins_generic_libqevdevkeyboardplugin.so cp /Users/admin/_DEV/3rdParties/qt5/5.4//android_armv7/plugins/generic/libqevdevmouseplugin.so android_dist/libs/armeabi-v7a/libplugins_generic_libqevdevmouseplugin.so cp /Users/admin/_DEV/3rdParties/qt5/5.4//android_armv7/plugins/generic/libqevdevtabletplugin.so android_dist/libs/armeabi-v7a/libplugins_generic_libqevdevtabletplugin.so cp /Users/admin/_DEV/3rdParties/qt5/5.4//android_armv7/plugins/generic/libqevdevtouchplugin.so android_dist/libs/armeabi-v7a/libplugins_generic_libqevdevtouchplugin.so cp /Users/admin/_DEV/3rdParties/fmodstudioapi10510android/api/lowlevel/lib/armeabi-v7a/libfmod.so android_dist/libs/armeabi-v7a/libfmod.so mv dist/mbp-gbl/gcc-4.8/release/bin/mvp_player_qt dist/mbp-gbl/gcc-4.8/release/bin/libmvp_player_qt.so cp dist/mbp-gbl/gcc-4.8/release/bin/libmvp_player_qt.so android_dist/libs/armeabi-v7a/libmvp_player_qt.so cp dist/mbp-gbl/gcc-4.8/release/bin/plugins/*.so android_dist/libs/armeabi-v7a/ rm -rf android_dist/gen android_dist/bin androiddeployqt --input ./android-mvpPlayerQt.so-deployment-settings.json --output android_dist --deployment bundled
edubois/mvp-player
android/build_mvpPlayerQt_android.sh
Shell
lgpl-3.0
4,254