Last active
April 25, 2024 05:39
-
-
Save western/6110a3e07897183c2d5d9bff38bfdaa7 to your computer and use it in GitHub Desktop.
Revisions
-
western revised this gist
Apr 25, 2024 . 1 changed file with 8 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ CPUC=`cat /proc/cpuinfo | grep processor | wc -l` CPUC=$((CPUC-1)) PARENTF=`pwd` BUILDF="$PARENTF/build" NGINXV='nginx-1.26.0' IS_LOCAL=1 IS_PAUSED=0 IS_GET_ONLY=1 @@ -30,8 +30,8 @@ function main { "dotinit") pushd /root/ wget https://raw.githubusercontent.com/western/nginx-builder/dev/.vimrc wget https://raw.githubusercontent.com/western/nginx-builder/dev/.alias echo "" >> .bashrc echo "source .alias" >> .bashrc source .alias @@ -40,6 +40,7 @@ function main { ;; "root_prepare") root_prepare break ;; "build") @@ -61,12 +62,15 @@ function main { #make_nginx_service prepare_for_archive break ;; "nginx_tmpfile") make_nginx_tmpfile break ;; "nginx_service") make_nginx_service break ;; "quit") break @@ -338,6 +342,7 @@ function make_configure { --with-file-aio \ --with-http_ssl_module $WITH_OPENSSL \ --with-http_v2_module \ --with-http_v3_module \ --with-http_realip_module \ --with-http_addition_module \ --with-http_image_filter_module \ -
western revised this gist
Mar 30, 2024 . 1 changed file with 56 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,27 +20,67 @@ function main { warn "IS_LOCAL $IS_LOCAL" warn "IS_PAUSED $IS_PAUSED" warn "IS_GET_ONLY $IS_GET_ONLY" PS3='Please enter your choice: ' options=("dotinit" "root_prepare" "build" "nginx_tmpfile" "nginx_service" "quit") select opt in "${options[@]}" do case $opt in "dotinit") pushd /root/ wget https://raw.githubusercontent.com/western/vpnset/dev/.vimrc wget https://raw.githubusercontent.com/western/vpnset/dev/.alias echo "" >> .bashrc echo "source .alias" >> .bashrc source .alias popd ;; "root_prepare") root_prepare ;; "build") rm versions if [ $IS_LOCAL == 1 ]; then mkdir -p $BUILDF/{tmp,proxy,fastcgi,uwsgi,scgi} fi #root_prepare ngx_module openssl_get ngx_src make_configure #make_nginx_tmpfile #make_nginx_service prepare_for_archive ;; "nginx_tmpfile") make_nginx_tmpfile ;; "nginx_service") make_nginx_service ;; "quit") break ;; *) echo "invalid option $REPLY";; esac done } # ------------------------------------------------------------------------------ -
western revised this gist
Mar 29, 2024 . 1 changed file with 5 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,6 +23,10 @@ function main { rm versions if [ $IS_LOCAL == 1 ]; then mkdir -p $BUILDF/{tmp,proxy,fastcgi,uwsgi,scgi} fi #root_prepare @@ -235,12 +239,9 @@ function make_configure { local FASTCGI_TEMP_PATH="" local UWSGI_TEMP_PATH="" local SCGI_TEMP_PATH="" if [ $IS_LOCAL == 1 ]; then PREFIX="$BUILDF/" CONF_PATH="$PREFIX/conf/nginx.conf" PID_PATH="$PREFIX/logs/nginx124.pid" @@ -251,9 +252,6 @@ function make_configure { FASTCGI_TEMP_PATH="$PREFIX/fastcgi/" UWSGI_TEMP_PATH="$PREFIX/uwsgi/" SCGI_TEMP_PATH="$PREFIX/scgi/" else PREFIX="/usr/local/$NGINXV" CONF_PATH="/etc/$NGINXV/nginx.conf" @@ -265,9 +263,6 @@ function make_configure { FASTCGI_TEMP_PATH="/var/lib/nginx/fastcgi/" UWSGI_TEMP_PATH="/var/lib/nginx/uwsgi/" SCGI_TEMP_PATH="/var/lib/nginx/scgi/" fi WITH_OPENSSL="" -
western revised this gist
Mar 29, 2024 . 1 changed file with 1 addition and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -346,10 +346,6 @@ function make_nginx_service { exit 1 fi @@ -363,7 +359,7 @@ [email protected] plymouth-quit.service xdm.service [Service] Type=forking PIDFile=/var/run/nginx/nginx124.pid ExecStartPre=/usr/local/$NGINXV/sbin/nginx -t ExecStart=/usr/local/$NGINXV/sbin/nginx ExecReload=/bin/kill -s HUP \$MAINPID -
western revised this gist
Mar 29, 2024 . 1 changed file with 4 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -243,7 +243,7 @@ function make_configure { mkdir -p $BUILDF/{tmp,proxy,fastcgi,uwsgi,scgi} PREFIX="$BUILDF/" CONF_PATH="$PREFIX/conf/nginx.conf" PID_PATH="$PREFIX/logs/nginx124.pid" ERROR_LOG="$PREFIX/logs/error.log" HTTP_LOG="$PREFIX/logs/access.log" CLIENT_BODY_TEMP="$PREFIX/tmp/" @@ -257,7 +257,7 @@ function make_configure { else PREFIX="/usr/local/$NGINXV" CONF_PATH="/etc/$NGINXV/nginx.conf" PID_PATH="/var/run/nginx/nginx124.pid" ERROR_LOG="/var/log/nginx/error.log" HTTP_LOG="/var/log/nginx/access.log" CLIENT_BODY_TEMP="/var/lib/nginx/tmp/" @@ -347,10 +347,9 @@ function make_nginx_service { fi local PREFIX="" local PID_PATH="/var/run/nginx/nginx124.pid" -
western revised this gist
Mar 29, 2024 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -347,10 +347,10 @@ function make_nginx_service { fi local PREFIX="" local PID_PATH="/var/run/nginx/nginx.pid" #PREFIX="/usr/local/$NGINXV" #PID_PATH="$PREFIX/logs/nginx.pid" -
western revised this gist
Mar 29, 2024 . 1 changed file with 2 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -349,13 +349,8 @@ function make_nginx_service { local PREFIX="" local PID_PATH="" PREFIX="/usr/local/$NGINXV" PID_PATH="$PREFIX/logs/nginx.pid" -
western revised this gist
Mar 29, 2024 . 1 changed file with 15 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,7 +25,6 @@ function main { #root_prepare ngx_module @@ -347,6 +346,19 @@ function make_nginx_service { exit 1 fi local PREFIX="" local PID_PATH="" if [ $IS_LOCAL == 1 ]; then PREFIX="$BUILDF/" PID_PATH="$PREFIX/logs/nginx.pid" else PREFIX="/usr/local/$NGINXV" PID_PATH="/var/run/nginx/nginx.pid" fi cat << L11HEREDOC > /etc/systemd/system/nginx124.service [Unit] @@ -357,12 +369,12 @@ [email protected] plymouth-quit.service xdm.service [Service] Type=forking PIDFile=$PID_PATH ExecStartPre=/usr/local/$NGINXV/sbin/nginx -t ExecStart=/usr/local/$NGINXV/sbin/nginx ExecReload=/bin/kill -s HUP \$MAINPID ExecStop=/bin/kill -s QUIT \$MAINPID #PrivateTmp=true [Install] WantedBy=multi-user.target runlevel3.target -
western revised this gist
Mar 29, 2024 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -370,8 +370,8 @@ WantedBy=multi-user.target runlevel3.target L11HEREDOC systemctl daemon-reload #systemctl status nginx124.service #systemctl enable nginx124.service } # ------------------------------------------------------------------------------ -
western revised this gist
Mar 29, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -347,7 +347,7 @@ function make_nginx_service { exit 1 fi cat << L11HEREDOC > /etc/systemd/system/nginx124.service [Unit] Description=$NGINXV -
western revised this gist
Mar 29, 2024 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/bin/bash # save and run # . nginx_builder2 CPUC=`cat /proc/cpuinfo | grep processor | wc -l` CPUC=$((CPUC-1)) @@ -35,6 +35,7 @@ function main { #make_nginx_tmpfile #make_nginx_service prepare_for_archive } -
western created this gist
Mar 29, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,551 @@ #!/bin/bash # save and run # . nginx_builder CPUC=`cat /proc/cpuinfo | grep processor | wc -l` CPUC=$((CPUC-1)) PARENTF=`pwd` BUILDF="$PARENTF/build" NGINXV='nginx-1.24.0' IS_LOCAL=1 IS_PAUSED=0 IS_GET_ONLY=1 function main { notice "builder for $NGINXV" notice "from parent folder $PARENTF" warn "IS_LOCAL $IS_LOCAL" warn "IS_PAUSED $IS_PAUSED" warn "IS_GET_ONLY $IS_GET_ONLY" rm versions #root_prepare ngx_module openssl_get ngx_src make_configure #make_nginx_tmpfile prepare_for_archive } # ------------------------------------------------------------------------------ function prepare_for_archive { notice "prepare_for_archive" pushd $PARENTF find . -type d -name '.git' -not -path "./.git" | xargs rm -rf find . -type d -name '.git' -not -path "./.git" popd } # ------------------------------------------------------------------------------ function root_prepare { notice "root_prepare" if ! whoami | grep -q root; then err 'root required. exit.' fi if ! grep -q "nginx" /etc/passwd; then groupadd nginx useradd -M -g nginx nginx fi if cat /etc/*release* | grep -q 'openSUSE Leap 15.5'; then warn 'openSUSE Leap 15.5 detected.' zypper in -t pattern -y devel_C_C++ devel_basis devel_perl console zypper in -y pcre-devel libopenssl-devel gd-devel libGeoIP-devel libatomic_ops-devel dialog zypper in -y libxslt-devel libxml2-devel fi if cat /etc/*release* | grep -q 'VERSION="11 (bullseye)"'; then warn 'Debian 11 detected.' apt-get install -y vim mc less mlocate git cmake build-essential curl gnupg aptitude apt-get install -y libpq-dev libpcre3-dev zlib1g-dev libgd-dev libgeoip-dev libatomic-ops-dev libxslt-dev fi if cat /etc/*release* | grep -q 'VERSION="12 (bookworm)"'; then warn 'Debian 12 detected.' apt-get update && apt-get upgrade -u apt-get install -y vim mc less lsof mlocate git curl wget aptitude apt-get install -y libpq-dev libpcre3-dev zlib1g-dev libgd-dev libgeoip-dev libatomic-ops-dev libxslt-dev fi if cat /etc/*release* | grep -q 'CentOS Linux release 8'; then warn 'CentOS 8 detected.' dnf groupinstall "Development Tools" -y dnf config-manager --set-enabled PowerTools dnf install python2 -y dnf install pcre-devel -y dnf install zlib-devel -y dnf install gd-devel -y dnf install openssl-devel -y dnf install epel-release -y dnf install GeoIP-devel -y dnf install libatomic_ops-devel -y ln -s /usr/bin/python2 /usr/bin/python fi if [ $IS_LOCAL == 0 ]; then rm -rf /usr/local/$NGINXV rm -rf /var/lib/nginx/ mkdir -p /var/lib/nginx/{fastcgi,proxy,scgi,tmp,uwsgi,cache} chown -R nginx:nginx /var/lib/nginx/ mkdir -p /var/run/nginx chown -R nginx:nginx /var/run/nginx mkdir /var/log/nginx/ fi } # ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------ function ngx_module { notice "ngx_module" mkdir ngx_module ; pushd ngx_module #get_github 'openresty' 'memc-nginx-module.git' #get_github 'openresty' 'lua-nginx-module.git' 'v0.10.17' get_github 'simplresty' 'ngx_devel_kit.git' #get_github 'openresty' 'redis2-nginx-module.git' get_github 'openresty' 'echo-nginx-module.git' get_github 'calio' 'form-input-nginx-module.git' get_github 'openresty' 'set-misc-nginx-module.git' get_github 'Austinb' 'nginx-upload-module.git' get_github 'FRiCKLE' 'ngx_cache_purge.git' get_github 'openresty' 'headers-more-nginx-module.git' #get_github 'nbs-system' 'naxsi.git' #get_github 'SpiderLabs' 'ModSecurity-nginx.git' #get_github 'openresty' 'replace-filter-nginx-module.git' #get_github 'openresty' 'rds-json-nginx-module.git' #get_github 'openresty' 'rds-csv-nginx-module.git' #get_github 'openresty' 'drizzle-nginx-module.git' #get_github 'openresty' 'ngx_postgres.git' get_github 'nginx' 'njs.git' #get_github 'openresty' 'stream-lua-nginx-module.git' 'v0.0.8' #get_github 'openresty' 'xss-nginx-module.git' #get_github 'arut' 'nginx-rtmp-module.git' #get_github 'arut' 'nginx-ts-module.git' popd } # ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------ function openssl_get { notice "openssl_get" mkdir etc_src ; pushd etc_src get_arch 'https://github.com/openssl/openssl/releases/download/openssl-3.2.1/openssl-3.2.1.tar.gz' 'openssl-3.2.1.tar.gz' 'openssl-3.2.1' popd } # ------------------------------------------------------------------------------ function openssl_generate_localhost { notice "openssl_generate_localhost" if [ ! -f "/etc/$NGINXV/ssl/localhost.crt" ]; then pushd "/etc/$NGINXV/" mkdir ssl ; cd ssl openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout localhost.key -out localhost.crt openssl dhparam -out dhparam.pem 4096 cd .. popd fi } # ------------------------------------------------------------------------------ function ngx_src { notice "ngx_src" mkdir ngx_src ; pushd ngx_src get_arch "https://nginx.org/download/$NGINXV.tar.gz" "$NGINXV.tar.gz" $NGINXV popd } # ------------------------------------------------------------------------------ function make_configure { notice "make_configure" local PREFIX="" local CONF_PATH="" local PID_PATH="" local ERROR_LOG="" local HTTP_LOG="" local CLIENT_BODY_TEMP="" local PROXY_TEMP_PATH="" local FASTCGI_TEMP_PATH="" local UWSGI_TEMP_PATH="" local SCGI_TEMP_PATH="" local LUAJIT2_BUILD_LIB="" local LUAJIT2_SRC="" local LUA_SSL_NGINX_MODULE="" if [ $IS_LOCAL == 1 ]; then mkdir -p $BUILDF/{tmp,proxy,fastcgi,uwsgi,scgi} PREFIX="$BUILDF/" CONF_PATH="$PREFIX/conf/nginx.conf" PID_PATH="$PREFIX/logs/nginx.pid" ERROR_LOG="$PREFIX/logs/error.log" HTTP_LOG="$PREFIX/logs/access.log" CLIENT_BODY_TEMP="$PREFIX/tmp/" PROXY_TEMP_PATH="$PREFIX/proxy/" FASTCGI_TEMP_PATH="$PREFIX/fastcgi/" UWSGI_TEMP_PATH="$PREFIX/uwsgi/" SCGI_TEMP_PATH="$PREFIX/scgi/" #LUAJIT2_BUILD_LIB="$PARENTF/lua_src/luajit2.git/build/lib" #LUAJIT2_SRC="$PARENTF/lua_src/luajit2.git/src" #LUA_SSL_NGINX_MODULE="$PARENTF/lua_src/lua-ssl-nginx-module.git/" else PREFIX="/usr/local/$NGINXV" CONF_PATH="/etc/$NGINXV/nginx.conf" PID_PATH="/var/run/nginx/nginx.pid" ERROR_LOG="/var/log/nginx/error.log" HTTP_LOG="/var/log/nginx/access.log" CLIENT_BODY_TEMP="/var/lib/nginx/tmp/" PROXY_TEMP_PATH="/var/lib/nginx/proxy/" FASTCGI_TEMP_PATH="/var/lib/nginx/fastcgi/" UWSGI_TEMP_PATH="/var/lib/nginx/uwsgi/" SCGI_TEMP_PATH="/var/lib/nginx/scgi/" #LUAJIT2_BUILD_LIB="/opt/lua_src/luajit2.git/build/lib" #LUAJIT2_SRC="/opt/lua_src/luajit2.git/src" #LUA_SSL_NGINX_MODULE="/opt/lua_src/lua-ssl-nginx-module.git/" fi WITH_OPENSSL="" if [ -d $PARENTF/etc_src/openssl-3.2.1 ]; then WITH_OPENSSL="--with-openssl=$PARENTF/etc_src/openssl-3.2.1 --with-openssl-opt='enable-tls1_3'" fi pushd ngx_src/$NGINXV /bin/bash configure \ --with-ld-opt="-Wl,-rpath,$LUAJIT2_BUILD_LIB" \ --prefix=$PREFIX \ --conf-path=$CONF_PATH \ --pid-path=$PID_PATH \ --error-log-path=$ERROR_LOG \ --http-log-path=$HTTP_LOG \ --http-client-body-temp-path=$CLIENT_BODY_TEMP \ --http-proxy-temp-path=$PROXY_TEMP_PATH \ --http-fastcgi-temp-path=$FASTCGI_TEMP_PATH \ --http-uwsgi-temp-path=$UWSGI_TEMP_PATH \ --http-scgi-temp-path=$SCGI_TEMP_PATH \ --user=nginx \ --group=nginx \ --with-debug \ --with-stream \ --with-stream_ssl_module \ --with-stream_realip_module \ --with-stream_geoip_module \ --with-stream_ssl_preread_module \ --with-threads \ --with-file-aio \ --with-http_ssl_module $WITH_OPENSSL \ --with-http_v2_module \ --with-http_realip_module \ --with-http_addition_module \ --with-http_image_filter_module \ --with-http_geoip_module \ --with-http_sub_module \ --with-http_mp4_module \ --with-http_gunzip_module \ --with-http_gzip_static_module \ --with-http_random_index_module \ --with-http_secure_link_module \ --with-http_stub_status_module \ --with-pcre \ --with-pcre-jit \ --with-libatomic \ --add-module=../../ngx_module/ngx_devel_kit.git/ \ --add-module=../../ngx_module/echo-nginx-module.git/ \ --add-module=../../ngx_module/form-input-nginx-module.git/ \ --add-module=../../ngx_module/set-misc-nginx-module.git/ \ --add-module=../../ngx_module/nginx-upload-module.git/ \ --add-module=../../ngx_module/ngx_cache_purge.git/ \ --add-module=../../ngx_module/headers-more-nginx-module.git/ \ --add-module=../../ngx_module/njs.git/nginx/ \ make install -j4 popd } # ------------------------------------------------------------------------------ function make_nginx_service { notice "make_nginx_service" if ! whoami | grep -q root; then echo 'root required. exit.' exit 1 fi cat << L11HEREDOC > /etc/systemd/system/nginx.service [Unit] Description=$NGINXV Wants=network.target nss-lookup.target After=syslog.target network.target remote-fs.target nss-lookup.target [email protected] plymouth-quit.service xdm.service [Service] Type=forking PIDFile=/var/run/nginx/nginx.pid ExecStartPre=/usr/local/$NGINXV/sbin/nginx -t ExecStart=/usr/local/$NGINXV/sbin/nginx ExecReload=/bin/kill -s HUP \$MAINPID ExecStop=/bin/kill -s QUIT \$MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target runlevel3.target L11HEREDOC systemctl daemon-reload systemctl status nginx.service systemctl enable nginx.service } # ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------ function make_nginx_tmpfile { notice "make_nginx_tmpfile" if ! whoami | grep -q root; then echo 'root required. exit.' exit 1 fi cat << L12HEREDOC > /usr/lib/tmpfiles.d/nginx.conf d /run/nginx 0755 nginx nginx - - L12HEREDOC } # ------------------------------------------------------------------------------ # get_arch 'https://domain.tld/archive.tar.gz' 'archive.tar.gz' 'folder' function get_arch { notice "get_arch [$1] FILE [$2] FOLD [$3]" local getUrl=$1 local fileName=$2 local folderName=$3 if [ ! -f $fileName ]; then notice "wget $getUrl -O $fileName" wget $getUrl -O $fileName fi #if [ -d $folderName ]; then # notice "rm rf $folderName" # rm -rf $folderName #fi if [ ! -d $folderName ] && [[ $fileName =~ ".zip" ]]; then notice "unzip" unzip $fileName fi if [[ ! -d $folderName ]] && [[ $fileName =~ ".tar." ]]; then notice "tar xf" tar xf $fileName fi if [ ! -f $fileName ]; then err "get_arch: file $fileName is not exists" fi if [ ! -d $folderName ]; then err "get_arch: folder $folderName is not exists" fi } # ------------------------------------------------------------------------------ # get_github 'user' 'project.git' # get_github 'user' 'project.git' 'branch' # # project 'project.git' save to similar folder 'project.git' function get_github { notice "get_github https://github.com/$1/$2" local folderName=$2 local branch=$3 if [ -d $folderName ]; then cd $folderName pwd git pull cd .. else if [ "$branch" == "" ]; then git clone https://github.com/$1/$folderName $folderName else warn "branch $branch" git clone -b $branch https://github.com/$1/$folderName $folderName fi fi if [ ! -d $folderName ]; then err "get_github: folder $folderName is not exists" fi echo "https://github.com/$1/$folderName" >> "$PARENTF/versions" pushd $folderName git describe --tags --abbrev=0 echo `git describe --tags --abbrev=0` >> "$PARENTF/versions" popd } # ------------------------------------------------------------------------------ # get_gitany 'https://domain.tld/anypath' 'folder.git' # get_gitany 'https://domain.tld/anypath' 'folder.git' 'branch' function get_gitany { notice "get_gitany $1 to $2" local folderName=$2 local branch=$3 if [ -d $folderName ]; then pushd $folderName pwd git pull popd else if [ "$branch" == "" ]; then git clone $1 $folderName else warn "branch $branch" git clone -b $branch $1 $folderName fi fi if [ ! -d $folderName ]; then err "get_gitany: folder $folderName is not exists" fi echo "$1" >> "$PARENTF/versions" pushd $folderName git describe --tags --abbrev=0 echo `git describe --tags --abbrev=0` >> "$PARENTF/versions" popd } # ------------------------------------------------------------------------------ function notice { builtin echo -en "\033[1m" echo "NOTICE: $@" builtin echo -en "\033[0m" } function success { builtin echo -en "\033[1;32m" echo "SUCCESS: $@" builtin echo -en "\033[0m" } function warn { builtin echo -en "\033[1;33m" echo "WARN: $@" builtin echo -en "\033[0m" } function err { builtin echo -en "\033[1;31m" echo "ERR: $@" builtin echo -en "\033[0m" exit 1 } function fatal { builtin echo -en "\033[1;31m" echo "FATAL: $@" builtin echo -en "\033[0m" exit 1 } # ------------------------------------------------------------------------------ main