├── .editorconfig ├── LICENSE ├── NTHU ├── sshfs_workstation_nthuee.sh └── yppasswd_arg.sh ├── README.md ├── Ubuntu ├── build_ctags.sh ├── fix-WPS-missing-fonts │ ├── fix.sh │ ├── readme.md │ └── wps_symbol_fonts │ │ ├── WEBDINGS.ttf │ │ ├── WINGDNG2.ttf │ │ ├── WINGDNG3.ttf │ │ ├── mtextra.ttf │ │ ├── symbol.ttf │ │ └── wingding.ttf ├── fix_beyondcompare.sh ├── fix_intelephense.sh ├── install_ripgrep.sh ├── remove_old_kernels.sh └── upgrade_all_pip_packages.sh ├── Windows ├── binaries │ ├── _download.txt │ ├── connect.exe │ ├── unzip.exe │ ├── wget.exe │ └── zip.exe ├── create_win64_portable_python.sh ├── psubst.bat └── psubst_example.bat ├── dot-files ├── .config │ ├── git │ │ ├── attributes │ │ └── git-commit-template.txt │ └── yamllint │ │ └── config ├── .editorconfig ├── .eslintrc.js └── .markdownlintrc ├── general ├── compile_gpg.sh ├── compile_gpg_static.sh ├── docker │ └── setup_bash_docker_autocompletion.sh ├── git │ ├── compile_git.sh │ ├── git-completion.bash │ └── git-prompt-set.sh ├── init.d │ ├── imageproxy │ ├── mysqld │ ├── nginx │ ├── php80-fpm │ └── redis-server ├── mintty_themes │ └── jfcherng └── web_server │ ├── compile_nginx.sh │ ├── compile_percona_server.sh │ ├── compile_percona_server_my.cnf │ ├── compile_php56.ini │ ├── compile_php56.sh │ ├── compile_php7.ini │ ├── compile_php7.sh │ ├── compile_php_exts.ini │ ├── compile_php_exts.sh │ ├── extract_uniq_url.sh │ └── prefer_latest_kernel.sh └── sublime_hq ├── mirror_official_docs.sh ├── update_official_packages.sh └── update_st_lsp.sh /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.bat] 12 | charset = latin1 13 | end_of_line = crlf 14 | 15 | [*.{css,sass,scss}] 16 | indent_size = 2 17 | 18 | [*.{html,xml,twig,blade,volt}] 19 | indent_size = 2 20 | 21 | [*.js] 22 | indent_size = 2 23 | 24 | [*.json] 25 | indent_size = 4 26 | 27 | [*.md] 28 | indent_size = 2 29 | trim_trailing_whitespace = false 30 | 31 | [*.php] 32 | indent_size = 4 33 | 34 | [*.ps] 35 | end_of_line = crlf 36 | 37 | [*.py] 38 | indent_size = 4 39 | 40 | [*.{sh,csh,tcsh,zsh,bash,fish}] 41 | indent_size = 4 42 | 43 | [*.{yml,yaml,toml,neon}] 44 | indent_size = 2 45 | 46 | [Makefile] 47 | indent_style = tab 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017-2022 Jack Cherng 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NTHU/sshfs_workstation_nthuee.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Install sshfs 4 | # $ sudo apt-get install -y sshfs 5 | # Add yourself to the fuse group 6 | # $ sudo adduser YOURNAME fuse 7 | # Logout and login again 8 | # Enable non-root users can modify mounted filesystems 9 | # $ sudo vim /etc/fuse.conf 10 | # discomment the "user_allow_other" 11 | 12 | mntDir=~/Desktop/workstation_ee 13 | 14 | # for example, account=m102061999 15 | account=YOUR_STUDENT_ID 16 | # may be daisy/bigbird 17 | server=daisy.ee.nthu.edu.tw 18 | 19 | # some routine jobs 20 | grade=$(echo "${account}" | sed -E 's/^([umd])([^1][0-9]|1[0-9]{2}).*/\1\2/') 21 | remoteDir=/home/${grade}/${account} 22 | 23 | mkdir -p "${mntDir}" 24 | fusermount -u "${mntDir}" 25 | sshfs "${account}@${server}:${remoteDir}" "${mntDir}" -o allow_other 26 | -------------------------------------------------------------------------------- /NTHU/yppasswd_arg.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/expect 2 | 3 | # Usage: ./yppasswd.sh USERNAME NEW_PASSWORD 4 | 5 | set rootpwd "Your root password" 6 | set newpwd [lindex ${argv} 1] 7 | 8 | spawn yppasswd [lindex ${argv} 0] 9 | 10 | expect "*?root password:" 11 | send "${rootpwd}\r" 12 | expect "*?new password:" 13 | send "${newpwd}\r" 14 | expect "*?new password:" 15 | send "${newpwd}\r" 16 | 17 | expect eof 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | My personal scripts. 2 | -------------------------------------------------------------------------------- /Ubuntu/build_ctags.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" 4 | THREAD_CNT=$(getconf _NPROCESSORS_ONLN) 5 | 6 | pushd "${SCRIPT_DIR}" || exit 7 | 8 | if [ ! -d "ctags/.git" ]; then 9 | rm -rf "ctags" 10 | git clone --recursive "https://github.com/universal-ctags/ctags.git" 11 | fi 12 | 13 | pushd ctags || exit 14 | 15 | # sync repo 16 | git fetch --tags --force --prune --all && git checkout origin/master && git reset --hard "@{upstream}" 17 | git submodule update --init 18 | git submodule update --recursive --remote 19 | 20 | # build 21 | ./autogen.sh 22 | ./configure --prefix=/usr/local 23 | make -j "${THREAD_CNT}" 24 | sudo make install 25 | 26 | # cleanup 27 | make clean 28 | git checkout - 29 | git checkout -- . 30 | git clean -dfx 31 | 32 | popd || exit 33 | 34 | popd || exit 35 | -------------------------------------------------------------------------------- /Ubuntu/fix-WPS-missing-fonts/fix.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | sudo command cp -f wps_symbol_fonts/* /usr/share/fonts/ 4 | -------------------------------------------------------------------------------- /Ubuntu/fix-WPS-missing-fonts/readme.md: -------------------------------------------------------------------------------- 1 | WPS is an Microsoft Office like product on Linux system. 2 | 3 | To download and install it check http://wps-community.org/downloads . 4 | 5 | To fix missing fonts problem, just run the `fix.sh` with root privilege. 6 | -------------------------------------------------------------------------------- /Ubuntu/fix-WPS-missing-fonts/wps_symbol_fonts/WEBDINGS.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jfcherng/my-scripts/29fd8c8a0cc6e9d60b1351655eb8f9ccaf6c44d3/Ubuntu/fix-WPS-missing-fonts/wps_symbol_fonts/WEBDINGS.ttf -------------------------------------------------------------------------------- /Ubuntu/fix-WPS-missing-fonts/wps_symbol_fonts/WINGDNG2.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jfcherng/my-scripts/29fd8c8a0cc6e9d60b1351655eb8f9ccaf6c44d3/Ubuntu/fix-WPS-missing-fonts/wps_symbol_fonts/WINGDNG2.ttf -------------------------------------------------------------------------------- /Ubuntu/fix-WPS-missing-fonts/wps_symbol_fonts/WINGDNG3.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jfcherng/my-scripts/29fd8c8a0cc6e9d60b1351655eb8f9ccaf6c44d3/Ubuntu/fix-WPS-missing-fonts/wps_symbol_fonts/WINGDNG3.ttf -------------------------------------------------------------------------------- /Ubuntu/fix-WPS-missing-fonts/wps_symbol_fonts/mtextra.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jfcherng/my-scripts/29fd8c8a0cc6e9d60b1351655eb8f9ccaf6c44d3/Ubuntu/fix-WPS-missing-fonts/wps_symbol_fonts/mtextra.ttf -------------------------------------------------------------------------------- /Ubuntu/fix-WPS-missing-fonts/wps_symbol_fonts/symbol.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jfcherng/my-scripts/29fd8c8a0cc6e9d60b1351655eb8f9ccaf6c44d3/Ubuntu/fix-WPS-missing-fonts/wps_symbol_fonts/symbol.ttf -------------------------------------------------------------------------------- /Ubuntu/fix-WPS-missing-fonts/wps_symbol_fonts/wingding.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jfcherng/my-scripts/29fd8c8a0cc6e9d60b1351655eb8f9ccaf6c44d3/Ubuntu/fix-WPS-missing-fonts/wps_symbol_fonts/wingding.ttf -------------------------------------------------------------------------------- /Ubuntu/fix_beyondcompare.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | [[ ${UID} == "0" ]] && { 4 | echo "do not directly run this script as root" 5 | exit 1 6 | } 7 | 8 | [ ! -f /usr/lib/beyondcompare/BCompare ] && echo 'Cannot find the "BCompare" executable...' 9 | 10 | # patch the "BCompare" executable 11 | sudo sed -i.bak \ 12 | "s/keexjEP3t4Mue23hrnuPtY4TdcsqNiJL-5174TsUdLmJSIXKfG2NGPwBL6vnRPddT7tH29qpkneX63DO9ECSPE9rzY1zhThHERg8lHM9IBFT+rVuiY823aQJuqzxCKIE1bcDqM4wgW01FH6oCBP1G4ub01xmb4BGSUG6ZrjxWHJyNLyIlGvOhoY2HAYzEtzYGwxFZn2JZ66o4RONkXjX0DF9EzsdUef3UAS+JQ+fCYReLawdjEe6tXCv88GKaaPKWxCeaUL9PejICQgRQOLGOZtZQkLgAelrOtehxz5ANOOqCaJgy2mJLQVLM5SJ9Dli909c5ybvEhVmIC0dc9dWH+/N9KmiLVlKMU7RJqnE+WXEEPI1SgglmfmLc1yVH7dqBb9ehOoKG9UE+HAE1YvH1XX2XVGeEqYUY-Tsk7YBTz0WpSpoYyPgx6Iki5KLtQ5G-aKP9eysnkuOAkrvHU8bLbGtZteGwJarev03PhfCioJL4OSqsmQGEvDbHFEbNl1qJtdwEriR+VNZts9vNNLk7UGfeNwIiqpxjk4Mn09nmSd8FhM4ifvcaIbNCRoMPGl6KU12iseSe+w+1kFsLhX+OhQM8WXcWV10cGqBzQE9OqOLUcg9n0krrR3KrohstS9smTwEx9olyLYppvC0p5i7dAx2deWvM1ZxKNs0BvcXGukR+/g" \ 13 | /usr/lib/beyondcompare/BCompare 14 | 15 | # fix: This License key has been revoked. 16 | rm -rf ~/.config/bcompare 17 | 18 | mkdir -p ~/.config/bcompare 19 | 20 | # add license key for the current user 21 | cat <<'EOF' >~/.config/bcompare/BC4Key.txt 22 | Beyond Compare 4 23 | Licensed to: pwelyn 24 | Quantity: 9999 users 25 | Serial number: 9571-9981 26 | License type: Pro Edition for Windows/Linux/OS X 27 | 28 | --- BEGIN LICENSE KEY --- 29 | GXN1eh9FbDiX1ACdd7XKMV7hL7x0ClBJLUJ-zFfKofjaj2yxE53xauIfk 30 | qZ8FoLpcZ0Ux6McTyNmODDSvSIHLYhg1QkTxjCeSCk6ARz0ABJcnUmd3d 31 | ZYJNWFyJun14rmGByRnVPL49QH+Rs0kjRGKCB-cb8IT4Gf0Ue9WMQ1A6t 32 | 31MO9jmjoYUeoUmbeAQSofvuK8GN1rLRv7WXfUJ0uyvYlGLqzq1ZoJAJD 33 | yo0Kdr4ThF-IXcv2cxVyWVW1SaMq8GFosDEGThnY7C-SgNXW30jqAOgiR 34 | jKKRX9RuNeDMFqgP2cuf0NMvyMrMScnM1ZyiAaJJtzbxqN5hZOMClUTE+ 35 | --- END LICENSE KEY ----- 36 | EOF 37 | -------------------------------------------------------------------------------- /Ubuntu/fix_intelephense.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | export FORCE_COLOR=0 4 | 5 | SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" 6 | NOW="$(date +%Y%m%d-%H%M%S)" 7 | 8 | SUB_PATH="intelephense/lib/intelephense.js" 9 | 10 | SERVER_BIN_LOCATIONS=( 11 | # the first argument 12 | "$1" 13 | # this script's directory 14 | "${SCRIPT_DIR}/$(basename "${SUB_PATH}")" 15 | "${SCRIPT_DIR}/node_modules/${SUB_PATH}" 16 | # ... 17 | "$(npm -g root 2>nul)/${SUB_PATH}" 18 | "$(yarn global dir 2>nul)/node_modules/${SUB_PATH}" 19 | ) 20 | 21 | VERSION="1.0.1" 22 | PATCHED_MARKER_DETECTION="/** FILE HAS BEEN PATCHED **/" 23 | PATCHED_MARKER="${PATCHED_MARKER_DETECTION}/** ${VERSION} **/" 24 | 25 | LICENSE_OBJECT_JS='{"message":{"timestamp":0,"machineId":"YOUR_MACHINE_ID","licenceKey":"YOUR_LICENCE_KEY","expiryTimestamp":99999999999,"resultCode":1},"signature":"THE_CALCULATED_SIGNATURE"}' 26 | 27 | ## 28 | ## @brief Change like "C:\Users\..." into "/C/Users/..." 29 | ## 30 | ## @param $1 The target path 31 | ## 32 | function windows_path_fix { 33 | path="$1" 34 | 35 | path="/${path//\\//}" 36 | path="${path//:/}" 37 | 38 | # fix for Unix path 39 | path="${path//\/\///}" 40 | 41 | echo "${path}" 42 | } 43 | 44 | function patch_intelephense { 45 | intelephense_js="$1" 46 | 47 | # backup the source file 48 | file_backup="${intelephense_js}.bak" 49 | if [ ! -f "${file_backup}" ]; then 50 | cp "${intelephense_js}" "${file_backup}" 51 | echo "- Backup '${intelephense_js}' to '${file_backup}'" 52 | else 53 | echo "- Backup already exists: '${file_backup}'" 54 | fi 55 | 56 | search_replace_pairs=( 57 | # force convert licenceKey into a non-empty string even if it is undefined 58 | "s@(\.initializationOptions\.licenceKey)(?![;)\]}])@\1 + 'FOO_BAR'@g" 59 | "s@(\.initializationOptions\.licenceKey)(?=[;)\]}])@\1 = 'FOO_BAR'@g" 60 | # license always active 61 | "s@\b(activationResult\([^)]*\)[[:space:]]*\{)@\1return this._activationResult = ${LICENSE_OBJECT_JS};@g" 62 | "s@\b(readActivationResultFromCache\([^)]*\)[[:space:]]*\{)@\1return this.activationResult = ${LICENSE_OBJECT_JS};@g" 63 | # nullify potential telemetry 64 | "s@\b(intelephense\.com)@localhost@g" 65 | ) 66 | 67 | # do patches 68 | for pair in "${search_replace_pairs[@]}"; do 69 | perl -pi.my_bak -e "${pair}" "${intelephense_js}" 70 | done 71 | rm -f "${intelephense_js}.my_bak" 72 | 73 | # add patched marker 74 | echo -e "\n\n${PATCHED_MARKER}" >>"${intelephense_js}" 75 | } 76 | 77 | for INTELEPHENSE_JS in "${SERVER_BIN_LOCATIONS[@]}"; do 78 | if [ "${INTELEPHENSE_JS}" = "" ]; then 79 | continue 80 | fi 81 | 82 | INTELEPHENSE_JS="$(windows_path_fix "${INTELEPHENSE_JS}")" 83 | 84 | echo "- Test file: ${INTELEPHENSE_JS}" 85 | 86 | if [ -f "${INTELEPHENSE_JS}" ]; then 87 | echo "- Target file: ${INTELEPHENSE_JS}" 88 | 89 | if grep -qF "${PATCHED_MARKER_DETECTION}" "${INTELEPHENSE_JS}"; then 90 | echo "- File seems to be patched already hence skipped." 91 | continue 92 | fi 93 | 94 | patch_intelephense "${INTELEPHENSE_JS}" 95 | 96 | echo "- Patch has been applied." 97 | 98 | break 99 | fi 100 | done 101 | 102 | echo 103 | echo 'Done.' 104 | echo 105 | -------------------------------------------------------------------------------- /Ubuntu/install_ripgrep.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" 4 | 5 | pushd "${SCRIPT_DIR}" || exit 6 | 7 | [[ ${UID} == "0" ]] || { 8 | echo "run as sudo to execute" 9 | exit 1 10 | } 11 | 12 | apt install -y curl jq 13 | 14 | REPO="https://github.com/BurntSushi/ripgrep/releases/download/" 15 | RG_LATEST=$(curl -sSL "https://api.github.com/repos/BurntSushi/ripgrep/releases/latest" | jq --raw-output .tag_name) 16 | RELEASE="${RG_LATEST}/ripgrep-${RG_LATEST}-x86_64-unknown-linux-musl.tar.gz" 17 | 18 | TMPDIR=$(mktemp -d) 19 | 20 | pushd "${TMPDIR}" || exit 21 | 22 | wget -O - "${REPO}${RELEASE}" | tar zxf - --strip-component=1 23 | mv -f rg /usr/local/bin/ 24 | mv -f rg.1 /usr/local/share/man/man1/ 25 | mv -f complete/rg.bash-completion /usr/share/bash-completion/completions/rg 26 | mandb 27 | 28 | popd || exit 29 | 30 | rm -rf "${TMPDIR}" 31 | 32 | popd || exit 33 | -------------------------------------------------------------------------------- /Ubuntu/remove_old_kernels.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | sudo apt install -y byobu 4 | sudo purge-old-kernels --keep 0 5 | -------------------------------------------------------------------------------- /Ubuntu/upgrade_all_pip_packages.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | [[ ${UID} == "0" ]] || { 4 | echo "run as sudo to execute" 5 | exit 1 6 | } 7 | 8 | pip3 freeze --local | command grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U 9 | -------------------------------------------------------------------------------- /Windows/binaries/_download.txt: -------------------------------------------------------------------------------- 1 | wget.exe: https://eternallybored.org/misc/wget/ 2 | zip.exe & unzip.exe: ftp://ftp.info-zip.org/pub/infozip/win32/ 3 | -------------------------------------------------------------------------------- /Windows/binaries/connect.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jfcherng/my-scripts/29fd8c8a0cc6e9d60b1351655eb8f9ccaf6c44d3/Windows/binaries/connect.exe -------------------------------------------------------------------------------- /Windows/binaries/unzip.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jfcherng/my-scripts/29fd8c8a0cc6e9d60b1351655eb8f9ccaf6c44d3/Windows/binaries/unzip.exe -------------------------------------------------------------------------------- /Windows/binaries/wget.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jfcherng/my-scripts/29fd8c8a0cc6e9d60b1351655eb8f9ccaf6c44d3/Windows/binaries/wget.exe -------------------------------------------------------------------------------- /Windows/binaries/zip.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jfcherng/my-scripts/29fd8c8a0cc6e9d60b1351655eb8f9ccaf6c44d3/Windows/binaries/zip.exe -------------------------------------------------------------------------------- /Windows/create_win64_portable_python.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # This script creates a Win64 portable Python environment. 4 | # Pre-installed packages: certifi, pip, setuptools, wheel 5 | 6 | SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) 7 | 8 | pushd "${SCRIPT_DIR}" || exit 1 9 | 10 | PY_PIP_DL_URL="https://bootstrap.pypa.io/get-pip.py" 11 | 12 | # ask user to input Python version 13 | echo '[INFO] Visit "https://www.python.org/downloads/windows/" to find available Python versions.' 14 | read -rp "Enter wanted Python version (e.g. 3.12.0rc1): " PY_FULL_VER 15 | 16 | PY_FULL_VER="${PY_FULL_VER// /}" 17 | # legal form: 3.12.0, 3.12.0a1, 3.12.0b1, 3.12.0rc1 18 | if ! [[ ${PY_FULL_VER} =~ ^[0-9]+\.[0-9]+\.[0-9]+(([ab]|rc)[0-9]+)?$ ]]; then 19 | echo "[ERROR] Invalid Python version." && exit 1 20 | fi 21 | 22 | [[ ${PY_FULL_VER} =~ ^([0-9]+\.[0-9]+) ]] && 23 | PYTHON_JOINED_BASE_VER=${BASH_REMATCH[1]//./} # e.g., 312 24 | [[ ${PY_FULL_VER} =~ ^([0-9]+\.[0-9]+\.[0-9]+) ]] && 25 | PY_BASE_VER=${BASH_REMATCH[1]} # e.g., 3.12.0 26 | 27 | PY_ZIP_BASRNAME="python-${PY_FULL_VER}-embed-amd64" 28 | PY_ZIP_DL_URL="https://www.python.org/ftp/python/${PY_BASE_VER}/${PY_ZIP_BASRNAME}.zip" 29 | 30 | wget "${PY_ZIP_DL_URL}" -O "${PY_ZIP_BASRNAME}.zip" || exit 1 && 31 | unzip "${PY_ZIP_BASRNAME}.zip" -d "${PY_ZIP_BASRNAME}" && 32 | rm -f "${PY_ZIP_BASRNAME}.zip" 33 | 34 | pushd "${PY_ZIP_BASRNAME}" || exit 1 35 | 36 | # add installed packages path 37 | sed -i'' -E "s/^#[ \t]*(import site)/\1/g" "python${PYTHON_JOINED_BASE_VER}._pth" || exit 1 38 | 39 | wget "${PY_PIP_DL_URL}" -qO- | ./python && 40 | ./python -m pip install -U certifi 41 | 42 | popd || exit 1 43 | 44 | 7za a "${PY_ZIP_BASRNAME}.7z" "${PY_ZIP_BASRNAME}" -mx9 -xr'!__pycache__' && 45 | rm -rf "${PY_ZIP_BASRNAME}" 46 | 47 | popd || exit 1 48 | -------------------------------------------------------------------------------- /Windows/psubst.bat: -------------------------------------------------------------------------------- 1 | ::PSUBST v3.0.1-0-gbbb9804 2 | :: 3 | ::Associates a path with a drive letter. 4 | ::Manages persistently substituted (virtual) drives. 5 | :: 6 | ::PSUBST [drive1: [drive2:]path] [/P | /PF] 7 | ::PSUBST drive1: /D [/P | /PF] 8 | ::PSUBST drive1: /P 9 | :: 10 | :: drive1: Specifies a virtual drive to which you want to assign a path. 11 | :: [drive2:]path Specifies a physical drive and path you want to assign to 12 | :: a virtual drive. 13 | :: /D Deletes a substituted (virtual) drive. 14 | :: /P Add, delete or display persistent drives. 15 | :: /PF Add or delete persistent drives with elevated privileges. 16 | :: 17 | ::Type PSUBST with no parameters to display a list of current virtual drives. 18 | ::Type PSUBST /P to display a list of persistent virtual drives. 19 | ::Type PSUBST drive1: /P to restore a virtual drive from persistency. 20 | @echo off 21 | 22 | 23 | if "%~1" == "/?" goto :print_usage 24 | 25 | 26 | if "%~1" == "" ( 27 | rem 28 | rem SUBST 29 | rem 30 | 31 | subst 32 | 33 | goto :EOF 34 | ) 35 | 36 | 37 | if /i "%~1" == "/P" ( 38 | rem 39 | rem SUBST /P 40 | rem 41 | 42 | setlocal 43 | 44 | call :psubst_init 45 | 46 | call :psubst_print 47 | 48 | endlocal 49 | goto :EOF 50 | ) 51 | 52 | 53 | setlocal 54 | 55 | call :psubst_init 56 | 57 | call :psubst_check_disk "%~1" || exit /b %ERRORLEVEL% 58 | 59 | if /i "%~2" == "/P" ( 60 | rem 61 | rem PSUBST X: /P 62 | rem 63 | 64 | call :psubst_lookup "%psubst_disk%" 65 | if not defined psubst_persist_path ( 66 | echo:%~n0: Drive not persistent 67 | exit /b 1 68 | ) 69 | 70 | setlocal enabledelayedexpansion 71 | 72 | subst "!psubst_persist_disk!" "!psubst_persist_path!" 73 | 74 | endlocal 75 | goto :EOF 76 | ) 77 | 78 | if /i "%~2" == "/D" ( 79 | rem 80 | rem PSUBST X: /D ... 81 | rem 82 | 83 | set "psubst_reg_op=delete" 84 | set "psubst_path=" 85 | ) else ( 86 | rem 87 | rem PSUBST X: "..." ... 88 | rem 89 | 90 | call :psubst_check_path "%~2" || exit /b %ERRORLEVEL% 91 | ) 92 | 93 | if /i "%~3" == "/P" ( 94 | rem 95 | rem PSUBST ... /P 96 | rem 97 | 98 | call :psubst_persist "%~3" 99 | ) else if /i "%~3" == "/PF" ( 100 | rem 101 | rem PSUBST ... /PF 102 | rem 103 | 104 | call :psubst_persist "%~3" 105 | ) else if defined psubst_path ( 106 | rem 107 | rem SUBST X: "..." 108 | rem 109 | 110 | subst "%psubst_disk%" "%psubst_path%" 111 | ) else ( 112 | rem 113 | rem SUBST X: /D 114 | rem 115 | 116 | subst "%psubst_disk%" /D 117 | ) 118 | 119 | endlocal 120 | goto :EOF 121 | 122 | 123 | :psubst_init 124 | set "psubst_disk=" 125 | set "psubst_path=" 126 | set "psubst_value=" 127 | set "psubst_persist_disk=" 128 | set "psubst_persist_path=" 129 | set "psubst_reg_op=" 130 | set "psubst_regkey=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices" 131 | goto :EOF 132 | 133 | 134 | :psubst_check_disk 135 | if not "%~1" == "" for %%d in ( "%~1" ) do if /i "%%~d" == "%%~dd" ( 136 | set "psubst_disk=%%~d" 137 | exit /b 0 138 | ) 139 | 140 | echo:%~n0: Invalid parameter: %~1 141 | exit /b 1 142 | 143 | 144 | :psubst_check_path 145 | if /i "%~1" == "/D" ( 146 | set "psubst_reg_op=delete" 147 | set "psubst_path=" 148 | exit /b 0 149 | ) 150 | 151 | if not "%~1" == "" for %%f in ( "%~1\." ) do if exist %%~sf\nul ( 152 | set "psubst_reg_op=add" 153 | set "psubst_path=%%~ff" 154 | exit /b 0 155 | ) 156 | 157 | echo:%~n0: Path not found: %~1 158 | exit /b 1 159 | 160 | 161 | :psubst_persist 162 | call :psubst_lookup "%psubst_disk%" 163 | 164 | if /i "%psubst_reg_op%" == "add" if defined psubst_persist_disk ( 165 | echo:%~n0: Drive already SUBSTed persistently 166 | exit /b 1 167 | ) 168 | 169 | if /i "%psubst_reg_op%" == "delete" if not defined psubst_persist_disk ( 170 | echo:%~n0: Drive not SUBSTed persistently 171 | exit /b 1 172 | ) 173 | 174 | set "psubst_value=" 175 | 176 | if /i "%~1" == "/PF" ( 177 | call :psubst_persist_reg_sudo 178 | ) else ( 179 | call :psubst_persist_reg 180 | ) 181 | 182 | call :psubst_lookup "%psubst_disk%" 183 | 184 | if /i "%psubst_reg_op%" == "add" if not defined psubst_persist_disk ( 185 | echo:%~n0: Unable to add persistently SUBSTed drive 186 | exit /b 1 187 | ) 188 | 189 | if /i "%psubst_reg_op%" == "delete" if defined psubst_persist_disk ( 190 | echo:%~n0: Unable to delete persistently SUBSTed drive 191 | exit /b 1 192 | ) 193 | goto :EOF 194 | 195 | :psubst_persist_reg 196 | if defined psubst_path set "psubst_value=/t REG_SZ /d "\??\%psubst_path%"" 197 | reg %psubst_reg_op% "%psubst_regkey%" /v %psubst_disk% %psubst_value% /f >nul 198 | goto :EOF 199 | 200 | rem Based on the solution suggested in this thread: 201 | rem https://www.dostips.com/forum/viewtopic.php?f=3&t=9212 202 | :psubst_persist_reg_sudo 203 | if defined psubst_path set "psubst_value=/t REG_SZ /d \"\??\%psubst_path%\"" 204 | reg add "HKCU\Software\Classes\.elevate\shell\runas\command" /ve /d "cmd.exe /c start reg %psubst_reg_op% \"%psubst_regkey%\" /v %psubst_disk% %psubst_value% /f >nul" /f >nul 205 | 206 | type nul > "%TEMP%\%~n0.elevate" 207 | "%TEMP%\%~n0.elevate" 208 | del /q "%TEMP%\%~n0.elevate" 209 | 210 | reg delete "HKCU\Software\Classes\.elevate" /f >nul 211 | 212 | goto :EOF 213 | 214 | 215 | :psubst_print 216 | setlocal 217 | call :psubst_lookup 218 | endlocal 219 | goto :EOF 220 | 221 | 222 | :psubst_lookup 223 | set "psubst_persist_disk=" 224 | set "psubst_persist_path=" 225 | 226 | for /f "tokens=1,2,*" %%a in ( 'reg query "%psubst_regkey%"' ) do ^ 227 | for /f "tokens=1,* delims=\\" %%k in ( "%%~c" ) do ^ 228 | if "%%k" == "??" if "%~1" == "" ( 229 | echo:%%~a\: =^> %%~l 230 | ) else if /i "%~1" == "%%~a" ( 231 | set "psubst_persist_disk=%%~a" 232 | set "psubst_persist_path=%%~l" 233 | goto :EOF 234 | ) 235 | goto :EOF 236 | 237 | 238 | :print_usage 239 | for /f "tokens=* delims=:" %%s in ( 'findstr "^::" "%~f0"' ) do echo:%%s 240 | goto :EOF 241 | 242 | -------------------------------------------------------------------------------- /Windows/psubst_example.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | CALL psubst /P 4 | 5 | ECHO [Remove old disk] 6 | CALL psubst E: /D 7 | CALL psubst E: /D /PF 8 | 9 | ECHO [Add new disk] 10 | CALL psubst E: D:\E_Data /PF 11 | 12 | PAUSE 13 | -------------------------------------------------------------------------------- /dot-files/.config/git/attributes: -------------------------------------------------------------------------------- 1 | 2 | *.doc diff=pandoc 3 | *.xls diff=pandoc 4 | *.ppt diff=pandoc 5 | *.odt diff=pandoc 6 | *.docx diff=pandoc 7 | *.xlsx diff=pandoc 8 | *.pptx diff=pandoc 9 | *.pdf diff=pandoc 10 | -------------------------------------------------------------------------------- /dot-files/.config/git/git-commit-template.txt: -------------------------------------------------------------------------------- 1 | # (): (Max 72 char) 2 | # |<---- Using a Maximum Of 72 Characters ---->| 3 | 4 | # Explain why this change is being made 5 | # |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->| 6 | 7 | # --- COMMIT END --- 8 | # Type can be 9 | # - chore (updating grunt tasks etc; no production code change) 10 | # - docs (changes to documentation) 11 | # - feat (new feature) 12 | # - fix (bug fix) 13 | # - perf (performance improvement) 14 | # - refactor (refactoring production code) 15 | # - revert (revert a commit) 16 | # - style (formatting, missing semi colons, etc; no code change) 17 | # - test (adding or refactoring tests; no production code change) 18 | # -------------------- 19 | # Remember to 20 | # - Un-capitalize the subject line 21 | # - Use the imperative mood in the subject line 22 | # - Do not end the subject line with a period 23 | # - Use the body to explain what and why vs. how 24 | # -------------------- 25 | # To use this template: 26 | # git config commit.template git-commit-template.txt 27 | # ^ can be absolute path too 28 | -------------------------------------------------------------------------------- /dot-files/.config/yamllint/config: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | extends: default 4 | 5 | rules: 6 | line-length: 7 | max: 120 8 | level: warning 9 | -------------------------------------------------------------------------------- /dot-files/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.bat] 12 | charset = latin1 13 | end_of_line = crlf 14 | 15 | [*.{css,sass,scss}] 16 | indent_size = 2 17 | 18 | [*.{html,xml,twig,blade,volt}] 19 | indent_size = 2 20 | 21 | [*.js] 22 | indent_size = 2 23 | 24 | [*.json] 25 | indent_size = 4 26 | 27 | [*.md] 28 | indent_size = 2 29 | trim_trailing_whitespace = false 30 | 31 | [*.php] 32 | indent_size = 4 33 | 34 | [*.ps] 35 | end_of_line = crlf 36 | 37 | [*.py] 38 | indent_size = 4 39 | 40 | [*.{sh,csh,tcsh,zsh,bash,fish}] 41 | indent_size = 4 42 | 43 | [*.{yml,yaml,toml,neon}] 44 | indent_size = 2 45 | 46 | [Makefile] 47 | indent_style = tab 48 | -------------------------------------------------------------------------------- /dot-files/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | es6: true, 4 | browser: true, 5 | node: true, 6 | }, 7 | // parser: 'babel-eslint', 8 | parserOptions: { 9 | ecmaFeatures: { 10 | jsx: true, 11 | }, 12 | ecmaVersion: 2018, 13 | sourceType: 'module', 14 | }, 15 | globals: { 16 | $: true, 17 | jQuery: true, 18 | }, 19 | // extends: ['eslint:recommended', 'eslint-config-prettier'], 20 | // plugins: ['prettier'], 21 | rules: { 22 | // 'prettier/prettier': ['error'], 23 | 'no-trailing-spaces': ['warn'], 24 | 'no-unused-vars': ['warn'], 25 | semi: ['error'], 26 | }, 27 | }; 28 | -------------------------------------------------------------------------------- /dot-files/.markdownlintrc: -------------------------------------------------------------------------------- 1 | { 2 | "default": true, 3 | "first-line-h1": false, 4 | "line-length": false, 5 | "no-bare-urls": false, 6 | "no-multiple-blanks": { "maximum": 2 }, 7 | "no-inline-html": false 8 | } 9 | -------------------------------------------------------------------------------- /general/compile_gpg.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" 4 | THREAD_CNT=$(getconf _NPROCESSORS_ONLN) 5 | PREFIX=${PREFIX:-${HOME}/opt} 6 | 7 | export LD_LIBRARY_PATH="${HOME}/opt/lib:${LD_LIBRARY_PATH}" 8 | export PATH="${PREFIX}/bin:${PATH}" 9 | 10 | gpgconf --kill dirmngr 11 | gpgconf --kill gpg-agent 12 | 13 | pushd "${SCRIPT_DIR}" || exit 14 | 15 | mkdir -p _tmp 16 | 17 | pushd _tmp || exit 18 | 19 | wget -c https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.47.tar.gz 20 | wget -c https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-1.10.3.tar.gz 21 | wget -c https://www.gnupg.org/ftp/gcrypt/libassuan/libassuan-2.5.6.tar.bz2 22 | wget -c https://www.gnupg.org/ftp/gcrypt/libksba/libksba-1.6.5.tar.bz2 23 | wget -c https://www.gnupg.org/ftp/gcrypt/npth/npth-1.6.tar.bz2 24 | wget -c https://www.gnupg.org/ftp/gcrypt/ntbtls/ntbtls-0.3.1.tar.bz2 25 | wget -c https://www.gnupg.org/ftp/gcrypt/pinentry/pinentry-1.2.1.tar.bz2 26 | wget -c https://www.gnupg.org/ftp/gcrypt/gnupg/gnupg-2.4.3.tar.bz2 27 | 28 | tar -xzf libgpg-error-1.47.tar.gz 29 | tar -xzf libgcrypt-1.10.3.tar.gz 30 | tar -xjf libassuan-2.5.6.tar.bz2 31 | tar -xjf libksba-1.6.5.tar.bz2 32 | tar -xjf npth-1.6.tar.bz2 33 | tar -xjf ntbtls-0.3.1.tar.bz2 34 | tar -xjf pinentry-1.2.1.tar.bz2 35 | tar -xjf gnupg-2.4.3.tar.bz2 36 | 37 | ( 38 | cd "libgpg-error-1.47" || exit 39 | ./configure --prefix="${PREFIX}" && 40 | make -j"${THREAD_CNT}" && 41 | make -j"${THREAD_CNT}" install 42 | ) 43 | ( 44 | cd "libgcrypt-1.10.3" || exit 45 | ./configure --prefix="${PREFIX}" && 46 | make -j"${THREAD_CNT}" && 47 | make -j"${THREAD_CNT}" install 48 | ) 49 | ( 50 | cd "libassuan-2.5.6" || exit 51 | ./configure --prefix="${PREFIX}" && 52 | make -j"${THREAD_CNT}" && 53 | make -j"${THREAD_CNT}" install 54 | ) 55 | ( 56 | cd "libksba-1.6.5" || exit 57 | ./configure --prefix="${PREFIX}" && 58 | make -j"${THREAD_CNT}" && 59 | make -j"${THREAD_CNT}" install 60 | ) 61 | ( 62 | cd "npth-1.6" || exit 63 | ./configure --prefix="${PREFIX}" && 64 | make -j"${THREAD_CNT}" && 65 | make -j"${THREAD_CNT}" install 66 | ) 67 | ( 68 | cd "ntbtls-0.3.1" || exit 69 | ./configure --prefix="${PREFIX}" && 70 | make -j"${THREAD_CNT}" && 71 | make -j"${THREAD_CNT}" install 72 | ) 73 | ( 74 | cd "pinentry-1.2.1" || exit 75 | ./configure --prefix="${PREFIX}" && 76 | make -j"${THREAD_CNT}" && 77 | make -j"${THREAD_CNT}" install 78 | ) 79 | ( 80 | cd "gnupg-2.4.3" || exit 81 | # This script is aken from https://gitlab.com/goeb/gnupg-static 82 | # Fix build failure ("undefined reference to `ks_ldap_free_state'" in 83 | # dirmngr/server.c). The source of this patch is the LFS project page at 84 | # : 85 | # https://lore.kernel.org/buildroot/20230822200736.30cc8fc8@windsurf/T/ 86 | sed \ 87 | -e '/ks_ldap_free_state/i #if USE_LDAP' \ 88 | -e '/ks_get_state =/a #endif' \ 89 | -e '/ks_ldap_help_variables/i #if USE_LDAP' \ 90 | -e '/ks_ldap_help_variables/a #endif' \ 91 | -i "dirmngr/server.c" 92 | ./configure --prefix="${PREFIX}" && 93 | make -j"${THREAD_CNT}" && 94 | make -j"${THREAD_CNT}" install 95 | ) 96 | 97 | popd || exit 98 | 99 | rm -rf _tmp 100 | 101 | echo "[INFO] Done." 102 | echo "[INFO] Please add \"${PREFIX}/lib\" to your LD_LIBRARY_PATH." 103 | echo "[INFO] Please add \"${PREFIX}/bin\" to your PATH." 104 | 105 | popd || exit 106 | -------------------------------------------------------------------------------- /general/compile_gpg_static.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # This script is modified from https://gitlab.com/goeb/gnupg-static 4 | # Usage: "$0" 5 | # 6 | # With being the directory the static GPG distribution will 7 | # eventually be installed to (by you, not by this script). All built files 8 | # will be placed in the dst/ directory. 9 | 10 | set -o errexit 11 | set -o nounset 12 | 13 | # shopt -s localvar_unset 14 | # shopt -s shift_verbose 15 | # shopt -u sourcepath 16 | 17 | SKIP_DOWNLOAD_VERIFY=${SKIP_DOWNLOAD_VERIFY:-true} 18 | 19 | v_musl_libc=1.2.3 # https://musl.libc.org/ 20 | v_libsqlite=3440200 # https://www.sqlite.org/download.html 21 | v_zlib_zlib=1.3 # https://zlib.net/ 22 | 23 | v_gpg_lnpth=1.6 # https://gnupg.org/download/index.html 24 | v_gpg_error=1.47 25 | v_gpg_lassn=2.5.6 26 | v_gpg_gcrpt=1.10.3 27 | v_gpg_lksba=1.6.5 28 | v_gpg_n_tls=0.3.1 29 | v_gpg_gnupg=2.4.3 30 | v_gpg_pntry=1.2.1 31 | 32 | n_processes=$(getconf _NPROCESSORS_ONLN) 33 | 34 | gpg_baseurl='https://gnupg.org/ftp/gcrypt' 35 | 36 | all_dl_urls=( 37 | "https://musl.libc.org/releases/musl-${v_musl_libc}.tar.gz"{,.asc} 38 | "https://www.sqlite.org/2023/sqlite-autoconf-${v_libsqlite}.tar.gz" 39 | "https://zlib.net/zlib-${v_zlib_zlib}.tar.gz"{,.asc} 40 | "${gpg_baseurl}/npth/npth-${v_gpg_lnpth}.tar.bz2"{,.sig} 41 | "${gpg_baseurl}/libgpg-error/libgpg-error-${v_gpg_error}.tar.bz2"{,.sig} 42 | "${gpg_baseurl}/libassuan/libassuan-${v_gpg_lassn}.tar.bz2"{,.sig} 43 | "${gpg_baseurl}/libgcrypt/libgcrypt-${v_gpg_gcrpt}.tar.bz2"{,.sig} 44 | "${gpg_baseurl}/libksba/libksba-${v_gpg_lksba}.tar.bz2"{,.sig} 45 | "${gpg_baseurl}/ntbtls/ntbtls-${v_gpg_n_tls}.tar.bz2"{,.sig} 46 | "${gpg_baseurl}/gnupg/gnupg-${v_gpg_gnupg}.tar.bz2"{,.sig} 47 | "${gpg_baseurl}/pinentry/pinentry-${v_gpg_pntry}.tar.bz2"{,.sig} 48 | ) 49 | 50 | import_keys=( 51 | '02F38DFF731FF97CB039A1DA549E695E905BA208' 52 | '5ED46A6721D365587791E2AA783FCD8E58BCAFBA' 53 | '6DAA6E64A76D2840571B4902528897B826403ADA' 54 | '836489290BB6B70F99FFDA0556BCDB593020450F' 55 | 'AC8E115BF73E2D8D47FA9908E98E9B2D19C6C8BD' 56 | 'D8692123C4065DEA5E0F3AB5249B39D24F25E3B6' 57 | ) 58 | 59 | src="$( pwd )/src" 60 | pfx="$( pwd )/pfx" 61 | tmp="$( pwd )/tmp" 62 | 63 | if [[ -z "${1:-}" ]] ; then 64 | printf 'Usage: %s \n' "$0" >&2 65 | exit 1 66 | fi 67 | 68 | DST="$( pwd )/dst" 69 | PFX="${1}" 70 | 71 | export PATH="${pfx}/bin:${PATH}" 72 | 73 | # create directories: ######################################################## 74 | # 75 | mkdir -p "${src}" "${pfx}" "${tmp}" "${DST}" 76 | 77 | # download all sources and signatures: ####################################### 78 | # 79 | ( 80 | cd tmp/ 81 | curl -L --remote-name-all "${all_dl_urls[@]}" 82 | ) 83 | 84 | # check signatures: ########################################################## 85 | # 86 | # disabled by short circuit... 87 | [[ ${SKIP_DOWNLOAD_VERIFY} == "true" ]] || ( 88 | # shellcheck disable=SC2174 89 | mkdir -m 0700 -p gpg/ 90 | 91 | GNUPGHOME="$( pwd )/gpg/" 92 | export GNUPGHOME 93 | 94 | for k in "${import_keys[@]}" ; do 95 | case "${k}" in 96 | https://*) curl -L "${k}" | gpg --import - ;; 97 | *) gpg --recv-keys "${k}" ;; 98 | esac 99 | done 100 | 101 | cd tmp/ 102 | 103 | gpg --verify "musl-${v_musl_libc}.tar.gz"{.asc,} 104 | gpg --verify "zlib-${v_zlib_zlib}.tar.gz"{.asc,} 105 | 106 | gpg --verify "npth-${v_gpg_lnpth}.tar.bz2"{.sig,} 107 | gpg --verify "libgpg-error-${v_gpg_error}.tar.bz2"{.sig,} 108 | gpg --verify "libassuan-${v_gpg_lassn}.tar.bz2"{.sig,} 109 | gpg --verify "libgcrypt-${v_gpg_gcrpt}.tar.bz2"{.sig,} 110 | gpg --verify "libksba-${v_gpg_lksba}.tar.bz2"{.sig,} 111 | gpg --verify "ntbtls-${v_gpg_n_tls}.tar.bz2"{.sig,} 112 | gpg --verify "pinentry-${v_gpg_pntry}.tar.bz2"{.sig,} 113 | gpg --verify "gnupg-${v_gpg_gnupg}.tar.bz2"{.sig,} 114 | 115 | gpgconf --kill dirmngr 116 | gpgconf --kill gpg-agent 117 | 118 | # Note: SQLite doesn't provide a signature, only a SHA3 checksum. 119 | # 120 | if command -v sha3sum >/dev/null 2>&1 ; then 121 | sqlite_file='' 122 | for url in "${all_dl_urls[@]}" ; do 123 | # shellcheck disable=SC2249 124 | case "${url}" in 125 | *sqlite*) sqlite_file=$( basename "${url}" ) ; break ;; 126 | esac 127 | done 128 | if [[ -z "${sqlite_file}" ]] ; then 129 | exit 1 130 | fi 131 | sha3=$( 132 | curl https://sqlite.org/download.html 2>/dev/null | \ 133 | awk -F, "/^PRODUCT,.*\/${sqlite_file},/{print\$5}" 134 | ) 135 | sha3sum -a 256 -c - <<<"${sha3} ${sqlite_file}" >/dev/null 136 | fi 137 | ) 138 | 139 | # build musl-gcc: ############################################################ 140 | # 141 | ( 142 | cd src/ 143 | tar -xzf "../tmp/musl-${v_musl_libc}.tar.gz" 144 | mkdir -p musl/ && cd musl/ 145 | "../musl-${v_musl_libc}/configure" \ 146 | --prefix="${pfx}" \ 147 | --enable-wrapper=gcc \ 148 | --syslibdir="${pfx}/lib" 149 | make -j"${n_processes}" 150 | make install 151 | ) 152 | 153 | export GCC="${pfx}/bin/musl-gcc" 154 | export CC="${pfx}/bin/musl-gcc" 155 | 156 | # build sqlite: ############################################################## 157 | # 158 | ( 159 | cd src/ 160 | tar -xzf "../tmp/sqlite-autoconf-${v_libsqlite}.tar.gz" 161 | mkdir -p sqlite/ && cd sqlite/ 162 | "../sqlite-autoconf-${v_libsqlite}/configure" CC="${GCC}" \ 163 | --prefix="${pfx}" \ 164 | --enable-shared=no \ 165 | --enable-static=yes 166 | make -j"${n_processes}" 167 | make install 168 | ) 169 | 170 | # build zlib: ################################################################ 171 | # 172 | ( 173 | cd src/ 174 | tar -xzf "../tmp/zlib-${v_zlib_zlib}.tar.gz" 175 | mkdir -p zlib/ && cd zlib/ 176 | "../zlib-${v_zlib_zlib}/configure" \ 177 | --prefix="${pfx}" \ 178 | --static 179 | make -j"${n_processes}" 180 | make install 181 | ) 182 | 183 | # build npth: ################################################################ 184 | # 185 | ( 186 | cd src/ 187 | tar -xjf "../tmp/npth-${v_gpg_lnpth}.tar.bz2" 188 | mkdir -p npth/ && cd npth/ 189 | "../npth-${v_gpg_lnpth}/configure" CC="${GCC}" \ 190 | --prefix="${pfx}" \ 191 | --enable-shared=no \ 192 | --enable-static=yes 193 | make -j"${n_processes}" 194 | make install 195 | ) 196 | 197 | # build libgpg-error: ######################################################## 198 | # 199 | ( 200 | cd src/ 201 | tar -xjf "../tmp/libgpg-error-${v_gpg_error}.tar.bz2" 202 | mkdir -p libgpg-error/ && cd libgpg-error/ 203 | "../libgpg-error-${v_gpg_error}/configure" CC="${GCC}" \ 204 | --prefix="${pfx}" \ 205 | --enable-shared=no \ 206 | --enable-static=yes \ 207 | --disable-nls \ 208 | --disable-languages \ 209 | --disable-doc 210 | make -j"${n_processes}" 211 | make install 212 | # This is required by following builds but not copied for some reason: 213 | cp src/gpg-error-config "${pfx}/bin/" 214 | ) 215 | 216 | # build libassuan: ########################################################### 217 | # 218 | ( 219 | cd src/ 220 | tar -xjf "../tmp/libassuan-${v_gpg_lassn}.tar.bz2" 221 | mkdir -p libassuan/ && cd libassuan/ 222 | "../libassuan-${v_gpg_lassn}/configure" CC="${GCC}" \ 223 | --prefix="${pfx}" \ 224 | --enable-shared=no \ 225 | --enable-static=yes \ 226 | --disable-doc \ 227 | --with-libgpg-error-prefix="${pfx}" 228 | make -j"${n_processes}" 229 | make install 230 | ) 231 | 232 | # build libgcrypt: ########################################################### 233 | # 234 | ( 235 | cd src/ 236 | tar -xjf "../tmp/libgcrypt-${v_gpg_gcrpt}.tar.bz2" 237 | mkdir -p libgcrypt/ && cd libgcrypt/ 238 | "../libgcrypt-${v_gpg_gcrpt}/configure" CC="${GCC}" \ 239 | --prefix="${pfx}" \ 240 | --enable-shared=no \ 241 | --enable-static=yes \ 242 | --disable-padlock-support \ 243 | --disable-ppc-crypto-support \ 244 | --disable-doc \ 245 | --with-libgpg-error-prefix="${pfx}" 246 | make -j"${n_processes}" 247 | make install 248 | ) 249 | 250 | # build libksba: ############################################################# 251 | # 252 | ( 253 | cd src/ 254 | tar -xjf "../tmp/libksba-${v_gpg_lksba}.tar.bz2" 255 | mkdir -p libksba/ && cd libksba/ 256 | "../libksba-${v_gpg_lksba}/configure" CC="${GCC}" \ 257 | --prefix="${pfx}" \ 258 | --enable-shared=no \ 259 | --enable-static=yes \ 260 | --with-libgpg-error-prefix="${pfx}" 261 | make -j"${n_processes}" 262 | make install 263 | ) 264 | 265 | # build ntbtls: ############################################################## 266 | # 267 | ( 268 | cd src/ 269 | tar -xjf "../tmp/ntbtls-${v_gpg_n_tls}.tar.bz2" 270 | mkdir -p ntbtls/ && cd ntbtls/ 271 | "../ntbtls-${v_gpg_n_tls}/configure" CC="${GCC}" \ 272 | --prefix="${pfx}" \ 273 | --enable-shared=no \ 274 | --enable-static=yes \ 275 | --with-libgpg-error-prefix="${pfx}" \ 276 | --with-libgcrypt-prefix="${pfx}" \ 277 | --with-libksba-prefix="${pfx}" \ 278 | --with-zlib="${pfx}" 279 | make -j"${n_processes}" 280 | make install 281 | ) 282 | 283 | # build gnupg: ############################################################### 284 | # 285 | ( 286 | cd src/ 287 | tar -xjf "../tmp/gnupg-${v_gpg_gnupg}.tar.bz2" 288 | # Fix build failure ("undefined reference to `ks_ldap_free_state'" in 289 | # dirmngr/server.c). The source of this patch is the LFS project page at 290 | # : 291 | # https://lore.kernel.org/buildroot/20230822200736.30cc8fc8@windsurf/T/ 292 | sed \ 293 | -e '/ks_ldap_free_state/i #if USE_LDAP' \ 294 | -e '/ks_get_state =/a #endif' \ 295 | -e '/ks_ldap_help_variables/i #if USE_LDAP' \ 296 | -e '/ks_ldap_help_variables/a #endif' \ 297 | -i "gnupg-${v_gpg_gnupg}/dirmngr/server.c" 298 | mkdir -p gnupg/ && cd gnupg/ 299 | "../gnupg-${v_gpg_gnupg}/configure" CC="${GCC}" LDFLAGS='-static -s' \ 300 | --prefix="${PFX}" \ 301 | --enable-tofu \ 302 | --disable-scdaemon \ 303 | --disable-keyboxd \ 304 | --disable-tpm2d \ 305 | --disable-doc \ 306 | --disable-gpgtar \ 307 | --disable-wks-tools \ 308 | --disable-libdns \ 309 | --disable-gpg-idea \ 310 | --disable-gpg-cast5 \ 311 | --disable-gpg-blowfish \ 312 | --disable-gpg-twofish \ 313 | --disable-gpg-md5 \ 314 | --disable-gpg-rmd160 \ 315 | --enable-zip \ 316 | --disable-bzip2 \ 317 | --disable-photo-viewers \ 318 | --disable-card-support \ 319 | --disable-ccid-driver \ 320 | --enable-sqlite \ 321 | --disable-dirmngr-auto-start \ 322 | --disable-gnutls \ 323 | --disable-ldap \ 324 | --disable-nls \ 325 | --with-agent-pgm="${PFX}/bin/gpg-agent" \ 326 | --with-pinentry-pgm="${PFX}/bin/pinentry" \ 327 | --with-libgpg-error-prefix="${pfx}" \ 328 | --with-libgcrypt-prefix="${pfx}" \ 329 | --with-libassuan-prefix="${pfx}" \ 330 | --with-libksba-prefix="${pfx}" \ 331 | --with-npth-prefix="${pfx}" \ 332 | --with-ntbtls-prefix="${pfx}" \ 333 | --with-zlib="${pfx}" 334 | make -j"${n_processes}" 335 | make install DESTDIR="${DST}" 336 | ) 337 | 338 | # build pinentry: ############################################################ 339 | # 340 | ( 341 | cd src/ 342 | tar -xjf "../tmp/pinentry-${v_gpg_pntry}.tar.bz2" 343 | mkdir -p pinentry/ && cd pinentry/ 344 | "../pinentry-${v_gpg_pntry}/configure" CC="${GCC}" LDFLAGS='-static -s' \ 345 | --prefix="${PFX}" \ 346 | --enable-pinentry-tty \ 347 | --disable-ncurses \ 348 | --disable-pinentry-qt5 \ 349 | --disable-doc \ 350 | --disable-libsecret \ 351 | --disable-pinentry-curses \ 352 | --disable-pinentry-emacs \ 353 | --disable-inside-emacs \ 354 | --disable-pinentry-gtk2 \ 355 | --disable-pinentry-gnome3 \ 356 | --disable-pinentry-qt \ 357 | --disable-pinentry-tqt \ 358 | --disable-pinentry-fltk \ 359 | --with-libgpg-error-prefix="${pfx}" \ 360 | --with-libassuan-prefix="${pfx}" 361 | make -j"${n_processes}" 362 | make install DESTDIR="${DST}" 363 | ) 364 | 365 | -------------------------------------------------------------------------------- /general/docker/setup_bash_docker_autocompletion.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # @see https://rohancragg.co.uk/misc/git-bash/ 4 | 5 | mkdir -p ~/bash_completion.d 6 | 7 | # Docker CLI 8 | curl -o \ 9 | ~/bash_completion.d/docker \ 10 | "https://raw.githubusercontent.com/docker/cli/master/contrib/completion/bash/docker" 11 | echo "source ~/bash_completion.d/docker" >>~/.bashrc 12 | 13 | # Docker Machine 14 | curl -o \ 15 | ~/bash_completion.d/docker-machine \ 16 | "https://raw.githubusercontent.com/docker/machine/master/contrib/completion/bash/docker-machine.bash" 17 | echo "source ~/bash_completion.d/docker-machine" >>~/.bashrc 18 | 19 | # Docker Compose 20 | curl -o \ 21 | ~/bash_completion.d/docker-compose \ 22 | "https://raw.githubusercontent.com/docker/compose/master/contrib/completion/bash/docker-compose" 23 | echo "source ~/bash_completion.d/docker-compose" >>~/.bashrc 24 | 25 | # Kubernetes 26 | kubectl completion bash >~/bash_completion.d/kubectl 27 | echo "source ~/bash_completion.d/kubectl" >>~/.bashrc 28 | -------------------------------------------------------------------------------- /general/git/compile_git.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #------------------------------------------# 4 | # This script compiles git. # 5 | # # 6 | # Author: Jack Cherng # 7 | #------------------------------------------# 8 | 9 | SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" 10 | THREAD_CNT=$(getconf _NPROCESSORS_ONLN) 11 | 12 | if [ "$(id -u)" != "0" ]; then 13 | is_root=false 14 | else 15 | is_root=true 16 | fi 17 | 18 | #-------# 19 | # begin # 20 | #-------# 21 | 22 | pushd "${SCRIPT_DIR}" || exit 23 | 24 | # prefer the latest user-installed libs if possible 25 | PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:${PKG_CONFIG_PATH}" 26 | 27 | echo "=========================================================================" 28 | if [ "${is_root}" = true ]; then 29 | echo "[INFO] You are 'root'!!!" 30 | git_install_prefix="/usr/local" 31 | else 32 | echo "[INFO] You are not 'root'..." 33 | git_install_prefix="${HOME}/opt" 34 | fi 35 | echo "This script will install git to '${git_install_prefix}'." 36 | echo "=========================================================================" 37 | 38 | git_ver_old=$("${git_install_prefix}/bin/git" --version | cut -d ' ' -f 3) 39 | if [ "${git_ver_old}" = "" ]; then 40 | git_ver_old="None" 41 | fi 42 | echo "Current git Version: ${git_ver_old}" 43 | echo "You can find version number from 'https://github.com/git/git/releases'" 44 | echo "Note: the latest build may not work properly!" 45 | 46 | #--------------------------# 47 | # read option: git_ver_new # 48 | #--------------------------# 49 | 50 | read -erp "Which git version you want to install (such as '2.15.0' or 'latest'): " git_ver_new 51 | if [ "${git_ver_new}" = "" ]; then 52 | echo "[*] No git version is given." 53 | exit 1 54 | fi 55 | 56 | #---------------------------# 57 | # read option: thread_count # 58 | #---------------------------# 59 | 60 | read -erp "Parallel compilation with thread counts (default = ${THREAD_CNT}): " thread_count 61 | if [ "${thread_count}" = "" ]; then 62 | thread_count=${THREAD_CNT} 63 | fi 64 | 65 | #--------------# 66 | # confirmation # 67 | #--------------# 68 | 69 | echo 70 | echo "===================================" 71 | echo "thread_count = ${thread_count}" 72 | echo "git_ver_new = ${git_ver_new}" 73 | echo "===================================" 74 | echo 75 | echo "Is the above information correct?" 76 | echo "Press any key to start or Ctrl+C to cancel." 77 | read -rn 1 # wait for a key press 78 | echo 79 | 80 | #----------------------# 81 | # download source code # 82 | #----------------------# 83 | 84 | git_archive="git-${git_ver_new}.tar.gz" 85 | echo 86 | echo "===================== Download Package: Start ===========================" 87 | 88 | rm -rf "git-${git_ver_new}"* # remove old sources 89 | 90 | if [ "${git_ver_new}" = "latest" ]; then 91 | wget --no-check-certificate -O "${git_archive}" "https://github.com/git/git/archive/master.tar.gz" 92 | else 93 | wget --no-check-certificate -O "${git_archive}" "https://github.com/git/git/archive/v${git_ver_new}.tar.gz" 94 | fi 95 | 96 | if [ $? -eq 0 ]; then 97 | echo "Download '${git_archive}' successfully!" 98 | else 99 | echo "[Error] Maybe the git version you input was wrong. Please check it." 100 | echo "The git version you just input was: ${git_ver_new}" 101 | exit 1 102 | fi 103 | 104 | echo "===================== Download Package: End =============================" 105 | 106 | #----------------------# 107 | # install dependencies # 108 | #----------------------# 109 | 110 | if [ "${is_root}" = true ]; then 111 | echo 112 | echo "You are a ROOT, let's install dependencies..." 113 | echo "=================== Install dependencies: Start =========================" 114 | 115 | # if there is `yum`, install dependencies 116 | if command -v yum >/dev/null 2>&1; then 117 | yum install -y autoconf curl curl-devel zlib-devel openssl-devel perl perl-devel cpio expat-devel gettext-devel unzip gcc autoconf 118 | # if there is `apt`, install dependencies 119 | elif command -v apt >/dev/null 2>&1; then 120 | apt update 121 | apt install -y autoconf build-essential gettext libcurl4-gnutls-dev libexpat1-dev libnl-dev libnl1 libreadline6-dev libssl-dev libssl-dev zlib1g-dev 122 | else 123 | echo "Did not find 'yum' or 'apt'..." 124 | fi 125 | 126 | echo "=================== Install dependencies: End ===========================" 127 | fi 128 | 129 | #-------------# 130 | # compile git # 131 | #-------------# 132 | 133 | echo 134 | echo "===================== Compile git: Start ===========================" 135 | 136 | git_source_dir_name="git-${git_ver_new}" 137 | 138 | echo "Decompressing tarball..." 139 | 140 | tar xf "${git_archive}" 141 | if [ "${git_ver_new}" = "latest" ]; then 142 | # correct the source dir name 143 | mv git-master "${git_source_dir_name}" 144 | fi 145 | 146 | echo "Decompressing tarball... Done" 147 | 148 | mkdir -p "${git_install_prefix}" 149 | pushd "${git_source_dir_name}" || exit 150 | 151 | # if there is autoconf, we use it 152 | if command -v autoconf >/dev/null 2>&1; then 153 | autoconf || exit 1 154 | ./configure --prefix="${git_install_prefix}" 155 | fi 156 | make -j "${thread_count}" all #CFLAGS="-liconv" 157 | make -j "${thread_count}" install #CFLAGS="-liconv" 158 | 159 | # error during compilation? 160 | if [ $? -ne 0 ]; then 161 | exit 1 162 | fi 163 | 164 | # compile modules 165 | git_modules=('subtree') 166 | for git_module in "${git_modules[@]}"; do 167 | pushd "contrib/${git_module}" || exit 168 | 169 | make -j "${thread_count}" 170 | make -j "${thread_count}" prefix="${git_install_prefix}" install 171 | 172 | popd || exit 173 | done 174 | 175 | popd || exit 176 | 177 | echo "===================== Compile git: End =============================" 178 | 179 | git_ver_new=$("${git_install_prefix}/bin/git" --version | cut -d ' ' -f 3) 180 | if [ "${git_ver_new}" = "" ]; then 181 | git_ver_new="None" 182 | fi 183 | 184 | echo 185 | echo "=========================================================================" 186 | echo "You have successfully upgraded from '${git_ver_old}' to '${git_ver_new}'" 187 | echo "You may have to add '${git_install_prefix}/bin' to your PATH" 188 | echo "=========================================================================" 189 | echo 190 | 191 | #----------------# 192 | # remove sources # 193 | #----------------# 194 | 195 | rm -f "${git_archive}"* 196 | rm -rf "${git_source_dir_name}" 197 | 198 | #-----# 199 | # end # 200 | #-----# 201 | 202 | popd || exit 203 | -------------------------------------------------------------------------------- /general/git/git-prompt-set.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Customize BASH PS1 prompt to show current GIT repository and branch. 3 | # by Mike Stewart - http://MediaDoneRight.com 4 | 5 | # SETUP CONSTANTS 6 | # Bunch-o-predefined colors. Makes reading code easier than escape sequences. 7 | # I don't remember where I found this. o_O 8 | 9 | # Reset 10 | Color_Off="\[\033[0m\]" # Text Reset 11 | 12 | # Regular Colors 13 | Black="\[\033[0;30m\]" # Black 14 | Red="\[\033[0;31m\]" # Red 15 | Green="\[\033[0;32m\]" # Green 16 | Yellow="\[\033[0;33m\]" # Yellow 17 | Blue="\[\033[0;34m\]" # Blue 18 | Purple="\[\033[0;35m\]" # Purple 19 | Cyan="\[\033[0;36m\]" # Cyan 20 | White="\[\033[0;37m\]" # White 21 | 22 | # Bold 23 | BBlack="\[\033[1;30m\]" # Black 24 | BRed="\[\033[1;31m\]" # Red 25 | BGreen="\[\033[1;32m\]" # Green 26 | BYellow="\[\033[1;33m\]" # Yellow 27 | BBlue="\[\033[1;34m\]" # Blue 28 | BPurple="\[\033[1;35m\]" # Purple 29 | BCyan="\[\033[1;36m\]" # Cyan 30 | BWhite="\[\033[1;37m\]" # White 31 | 32 | # Underline 33 | UBlack="\[\033[4;30m\]" # Black 34 | URed="\[\033[4;31m\]" # Red 35 | UGreen="\[\033[4;32m\]" # Green 36 | UYellow="\[\033[4;33m\]" # Yellow 37 | UBlue="\[\033[4;34m\]" # Blue 38 | UPurple="\[\033[4;35m\]" # Purple 39 | UCyan="\[\033[4;36m\]" # Cyan 40 | UWhite="\[\033[4;37m\]" # White 41 | 42 | # Background 43 | On_Black="\[\033[40m\]" # Black 44 | On_Red="\[\033[41m\]" # Red 45 | On_Green="\[\033[42m\]" # Green 46 | On_Yellow="\[\033[43m\]" # Yellow 47 | On_Blue="\[\033[44m\]" # Blue 48 | On_Purple="\[\033[45m\]" # Purple 49 | On_Cyan="\[\033[46m\]" # Cyan 50 | On_White="\[\033[47m\]" # White 51 | 52 | # High Intensty 53 | IBlack="\[\033[0;90m\]" # Black 54 | IRed="\[\033[0;91m\]" # Red 55 | IGreen="\[\033[0;92m\]" # Green 56 | IYellow="\[\033[0;93m\]" # Yellow 57 | IBlue="\[\033[0;94m\]" # Blue 58 | IPurple="\[\033[0;95m\]" # Purple 59 | ICyan="\[\033[0;96m\]" # Cyan 60 | IWhite="\[\033[0;97m\]" # White 61 | 62 | # Bold High Intensty 63 | BIBlack="\[\033[1;90m\]" # Black 64 | BIRed="\[\033[1;91m\]" # Red 65 | BIGreen="\[\033[1;92m\]" # Green 66 | BIYellow="\[\033[1;93m\]" # Yellow 67 | BIBlue="\[\033[1;94m\]" # Blue 68 | BIPurple="\[\033[1;95m\]" # Purple 69 | BICyan="\[\033[1;96m\]" # Cyan 70 | BIWhite="\[\033[1;97m\]" # White 71 | 72 | # High Intensty backgrounds 73 | On_IBlack="\[\033[0;100m\]" # Black 74 | On_IRed="\[\033[0;101m\]" # Red 75 | On_IGreen="\[\033[0;102m\]" # Green 76 | On_IYellow="\[\033[0;103m\]" # Yellow 77 | On_IBlue="\[\033[0;104m\]" # Blue 78 | On_IPurple="\[\033[10;95m\]" # Purple 79 | On_ICyan="\[\033[0;106m\]" # Cyan 80 | On_IWhite="\[\033[0;107m\]" # White 81 | 82 | # Various variables you might want for your PS1 prompt instead 83 | Time12h="\T" 84 | Time12a="\@" 85 | PathShort="\W" 86 | PathFull="\w" 87 | NewLine="\n" 88 | Jobs="\j" 89 | Username="\u" 90 | HostnameShort="\h" 91 | HostnameFull="\H" 92 | Dollar='$' 93 | 94 | # This PS1 snippet was adopted from code for MAC/BSD I saw from: 95 | # http://allancraig.net/index.php?option=com_content&view=article&id=108:ps1-export-command-for-git&catid=45:general&Itemid=96 96 | # Re-written by Jack Cherng for performance under Windows 97 | 98 | export PS1="[${Username}@${HostnameShort} ${IYellow}${PathShort}${Color_Off}]"'\ 99 | $( \ 100 | { \ 101 | # from git rev-parse 102 | read _is_bare; \ 103 | read _is_shallow; \ 104 | read _is_in_git_dir; \ 105 | read _is_in_work_tree; \ 106 | # from git status 107 | read _st_oid; \ 108 | read _st_head; \ 109 | read -d "" _st; \ 110 | } <<< "$( \ 111 | git rev-parse \ 112 | --is-bare-repository \ 113 | --is-shallow-repository \ 114 | --is-inside-git-dir \ 115 | --is-inside-work-tree \ 116 | 2>/dev/null \ 117 | && git status --porcelain=2 --branch 2>/dev/null \ 118 | )"; \ 119 | \ 120 | # not git-managed 121 | [[ -z $_is_bare ]] && exit; \ 122 | # early stop if bare repository 123 | [[ $_is_bare == "true" ]] && echo -n "('${BICyan}'bare'${Color_Off}')" && exit; \ 124 | # early stop if in .git repository 125 | [[ $_is_in_git_dir == "true" ]] && echo -n "('${BICyan}'git-dir'${Color_Off}')" && exit; \ 126 | # early stop if not in work tree directory 127 | [[ $_is_in_work_tree == "false" ]] && exit; \ 128 | \ 129 | # "upstream" and "ab" are not present if non-detached HEAD 130 | [[ ${_st} =~ ^\\# ]] && { read _st_upstream; read -d "" _st; } <<< "${_st}"; \ 131 | [[ ${_st} =~ ^\\# ]] && { read _st_ab; read -d "" _st; } <<< "${_st}"; \ 132 | \ 133 | [[ ${_st_oid} =~ \.oid\ ([^\r\n]*) ]] && _branch_oid="${BASH_REMATCH[1]}"; \ 134 | [[ ${_st_head} =~ \.head\ ([^\r\n]*) ]] && _branch_name="${BASH_REMATCH[1]}"; \ 135 | [[ ${_st_upstream} =~ \.upstream\ ([^\r\n]*) ]] && _branch_upstream="${BASH_REMATCH[1]}"; \ 136 | [[ ${_st_ab} =~ \.ab\ ([^\r\n]*) ]] && _branch_ab="${BASH_REMATCH[1]}"; \ 137 | \ 138 | [[ ${_is_shallow} == "true" ]] \ 139 | && shallow_sign="'${BICyan}'!'${Color_Off}'" \ 140 | || shallow_sign=; \ 141 | \ 142 | [[ ${_st} =~ ^[^#] ]] \ 143 | && branch_name="'${BIRed}'${_branch_name}'${Color_Off}'" \ 144 | || branch_name="'${BIGreen}'${_branch_name}'${Color_Off}'"; \ 145 | \ 146 | if [[ ${_branch_oid} == "(initial)" ]]; then \ 147 | # there is no commit yet 148 | branch_status="('${BICyan}'initial'${Color_Off}')"; \ 149 | else \ 150 | [[ ${_branch_ab} =~ \\+([0-9]+)\ -([0-9]+) ]] && branch_status="'${BIGreen}'>${BASH_REMATCH[1]}'${Color_Off}${BIRed}'<${BASH_REMATCH[2]}'${Color_Off}'"; \ 151 | branch_status="${branch_status/'${BIGreen}'>0'${Color_Off}'/}"; \ 152 | branch_status="${branch_status/'${BIRed}'<0'${Color_Off}'/}"; \ 153 | fi; \ 154 | \ 155 | echo -n "(${branch_name})${shallow_sign}${branch_status}"; \ 156 | )'"${Dollar} " 157 | -------------------------------------------------------------------------------- /general/init.d/imageproxy: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ### BEGIN INIT INFO 4 | # Provides: imageproxy 5 | # Required-Start: $remote_fs $network 6 | # Required-Stop: $remote_fs $network 7 | # Default-Start: 2 3 4 5 8 | # Default-Stop: 0 1 6 9 | # Short-Description: starts imageproxy 10 | # Description: starts the imageproxy daemon (https://github.com/willnorris/imageproxy) 11 | ### END INIT INFO 12 | 13 | # There is a service file so you can actually stop using init.d. 14 | # Check this https://github.com/willnorris/imageproxy/blob/master/etc/imageproxy.service 15 | 16 | umask 0002 17 | 18 | IMAGEPROXY_BIN="/root/go/bin/imageproxy" 19 | PID_FILE="/var/run/imageproxy.pid" 20 | 21 | APP_ADDR="localhost:15900" 22 | CACHE_DESTINATION="/tmp/imageproxy" 23 | ALLOWED_CONTENT_TYPES="image/*,image" 24 | USER_AGENT="Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36" 25 | 26 | wait_for_pid() { 27 | try=0 28 | 29 | while test "${try}" -lt 35; do 30 | 31 | case "$1" in 32 | 'created') 33 | if [ -f "$2" ]; then 34 | try='' 35 | break 36 | fi 37 | ;; 38 | 39 | 'removed') 40 | if [ ! -f "$2" ]; then 41 | try='' 42 | break 43 | fi 44 | ;; 45 | esac 46 | 47 | echo -n . 48 | try=$(expr ${try} + 1) 49 | sleep 1 50 | 51 | done 52 | } 53 | 54 | case "$1" in 55 | start) 56 | echo -n "Starting imageproxy " 57 | 58 | "${IMAGEPROXY_BIN}" -scaleUp -addr "${APP_ADDR}" -cache "${CACHE_DESTINATION}" -contentTypes "${ALLOWED_CONTENT_TYPES}" -userAgent "${USER_AGENT}" & 59 | 60 | PID=$(echo $!) 61 | 62 | if [ "${PID}" = "" ]; then 63 | echo " failed" 64 | exit 1 65 | else 66 | echo "${PID}" >"${PID_FILE}" 67 | fi 68 | 69 | wait_for_pid created "${PID_FILE}" 70 | 71 | if [ -n "${try}" ]; then 72 | echo " failed" 73 | exit 1 74 | else 75 | echo " done" 76 | fi 77 | ;; 78 | 79 | stop) 80 | echo -n "Gracefully shutting down imageproxy " 81 | 82 | if [ ! -r "${PID_FILE}" ]; then 83 | echo "warning, no pid file found - imageproxy is not running ?" 84 | exit 1 85 | fi 86 | 87 | kill -QUIT $(cat "${PID_FILE}") && rm -f "${PID_FILE}" 88 | 89 | wait_for_pid removed "${PID_FILE}" 90 | 91 | if [ -n "${try}" ]; then 92 | echo " failed. Use force-quit" 93 | exit 1 94 | else 95 | echo " done" 96 | fi 97 | ;; 98 | 99 | status) 100 | if [ ! -r ${PID_FILE} ]; then 101 | echo "imageproxy is stopped" 102 | exit 0 103 | fi 104 | 105 | PID=$(cat "${PID_FILE}") 106 | if ps -p "${PID}" | grep -q "${PID}"; then 107 | echo "imageproxy (pid ${PID}) is running..." 108 | else 109 | echo "imageproxy dead but pid file exists" 110 | fi 111 | ;; 112 | 113 | force-quit) 114 | echo -n "Terminating imageproxy " 115 | 116 | if [ ! -r "${PID_FILE}" ]; then 117 | echo "warning, no pid file found - imageproxy is not running ?" 118 | exit 1 119 | fi 120 | 121 | kill -TERM $(cat "${PID_FILE}") && rm -f "${PID_FILE}" 122 | 123 | wait_for_pid removed "${PID_FILE}" 124 | 125 | if [ -n "${try}" ]; then 126 | echo " failed" 127 | exit 1 128 | else 129 | echo " done" 130 | fi 131 | ;; 132 | 133 | restart) 134 | $0 stop 135 | $0 start 136 | ;; 137 | 138 | *) 139 | echo "Usage: $0 {start|stop|force-quit|restart|status}" 140 | exit 1 141 | ;; 142 | 143 | esac 144 | -------------------------------------------------------------------------------- /general/init.d/mysqld: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB 3 | # This file is public domain and comes with NO WARRANTY of any kind 4 | 5 | # MySQL daemon start/stop script. 6 | 7 | # Usually this is put in /etc/init.d (at least on machines SYSV R4 based 8 | # systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql. 9 | # When this is done the mysql server will be started when the machine is 10 | # started and shut down when the systems goes down. 11 | 12 | # Comments to support chkconfig on RedHat Linux 13 | # chkconfig: 2345 64 36 14 | # description: A very fast and reliable SQL database engine. 15 | 16 | # Comments to support LSB init script conventions 17 | ### BEGIN INIT INFO 18 | # Provides: mysql 19 | # Required-Start: $local_fs $network $remote_fs 20 | # Should-Start: ypbind nscd ldap ntpd xntpd 21 | # Required-Stop: $local_fs $network $remote_fs 22 | # Default-Start: 2 3 4 5 23 | # Default-Stop: 0 1 6 24 | # Short-Description: start and stop MySQL 25 | # Description: MySQL is a very fast and reliable SQL database engine. 26 | ### END INIT INFO 27 | 28 | # If you install MySQL on some other places than /usr/local/mysql, then you 29 | # have to do one of the following things for this script to work: 30 | # 31 | # - Run this script from within the MySQL installation directory 32 | # - Create a /etc/my.cnf file with the following information: 33 | # [mysqld] 34 | # basedir= 35 | # - Add the above to any other configuration file (for example ~/.my.ini) 36 | # and copy my_print_defaults to /usr/bin 37 | # - Add the path to the mysql-installation-directory to the basedir variable 38 | # below. 39 | # 40 | # If you want to affect other MySQL variables, you should make your changes 41 | # in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files. 42 | 43 | # If you change base dir, you must also change datadir. These may get 44 | # overwritten by settings in the MySQL configuration files. 45 | 46 | basedir=/usr/local/mysql 47 | datadir=/data/mysql 48 | 49 | # Default value, in seconds, afterwhich the script should timeout waiting 50 | # for server start. 51 | # Value here is overriden by value in my.cnf. 52 | # 0 means don't wait at all 53 | # Negative numbers mean to wait indefinitely 54 | service_startup_timeout=900 55 | 56 | # Lock directory for RedHat / SuSE. 57 | lockdir='/var/lock/subsys' 58 | lock_file_path="$lockdir/mysql" 59 | 60 | # The following variables are only set for letting mysql.server find things. 61 | 62 | # Set some defaults 63 | mysqld_pid_file_path= 64 | if test -z "$basedir"; then 65 | basedir=/usr/local/mysql 66 | bindir=/usr/local/mysql/bin 67 | if test -z "$datadir"; then 68 | datadir=/data/mysql 69 | fi 70 | sbindir=/usr/local/mysql/bin 71 | libexecdir=/usr/local/mysql/bin 72 | else 73 | bindir="$basedir/bin" 74 | if test -z "$datadir"; then 75 | datadir="$basedir/data" 76 | fi 77 | sbindir="$basedir/sbin" 78 | libexecdir="$basedir/libexec" 79 | fi 80 | 81 | # datadir_set is used to determine if datadir was set (and so should be 82 | # *not* set inside of the --basedir= handler.) 83 | datadir_set= 84 | 85 | # 86 | # Use LSB init script functions for printing messages, if possible 87 | # 88 | lsb_functions="/lib/lsb/init-functions" 89 | if test -f $lsb_functions; then 90 | . $lsb_functions 91 | else 92 | log_success_msg() { 93 | echo " SUCCESS! $@" 94 | } 95 | log_failure_msg() { 96 | echo " ERROR! $@" 97 | } 98 | fi 99 | 100 | PATH="/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin" 101 | export PATH 102 | 103 | mode=$1 # start or stop 104 | 105 | [ $# -ge 1 ] && shift 106 | 107 | other_args="$*" # uncommon, but needed when called from an RPM upgrade action 108 | # Expected: "--skip-networking --skip-grant-tables" 109 | # They are not checked here, intentionally, as it is the resposibility 110 | # of the "spec" file author to give correct arguments only. 111 | 112 | case $(echo "testing\c"),$(echo -n testing) in 113 | *c*,-n*) echo_n= echo_c= ;; 114 | *c*,*) echo_n=-n echo_c= ;; 115 | *) echo_n= echo_c='\c' ;; 116 | esac 117 | 118 | parse_server_arguments() { 119 | for arg; do 120 | case "$arg" in 121 | --basedir=*) 122 | basedir=$(echo "$arg" | sed -e 's/^[^=]*=//') 123 | bindir="$basedir/bin" 124 | if test -z "$datadir_set"; then 125 | datadir="$basedir/data" 126 | fi 127 | sbindir="$basedir/sbin" 128 | libexecdir="$basedir/libexec" 129 | ;; 130 | --datadir=*) 131 | datadir=$(echo "$arg" | sed -e 's/^[^=]*=//') 132 | datadir_set=1 133 | ;; 134 | --pid-file=*) mysqld_pid_file_path=$(echo "$arg" | sed -e 's/^[^=]*=//') ;; 135 | --service-startup-timeout=*) service_startup_timeout=$(echo "$arg" | sed -e 's/^[^=]*=//') ;; 136 | esac 137 | done 138 | } 139 | 140 | wait_for_pid() { 141 | verb="$1" # created | removed 142 | pid="$2" # process ID of the program operating on the pid-file 143 | pid_file_path="$3" # path to the PID file. 144 | 145 | i=0 146 | avoid_race_condition="by checking again" 147 | 148 | while test $i -ne $service_startup_timeout; do 149 | 150 | case "$verb" in 151 | 'created') 152 | # wait for a PID-file to pop into existence. 153 | test -s "$pid_file_path" && i='' && break 154 | ;; 155 | 'removed') 156 | # wait for this PID-file to disappear 157 | test ! -s "$pid_file_path" && i='' && break 158 | ;; 159 | *) 160 | echo "wait_for_pid () usage: wait_for_pid created|removed pid pid_file_path" 161 | exit 1 162 | ;; 163 | esac 164 | 165 | # if server isn't running, then pid-file will never be updated 166 | if test -n "$pid"; then 167 | if kill -0 "$pid" 2>/dev/null; then 168 | : # the server still runs 169 | else 170 | # The server may have exited between the last pid-file check and now. 171 | if test -n "$avoid_race_condition"; then 172 | avoid_race_condition="" 173 | continue # Check again. 174 | fi 175 | 176 | # there's nothing that will affect the file. 177 | log_failure_msg "The server quit without updating PID file ($pid_file_path)." 178 | return 1 # not waiting any more. 179 | fi 180 | fi 181 | 182 | echo $echo_n ".$echo_c" 183 | i=$(expr $i + 1) 184 | sleep 1 185 | 186 | done 187 | 188 | if test -z "$i"; then 189 | log_success_msg 190 | return 0 191 | else 192 | log_failure_msg 193 | return 1 194 | fi 195 | } 196 | 197 | # Get arguments from the my.cnf file, 198 | # the only group, which is read from now on is [mysqld] 199 | if test -x "$bindir/my_print_defaults"; then 200 | print_defaults="$bindir/my_print_defaults" 201 | else 202 | # Try to find basedir in /etc/my.cnf 203 | conf=/etc/my.cnf 204 | print_defaults= 205 | if test -r $conf; then 206 | subpat='^[^=]*basedir[^=]*=\(.*\)$' 207 | dirs=$(sed -e "/$subpat/!d" -e 's//\1/' $conf) 208 | for d in $dirs; do 209 | d=$(echo $d | sed -e 's/[ ]//g') 210 | if test -x "$d/bin/my_print_defaults"; then 211 | print_defaults="$d/bin/my_print_defaults" 212 | break 213 | fi 214 | done 215 | fi 216 | 217 | # Hope it's in the PATH ... but I doubt it 218 | test -z "$print_defaults" && print_defaults="my_print_defaults" 219 | fi 220 | 221 | # 222 | # Read defaults file from 'basedir'. If there is no defaults file there 223 | # check if it's in the old (depricated) place (datadir) and read it from there 224 | # 225 | 226 | extra_args="" 227 | if test -r "$basedir/my.cnf"; then 228 | extra_args="-e $basedir/my.cnf" 229 | fi 230 | 231 | parse_server_arguments $($print_defaults $extra_args mysqld server mysql_server mysql.server) 232 | 233 | # 234 | # Set pid file if not given 235 | # 236 | if test -z "$mysqld_pid_file_path"; then 237 | mysqld_pid_file_path=$datadir/$(hostname).pid 238 | else 239 | case "$mysqld_pid_file_path" in 240 | /*) ;; 241 | *) mysqld_pid_file_path="$datadir/$mysqld_pid_file_path" ;; 242 | esac 243 | fi 244 | 245 | case "$mode" in 246 | 'start') 247 | # Start daemon 248 | 249 | # Safeguard (relative paths, core dumps..) 250 | cd $basedir 251 | 252 | echo $echo_n "Starting MySQL" 253 | if test -x $bindir/mysqld_safe; then 254 | # Give extra arguments to mysqld with the my.cnf file. This script 255 | # may be overwritten at next upgrade. 256 | $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null & 257 | wait_for_pid created "$!" "$mysqld_pid_file_path" 258 | return_value=$? 259 | 260 | # Make lock for RedHat / SuSE 261 | if test -w "$lockdir"; then 262 | touch "$lock_file_path" 263 | fi 264 | 265 | exit $return_value 266 | else 267 | log_failure_msg "Couldn't find MySQL server ($bindir/mysqld_safe)" 268 | fi 269 | ;; 270 | 271 | 'stop') 272 | # Stop daemon. We use a signal here to avoid having to know the 273 | # root password. 274 | 275 | if test -s "$mysqld_pid_file_path"; then 276 | # signal mysqld_safe that it needs to stop 277 | touch "$mysqld_pid_file_path.shutdown" 278 | 279 | mysqld_pid=$(cat "$mysqld_pid_file_path") 280 | 281 | if (kill -0 $mysqld_pid 2>/dev/null); then 282 | echo $echo_n "Shutting down MySQL" 283 | kill $mysqld_pid 284 | # mysqld should remove the pid file when it exits, so wait for it. 285 | wait_for_pid removed "$mysqld_pid" "$mysqld_pid_file_path" 286 | return_value=$? 287 | else 288 | log_failure_msg "MySQL server process #$mysqld_pid is not running!" 289 | rm "$mysqld_pid_file_path" 290 | fi 291 | 292 | # Delete lock for RedHat / SuSE 293 | if test -f "$lock_file_path"; then 294 | rm -f "$lock_file_path" 295 | fi 296 | exit $return_value 297 | else 298 | log_failure_msg "MySQL server PID file could not be found!" 299 | fi 300 | ;; 301 | 302 | 'restart') 303 | # Stop the service and regardless of whether it was 304 | # running or not, start it again. 305 | if $0 stop $other_args; then 306 | $0 start $other_args 307 | else 308 | log_failure_msg "Failed to stop running server, so refusing to try to start." 309 | exit 1 310 | fi 311 | ;; 312 | 313 | 'reload' | 'force-reload') 314 | if test -s "$mysqld_pid_file_path"; then 315 | read mysqld_pid <"$mysqld_pid_file_path" 316 | kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL" 317 | touch "$mysqld_pid_file_path" 318 | else 319 | log_failure_msg "MySQL PID file could not be found!" 320 | exit 1 321 | fi 322 | ;; 323 | 'status') 324 | # First, check to see if pid file exists 325 | if test -s "$mysqld_pid_file_path"; then 326 | read mysqld_pid <"$mysqld_pid_file_path" 327 | if kill -0 $mysqld_pid 2>/dev/null; then 328 | log_success_msg "MySQL running ($mysqld_pid)" 329 | exit 0 330 | else 331 | log_failure_msg "MySQL is not running, but PID file exists" 332 | exit 1 333 | fi 334 | else 335 | # Try to find appropriate mysqld process 336 | mysqld_pid=$(pidof $libexecdir/mysqld) 337 | 338 | # test if multiple pids exist 339 | pid_count=$(echo $mysqld_pid | wc -w) 340 | if test $pid_count -gt 1; then 341 | log_failure_msg "Multiple MySQL running but PID file could not be found ($mysqld_pid)" 342 | exit 5 343 | elif test -z $mysqld_pid; then 344 | if test -f "$lock_file_path"; then 345 | log_failure_msg "MySQL is not running, but lock file ($lock_file_path) exists" 346 | exit 2 347 | fi 348 | log_failure_msg "MySQL is not running" 349 | exit 3 350 | else 351 | log_failure_msg "MySQL is running but PID file could not be found" 352 | exit 4 353 | fi 354 | fi 355 | ;; 356 | *) 357 | # usage 358 | basename=$(basename "$0") 359 | echo "Usage: $basename {start|stop|restart|reload|force-reload|status} [ MySQL server options ]" 360 | exit 1 361 | ;; 362 | esac 363 | 364 | exit 0 365 | -------------------------------------------------------------------------------- /general/init.d/nginx: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # nginx - this script starts and stops the nginx daemon 4 | # 5 | # chkconfig: - 85 15 6 | # description: Nginx is an HTTP(S) server, HTTP(S) reverse \ 7 | # proxy and IMAP/POP3 proxy server 8 | # processname: nginx 9 | # config: /usr/local/nginx/conf/nginx.conf 10 | # pidfile: /var/run/nginx.pid 11 | 12 | # Source function library. 13 | . /etc/rc.d/init.d/functions 14 | 15 | # Source networking configuration. 16 | . /etc/sysconfig/network 17 | 18 | # Check that networking is up. 19 | [ "$NETWORKING" = "no" ] && exit 0 20 | 21 | nginx="/usr/local/nginx/sbin/nginx" 22 | prog=$(basename $nginx) 23 | 24 | NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" 25 | 26 | [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx 27 | 28 | lockfile=/var/lock/subsys/nginx 29 | 30 | make_dirs() { 31 | # make required directories 32 | user=$($nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -) 33 | if [ -z "$(grep "$user" /etc/passwd)" ]; then 34 | useradd -M -s /bin/nologin "$user" 35 | fi 36 | options=$($nginx -V 2>&1 | grep 'configure arguments:') 37 | for opt in $options; do 38 | if [ $(echo "$opt" | grep '.*-temp-path') ]; then 39 | value=$(echo "$opt" | cut -d "=" -f 2) 40 | if [ ! -d "$value" ]; then 41 | # echo "creating" $value 42 | mkdir -p "$value" && chown -R "$user" "$value" 43 | fi 44 | fi 45 | done 46 | } 47 | 48 | start() { 49 | [ -x $nginx ] || exit 5 50 | [ -f $NGINX_CONF_FILE ] || exit 6 51 | make_dirs 52 | echo -n "Starting $prog: " 53 | daemon $nginx -c $NGINX_CONF_FILE 54 | retval=$? 55 | echo 56 | [ $retval -eq 0 ] && touch $lockfile 57 | return $retval 58 | } 59 | 60 | stop() { 61 | echo -n "Stopping $prog: " 62 | killproc "$prog" -QUIT 63 | retval=$? 64 | echo 65 | [ $retval -eq 0 ] && rm -f $lockfile 66 | return $retval 67 | } 68 | 69 | restart() { 70 | configtest || return $? 71 | stop 72 | sleep 3 73 | start 74 | } 75 | 76 | reload() { 77 | configtest || return $? 78 | echo -n "Reloading $prog: " 79 | killproc $nginx -HUP 80 | RETVAL=$? 81 | echo 82 | } 83 | 84 | force_reload() { 85 | restart 86 | } 87 | 88 | configtest() { 89 | $nginx -t -c $NGINX_CONF_FILE 90 | } 91 | 92 | rh_status() { 93 | status "$prog" 94 | } 95 | 96 | rh_status_q() { 97 | rh_status >/dev/null 2>&1 98 | } 99 | 100 | case "$1" in 101 | start) 102 | rh_status_q && exit 0 103 | $1 104 | ;; 105 | stop) 106 | rh_status_q || exit 0 107 | $1 108 | ;; 109 | restart | configtest) 110 | $1 111 | ;; 112 | reload) 113 | rh_status_q || exit 7 114 | $1 115 | ;; 116 | force-reload) 117 | force_reload 118 | ;; 119 | status) 120 | rh_status 121 | ;; 122 | condrestart | try-restart) 123 | rh_status_q || exit 0 124 | ;; 125 | *) 126 | echo "Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" 127 | exit 2 128 | ;; 129 | esac 130 | -------------------------------------------------------------------------------- /general/init.d/php80-fpm: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | ### BEGIN INIT INFO 4 | # Provides: php80-fpm 5 | # Required-Start: $remote_fs $network 6 | # Required-Stop: $remote_fs $network 7 | # Default-Start: 2 3 4 5 8 | # Default-Stop: 0 1 6 9 | # Short-Description: starts php-fpm 10 | # Description: starts the PHP FastCGI Process Manager daemon 11 | ### END INIT INFO 12 | 13 | umask 0002 14 | 15 | prefix=/usr/local/php80 16 | exec_prefix=${prefix} 17 | 18 | php_fpm_BIN=${exec_prefix}/sbin/php-fpm 19 | php_fpm_CONF=${prefix}/etc/php-fpm.conf 20 | php_fpm_PID=${prefix}/var/run/php-fpm.pid 21 | 22 | php_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID" 23 | 24 | wait_for_pid() { 25 | try=0 26 | 27 | while test "$try" -lt 35; do 28 | 29 | case "$1" in 30 | 'created') 31 | if [ -f "$2" ]; then 32 | try='' 33 | break 34 | fi 35 | ;; 36 | 37 | 'removed') 38 | if [ ! -f "$2" ]; then 39 | try='' 40 | break 41 | fi 42 | ;; 43 | esac 44 | 45 | echo -n . 46 | try=$(expr $try + 1) 47 | sleep 1 48 | 49 | done 50 | 51 | } 52 | 53 | case "$1" in 54 | start) 55 | echo -n "Starting php-fpm " 56 | 57 | $php_fpm_BIN --daemonize $php_opts 58 | 59 | if [ "$?" != 0 ]; then 60 | echo " failed" 61 | exit 1 62 | fi 63 | 64 | wait_for_pid created $php_fpm_PID 65 | 66 | if [ -n "$try" ]; then 67 | echo " failed" 68 | exit 1 69 | else 70 | echo " done" 71 | fi 72 | ;; 73 | 74 | stop) 75 | echo -n "Gracefully shutting down php-fpm " 76 | 77 | if [ ! -r $php_fpm_PID ]; then 78 | echo "warning, no pid file found - php-fpm is not running ?" 79 | exit 1 80 | fi 81 | 82 | kill -QUIT "$(cat $php_fpm_PID)" 83 | 84 | wait_for_pid removed $php_fpm_PID 85 | 86 | if [ -n "$try" ]; then 87 | echo " failed. Use force-quit" 88 | exit 1 89 | else 90 | echo " done" 91 | fi 92 | ;; 93 | 94 | status) 95 | if [ ! -r $php_fpm_PID ]; then 96 | echo "php-fpm is stopped" 97 | exit 0 98 | fi 99 | 100 | PID="$(cat $php_fpm_PID)" 101 | if ps -p "$PID" | grep -q "$PID"; then 102 | echo "php-fpm (pid $PID) is running..." 103 | else 104 | echo "php-fpm dead but pid file exists" 105 | fi 106 | ;; 107 | 108 | force-quit) 109 | echo -n "Terminating php-fpm " 110 | 111 | if [ ! -r $php_fpm_PID ]; then 112 | echo "warning, no pid file found - php-fpm is not running ?" 113 | exit 1 114 | fi 115 | 116 | kill -TERM "$(cat $php_fpm_PID)" 117 | 118 | wait_for_pid removed $php_fpm_PID 119 | 120 | if [ -n "$try" ]; then 121 | echo " failed" 122 | exit 1 123 | else 124 | echo " done" 125 | fi 126 | ;; 127 | 128 | restart) 129 | $0 stop 130 | $0 start 131 | ;; 132 | 133 | reload) 134 | 135 | echo -n "Reload service php-fpm " 136 | 137 | if [ ! -r $php_fpm_PID ]; then 138 | echo "warning, no pid file found - php-fpm is not running ?" 139 | exit 1 140 | fi 141 | 142 | kill -USR2 ""$(cat $php_fpm_PID)"" 143 | 144 | echo " done" 145 | ;; 146 | 147 | configtest) 148 | $php_fpm_BIN -t 149 | ;; 150 | 151 | *) 152 | echo "Usage: $0 {start|stop|force-quit|restart|reload|status|configtest}" 153 | exit 1 154 | ;; 155 | 156 | esac 157 | -------------------------------------------------------------------------------- /general/init.d/redis-server: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | ### BEGIN INIT INFO 3 | # Provides: redis-server 4 | # Required-Start: $syslog 5 | # Required-Stop: $syslog 6 | # Should-Start: $local_fs 7 | # Should-Stop: $local_fs 8 | # Default-Start: 2 3 4 5 9 | # Default-Stop: 0 1 6 10 | # Short-Description: redis-server - Persistent key-value db 11 | # Description: redis-server - Persistent key-value db 12 | ### END INIT INFO 13 | 14 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 15 | DAEMON=/usr/local/redis/bin/redis-server 16 | DAEMON_ARGS=/usr/local/redis/etc/redis.conf 17 | NAME=redis-server 18 | DESC=redis-server 19 | PIDFILE=/var/run/redis.pid 20 | 21 | test -x $DAEMON || exit 0 22 | test -x $DAEMONBOOTSTRAP || exit 0 23 | 24 | set -e 25 | 26 | case "$1" in 27 | start) 28 | echo -n "Starting $DESC: " 29 | touch $PIDFILE 30 | chown redis:redis $PIDFILE 31 | if start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid redis:redis --exec $DAEMON -- $DAEMON_ARGS; then 32 | echo "[OK]" 33 | else 34 | echo "failed" 35 | fi 36 | ;; 37 | stop) 38 | echo -n "Stopping $DESC: " 39 | if start-stop-daemon --stop --retry 10 --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON; then 40 | echo "[OK]" 41 | else 42 | echo "failed" 43 | fi 44 | rm -f $PIDFILE 45 | ;; 46 | 47 | restart | force-reload) 48 | ${0} stop 49 | ${0} start 50 | ;; 51 | *) 52 | echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2 53 | exit 1 54 | ;; 55 | esac 56 | 57 | exit 0 58 | -------------------------------------------------------------------------------- /general/mintty_themes/jfcherng: -------------------------------------------------------------------------------- 1 | # put this file in "C:\Program Files\Git\usr\share\mintty\themes\jfcherng" 2 | 3 | ForegroundColour= 236, 240, 241 4 | BackgroundColour= 12, 12, 12 5 | CursorColour= 217, 217, 217 6 | BoldBlack= 52, 73, 94 7 | Black= 44, 62, 80 8 | BoldRed= 231, 76, 60 9 | Red= 192, 57, 43 10 | BoldGreen= 46, 204, 113 11 | Green= 39, 174, 96 12 | BoldYellow= 241, 196, 15 13 | Yellow= 243, 156, 18 14 | BoldBlue= 52, 152, 219 15 | Blue= 41, 128, 185 16 | BoldMagenta= 175, 109, 202 17 | Magenta= 162, 88, 193 18 | BoldCyan= 71, 207, 197 19 | Cyan= 42, 161, 152 20 | BoldWhite= 236, 240, 241 21 | White= 189, 195, 199 22 | -------------------------------------------------------------------------------- /general/web_server/compile_nginx.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #------------------------------------------# 4 | # This script compiles the latest NGINX. # 5 | # # 6 | # Author: Jack Cherng # 7 | #------------------------------------------# 8 | 9 | SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" 10 | THREAD_CNT=$(getconf _NPROCESSORS_ONLN) 11 | NGINX_FLAGS=() 12 | 13 | NOW="$(date +%Y%m%d%H%M%S)" 14 | LOG_FILE="${SCRIPT_DIR}/compile_nginx-${NOW}.log" 15 | 16 | function git_repo_clean { 17 | make clean >/dev/null 2>&1 18 | git clean -dfx 19 | git checkout -- . 20 | } 21 | 22 | #--------# 23 | # config # 24 | #--------# 25 | 26 | NGINX_INSTALL_DIR="/usr/local/nginx" 27 | OPENSSL_VERSION="3.5.0" 28 | 29 | # the command used to clone a repo 30 | declare -A NGINX_CMD=( 31 | ["nginx"]="git clone https://github.com/nginx/nginx.git nginx" 32 | # modules 33 | ["ngx_brotli"]="git clone https://github.com/google/ngx_brotli.git ngx_brotli" 34 | ["ngx_headers_more"]="git clone https://github.com/openresty/headers-more-nginx-module.git ngx_headers_more" 35 | ["ngx_http_concat"]="git clone https://github.com/alibaba/nginx-http-concat.git ngx_http_concat" 36 | ["ngx_http_trim"]="git clone https://github.com/taoyuanyuan/ngx_http_trim_filter_module.git ngx_http_trim" 37 | ["ngx_njs"]="git clone https://github.com/nginx/njs.git ngx_njs" 38 | ) 39 | 40 | # checkout repo to a specific commit before compilation 41 | declare -A NGINX_MODULES_CHECKOUT=( 42 | # modules 43 | ["ngx_njs"]="tags/0.8.10" 44 | ) 45 | 46 | { 47 | 48 | #-------# 49 | # begin # 50 | #-------# 51 | 52 | pushd "${SCRIPT_DIR}" || exit 53 | 54 | # prefer the latest user-installed libs if possible 55 | PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:${PKG_CONFIG_PATH}" 56 | 57 | #-------------# 58 | # check repos # 59 | #-------------# 60 | 61 | for repoName in "${!NGINX_CMD[@]}"; do 62 | # clone new repos 63 | if [ ! -d "${repoName}/.git" ]; then 64 | rm -rf "${repoName}" 65 | eval "${NGINX_CMD[${repoName}]}" || exit 66 | fi 67 | 68 | pushd "${repoName}" || exit 69 | 70 | git_repo_clean 71 | 72 | # fetch the latest source 73 | git fetch --tags --force --prune --all && git reset --hard "@{upstream}" 74 | git submodule update --init 75 | git submodule foreach --recursive git pull 76 | 77 | # checkout a specific commit if required 78 | commit=${NGINX_MODULES_CHECKOUT[${repoName}]} 79 | if [ "${commit}" != "" ]; then 80 | git checkout -f "${commit}" 81 | fi 82 | 83 | popd || exit 84 | done 85 | 86 | #---------------# 87 | # check openssl # 88 | #---------------# 89 | 90 | # install dependencies 91 | if command -v yum &>/dev/null; then 92 | yum install -y --skip-broken perl-IPC-Cmd 93 | elif command -v dnf &>/dev/null; then 94 | dnf install -y perl-IPC-Cmd 95 | fi 96 | 97 | openssl_tarball="openssl-${OPENSSL_VERSION}.tar.gz" 98 | openssl_src_dir="openssl-${OPENSSL_VERSION}" 99 | if [ ! -d "${openssl_src_dir}" ]; then 100 | rm -rf -- openssl-* # remove downloaded old libs 101 | 102 | curl -O -L "https://github.com/openssl/openssl/releases/download/openssl-${OPENSSL_VERSION}/${openssl_tarball}" 103 | 104 | if [ ! -s "${openssl_tarball}" ]; then 105 | echo "Failed to download OpenSSL tarball..." 106 | exit 1 107 | fi 108 | 109 | tar xf "${openssl_tarball}" 110 | 111 | # GitHub's release has an extra prefixed "openssl-", we remove it 112 | mv -f "openssl-${openssl_src_dir}" "${openssl_src_dir}" 113 | fi 114 | 115 | #----------------# 116 | # check jemalloc # 117 | #----------------# 118 | 119 | if command -v jemalloc-config >/dev/null 2>&1; then 120 | echo "[*] Compile NGINX with jemalloc" 121 | NGINX_FLAGS+=("--with-ld-opt='-ljemalloc'") 122 | fi 123 | 124 | #---------------# 125 | # compile NGINX # 126 | #---------------# 127 | 128 | echo "===================================" 129 | echo "Begin compile 'NGINX'..." 130 | echo "===================================" 131 | 132 | pushd nginx || exit 133 | 134 | # to load compiled dynamic modules, add the following at the very top of the main NGINX config file: 135 | # load_module modules/ngx_http_brotli_filter_module.so; 136 | # load_module modules/ngx_http_brotli_static_module.so; 137 | # load_module modules/ngx_http_headers_more_filter_module.so; 138 | # load_module modules/ngx_http_js_module.so; 139 | 140 | ./auto/configure \ 141 | --prefix=/usr/local/nginx \ 142 | --user=www \ 143 | --group=www \ 144 | --with-openssl="${SCRIPT_DIR}/${openssl_src_dir}" \ 145 | `# built-in modules` \ 146 | --with-http_flv_module \ 147 | --with-http_gzip_static_module \ 148 | --with-http_realip_module \ 149 | --with-http_ssl_module \ 150 | --with-http_stub_status_module \ 151 | --with-http_v2_module \ 152 | `# 3rd-party modules` \ 153 | --add-dynamic-module="${SCRIPT_DIR}/ngx_brotli" \ 154 | --add-dynamic-module="${SCRIPT_DIR}/ngx_headers_more" \ 155 | --add-dynamic-module="${SCRIPT_DIR}/ngx_http_concat" \ 156 | --add-dynamic-module="${SCRIPT_DIR}/ngx_http_trim" \ 157 | --add-dynamic-module="${SCRIPT_DIR}/ngx_njs/nginx" \ 158 | ${NGINX_FLAGS[@]} 159 | 160 | make -j"${THREAD_CNT}" install || exit 161 | git_repo_clean 162 | 163 | popd || exit 164 | 165 | echo "===================================" 166 | echo "End compile 'NGINX'..." 167 | echo "===================================" 168 | 169 | #-----# 170 | # end # 171 | #-----# 172 | 173 | # try to restart the daemon if NGINX works normally 174 | if "${NGINX_INSTALL_DIR}/sbin/nginx" -V; then 175 | daemon="/etc/init.d/nginx" 176 | 177 | [[ -x ${daemon} ]] && "${daemon}" restart 178 | fi 179 | 180 | popd || exit 181 | 182 | } 2>&1 | tee "${LOG_FILE}" 183 | -------------------------------------------------------------------------------- /general/web_server/compile_percona_server.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #---------------------------------------------------# 4 | # This script compiles the latest Percona server. # 5 | # # 6 | # Author: Jack Cherng # 7 | #---------------------------------------------------# 8 | 9 | SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" 10 | THREAD_CNT=$(getconf _NPROCESSORS_ONLN) 11 | 12 | NOW="$(date +%Y%m%d%H%M%S)" 13 | LOG_FILE="${SCRIPT_DIR}/compile_percona_server-${NOW}.log" 14 | 15 | APP_NAME=Percona-Server-8.0.23-14 16 | TAR_FILE_BASENAME=${APP_NAME,,} 17 | TAR_FILE_NAME=${TAR_FILE_BASENAME}.tar.gz 18 | 19 | INSTALL_DIR=/usr/local/mysql 20 | 21 | function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; } 22 | 23 | { 24 | 25 | #-------------------# 26 | # check gcc version # 27 | #-------------------# 28 | 29 | GCC_MIN_VERSION=4.9.0 30 | if [ "$(version "$(gcc -dumpversion)")" -lt "$(version "${GCC_MIN_VERSION}")" ]; then 31 | echo "[*] GCC must be newer than ${GCC_MIN_VERSION}" 32 | exit 1 33 | fi 34 | 35 | #--------------# 36 | # install deps # 37 | #--------------# 38 | 39 | yum install -y \ 40 | scons socat openssl check cmake3 bison \ 41 | boost-devel asio-devel libaio-devel ncurses-devel \ 42 | readline-devel pam-devel libcurl-devel 43 | 44 | #-------# 45 | # begin # 46 | #-------# 47 | 48 | pushd "${SCRIPT_DIR}" || exit 49 | 50 | # prefer the latest user-installed libs if possible 51 | PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:${PKG_CONFIG_PATH}" 52 | 53 | #---------------------# 54 | # download the source # 55 | #---------------------# 56 | 57 | wget "https://www.percona.com/downloads/Percona-Server-LATEST/${APP_NAME}/source/tarball/${TAR_FILE_NAME}" -O "${TAR_FILE_NAME}" 58 | tar xf "${TAR_FILE_NAME}" 59 | 60 | #-----------------# 61 | # compile Percona # 62 | #-----------------# 63 | 64 | pushd "${TAR_FILE_BASENAME}" || exit 65 | 66 | rm -rf my_build && mkdir -p my_build 67 | pushd my_build || exit 68 | 69 | cmake .. \ 70 | -DCMAKE_INSTALL_PREFIX:PATH="${INSTALL_DIR}" \ 71 | -DDOWNLOAD_BOOST=1 -DWITH_BOOST="$(pwd)/boost" \ 72 | -DCMAKE_BUILD_TYPE=RelWithDebInfo \ 73 | -DBUILD_CONFIG=mysql_release \ 74 | -DFEATURE_SET=community 75 | 76 | # it's quite possible that we run out of memory, so -j2 77 | make -j2 || exit 78 | make install || exit 79 | 80 | popd || exit 81 | 82 | popd || exit 83 | 84 | #-----# 85 | # end # 86 | #-----# 87 | 88 | "${INSTALL_DIR}/bin/mysql" -V || exit 89 | 90 | groupadd mysql 91 | useradd -g mysql -s /sbin/nologin -M mysql 92 | 93 | mkdir -p /data/mysql 94 | chown mysql.mysql -R /data/mysql 95 | 96 | popd || exit 97 | 98 | } | tee "${LOG_FILE}" 99 | -------------------------------------------------------------------------------- /general/web_server/compile_percona_server_my.cnf: -------------------------------------------------------------------------------- 1 | [client] 2 | port = 3306 3 | default-character-set = utf8mb4 4 | 5 | [mysql] 6 | prompt="MySQL [\d]> " 7 | no-auto-rehash 8 | default-character-set = utf8mb4 9 | 10 | [mysqld] 11 | port = 3306 12 | socket = /dev/shm/mysql.sock 13 | mysqlx_socket = /dev/shm/mysqlx.sock 14 | 15 | basedir = /usr/local/mysql 16 | datadir = /data/mysql 17 | pid-file = /data/mysql/mysql.pid 18 | log_error = /data/mysql/mysql-error.log 19 | slow_query_log_file = /data/mysql/mysql-slow.log 20 | lc-messages-dir = /usr/local/mysql/share/english 21 | 22 | user = mysql 23 | # bind-address = 0.0.0.0 24 | server-id = 1 25 | 26 | init-connect = 'SET NAMES utf8mb4' 27 | collation-server = utf8mb4_unicode_ci 28 | character-set-server = utf8mb4 29 | default_authentication_plugin= mysql_native_password 30 | # sql-mode = "ERROR_FOR_DIVISION_BY_ZERO,NO_ZERO_DATE,NO_ZERO_IN_DATE,NO_AUTO_CREATE_USER" 31 | 32 | skip-name-resolve 33 | # skip-networking 34 | back_log = 300 35 | 36 | max_connections = 996 37 | max_connect_errors = 6000 38 | open_files_limit = 65535 39 | table_open_cache = 256 40 | max_allowed_packet = 500M 41 | binlog_cache_size = 1M 42 | max_heap_table_size = 8M 43 | tmp_table_size = 32M 44 | 45 | read_buffer_size = 2M 46 | read_rnd_buffer_size = 8M 47 | sort_buffer_size = 8M 48 | join_buffer_size = 8M 49 | key_buffer_size = 16M 50 | 51 | thread_cache_size = 16 52 | 53 | # query_cache_type = 1 54 | # query_cache_size = 16M 55 | # query_cache_limit = 2M 56 | 57 | ft_min_word_len = 4 58 | 59 | log_bin = mysql-bin 60 | binlog_format = mixed 61 | binlog_expire_logs_seconds = 604800 62 | # expire_logs_days = 7 63 | slow_query_log = 1 64 | long_query_time = 1 65 | 66 | performance_schema = 0 67 | explicit_defaults_for_timestamp 68 | 69 | # https://dev.mysql.com/doc/refman/8.0/en/identifier-case-sensitivity.html 70 | lower_case_table_names = 2 71 | 72 | skip-external-locking 73 | 74 | default_storage_engine = InnoDB 75 | innodb_file_per_table = 1 76 | innodb_open_files = 500 77 | innodb_buffer_pool_size = 128M 78 | innodb_write_io_threads = 4 79 | innodb_read_io_threads = 4 80 | innodb_thread_concurrency = 0 81 | innodb_purge_threads = 1 82 | innodb_flush_log_at_trx_commit = 2 83 | innodb_log_buffer_size = 2M 84 | innodb_log_file_size = 32M 85 | innodb_log_files_in_group = 3 86 | innodb_max_dirty_pages_pct = 90 87 | innodb_lock_wait_timeout = 120 88 | 89 | bulk_insert_buffer_size = 8M 90 | myisam_sort_buffer_size = 16M 91 | myisam_max_sort_file_size = 10G 92 | myisam_repair_threads = 1 93 | 94 | interactive_timeout = 28800 95 | wait_timeout = 28800 96 | 97 | [mysqldump] 98 | quick 99 | max_allowed_packet = 500M 100 | 101 | [myisamchk] 102 | key_buffer_size = 16M 103 | sort_buffer_size = 8M 104 | read_buffer = 4M 105 | write_buffer = 4M 106 | -------------------------------------------------------------------------------- /general/web_server/compile_php56.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #------------------------------------------# 4 | # This script compiles PHP 5.6. # 5 | # # 6 | # Author: Jack Cherng # 7 | #------------------------------------------# 8 | 9 | SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" 10 | THREAD_CNT=$(getconf _NPROCESSORS_ONLN) 11 | MEMSIZE_MB=$(free -m | awk '/^Mem:/{print $2}') 12 | 13 | NOW="$(date +%Y%m%d%H%M%S)" 14 | LOG_FILE="${SCRIPT_DIR}/compile_php56-${NOW}.log" 15 | 16 | { 17 | 18 | #----------------# 19 | # configurations # 20 | #----------------# 21 | 22 | php_version="latest" 23 | bison_version="2.7.1" 24 | 25 | # get the exact latest 5.6 version number 26 | if [ "${php_version,,}" = 'latest' ]; then 27 | # get something like "5.6.40" 28 | php_version=$( 29 | curl -s -k 'https://api.github.com/repos/php/php-src/git/refs/tags' | 30 | python -m json.tool | 31 | command grep -Pio 'php-5.6.[0-9]+((alpha|beta|rc)[0-9]*)?' | 32 | uniq | 33 | tail -1 | 34 | # remove leading "php-" 35 | cut -b 5- 36 | ) 37 | 38 | echo "[*] The latest PHP 5.6 version is ${php_version}" 39 | fi 40 | 41 | # such as "5.6.39" => "56" 42 | php_version_path=$(echo "${php_version}" | sed -r 's/^([0-9]+)(\.([0-9]+))?.*$/\1\3/g') 43 | 44 | php_run_user="www" 45 | php_install_dir="/usr/local/php${php_version_path}" 46 | php_src_dir="php-${php_version}" 47 | 48 | #----------------------# 49 | # install dependencies # 50 | #----------------------# 51 | 52 | yum install -y \ 53 | aspell-devel \ 54 | bzip2 bzip2-devel \ 55 | curl curl-devel \ 56 | freetype-devel \ 57 | gmp-devel \ 58 | icu libicu libicu-devel \ 59 | libc-client uw-imap-devel \ 60 | libjpeg-devel libpng-devel libwebp-devel \ 61 | libmcrypt-devel \ 62 | libssh2-devel \ 63 | libtidy-devel \ 64 | libxml2 libxml2-devel \ 65 | libxslt libxslt-devel \ 66 | ncurses ncurses-devel \ 67 | openldap-devel \ 68 | pcre-devel \ 69 | readline-devel 70 | 71 | #-----------------# 72 | # fix lib linking # 73 | #-----------------# 74 | 75 | ln -sfn /usr/lib64/libldap* /usr/lib/ 76 | ln -sfn /usr/lib64/liblber* /usr/lib/ 77 | 78 | ldconfig 79 | 80 | #-------# 81 | # begin # 82 | #-------# 83 | 84 | pushd "${SCRIPT_DIR}" || exit 85 | 86 | # prefer the latest user-installed libs if possible 87 | PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:${PKG_CONFIG_PATH}" 88 | 89 | #-------------------------------# 90 | # compile old bison for PHP 5.6 # 91 | #-------------------------------# 92 | 93 | bison_bin_dir="$(pwd)/bison-${bison_version}/build/bin" 94 | if [ ! -f "${bison_bin_dir}/bison" ]; then 95 | bison_tarball="bison-${bison_version}.tar.gz" 96 | 97 | # remove possibly corrupted old tarball 98 | rm -f "${bison_tarball}" 99 | 100 | wget --no-check-certificate "https://ftp.gnu.org/gnu/bison/${bison_tarball}" 101 | 102 | if [ ! -s "${bison_tarball}" ]; then 103 | echo "Failed to download bison tarball from GitHub..." 104 | exit 1 105 | fi 106 | 107 | tar xf "${bison_tarball}" 108 | 109 | pushd "bison-${bison_version}" || exit 110 | 111 | mkdir -p build 112 | ./configure --prefix="$(pwd)/build" 113 | make -j"${THREAD_CNT}" && make install 114 | 115 | popd || exit 116 | fi 117 | 118 | # prefer using older bison 119 | if ! bison --version | grep -F -q "${bison_version}"; then 120 | echo "[*] temporarily set bison executable into PATH" 121 | PATH="${bison_bin_dir}:${PATH}" 122 | fi 123 | 124 | #-------------# 125 | # compile PHP # 126 | #-------------# 127 | 128 | php_tarball="${php_src_dir}.tar.gz" 129 | 130 | if [ ! -f "${php_tarball}" ]; then 131 | wget --no-check-certificate "https://github.com/php/php-src/archive/${php_tarball}" 132 | fi 133 | 134 | gzip -t "${php_tarball}" 135 | if [ $? -ne 0 ]; then 136 | echo "${php_tarball} is unusable... Please try this script again." 137 | rm -f "${php_tarball}" 138 | exit 1 139 | fi 140 | 141 | # always compile from a fresh state 142 | rm -rf "${php_src_dir}" 143 | tar xf "${php_tarball}" 144 | mv "php-src-${php_src_dir}" "${php_src_dir}" 145 | 146 | LOW_MEMORY_FLAGS=() 147 | 148 | if [ "${MEMSIZE_MB}" -lt "256" ]; then 149 | LOW_MEMORY_FLAGS+=('--disable-fileinfo') 150 | fi 151 | 152 | ZEND_EXTRA_LIBS=() 153 | 154 | # if we could link to the iconv library, add a flag for it 155 | if ldconfig -p | grep libiconv >/dev/null 2>&1; then 156 | ZEND_EXTRA_LIBS+=('-liconv') 157 | fi 158 | 159 | # if we could link to the LDAP library, add a flag for it 160 | if ldconfig -p | grep liblber >/dev/null 2>&1; then 161 | ZEND_EXTRA_LIBS+=('-llber') 162 | fi 163 | 164 | pushd "${php_src_dir}" || exit 165 | 166 | ./buildconf --force 167 | 168 | ./configure \ 169 | --prefix="${php_install_dir}" \ 170 | --disable-debug \ 171 | --disable-rpath \ 172 | --enable-bcmath \ 173 | --enable-calendar \ 174 | --enable-exif \ 175 | --enable-fpm \ 176 | --enable-ftp \ 177 | --enable-inline-optimization \ 178 | --enable-intl \ 179 | --enable-mbregex --enable-mbstring \ 180 | --enable-pcntl \ 181 | --enable-shmop \ 182 | --enable-soap \ 183 | --enable-sockets \ 184 | --enable-sysvmsg --enable-sysvsem --enable-sysvshm \ 185 | --enable-wddx \ 186 | --enable-xml \ 187 | --enable-zip \ 188 | --with-bz2 \ 189 | --with-config-file-path="${php_install_dir}/etc" \ 190 | --with-config-file-scan-dir="${php_install_dir}/etc/php.d" \ 191 | --with-curl="/usr/local" \ 192 | --with-fpm-group="${php_run_user}" \ 193 | --with-fpm-user="${php_run_user}" \ 194 | --with-gd --with-freetype-dir --with-jpeg-dir --with-png-dir --enable-gd-native-ttf \ 195 | --with-gettext \ 196 | --with-gmp \ 197 | --with-iconv-dir="/usr/local" \ 198 | --with-imap --with-kerberos --with-imap-ssl --with-libdir="lib64" \ 199 | --with-libxml-dir="/usr" \ 200 | --with-libzip \ 201 | --with-mhash \ 202 | --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd \ 203 | --with-openssl \ 204 | --with-pspell \ 205 | --with-readline \ 206 | --with-xmlrpc \ 207 | --with-xsl \ 208 | --with-zlib \ 209 | ${LOW_MEMORY_FLAGS[*]} 210 | 211 | # PEAR is no longer maintained, ignore errors about PEAR 212 | sed -i"" -E "s/^(install-pear):/.IGNORE: \1\n\1:/g" ./Makefile 213 | 214 | make -j"${THREAD_CNT}" install ZEND_EXTRA_LIBS="${ZEND_EXTRA_LIBS[*]}" || exit 215 | make clean 216 | 217 | popd || exit 218 | 219 | #-----# 220 | # end # 221 | #-----# 222 | 223 | "${php_install_dir}/bin/php" -v 224 | 225 | # try to restart the daemon if PHP works normally 226 | if [ $? -eq 0 ]; then 227 | daemon="/etc/init.d/php${php_version_path}-fpm" 228 | 229 | [ -x "${daemon}" ] && "${daemon}" restart 230 | fi 231 | 232 | popd || exit 233 | 234 | } | tee "${LOG_FILE}" 235 | -------------------------------------------------------------------------------- /general/web_server/compile_php7.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | 3 | ;;;;;;;;;;;;;;;;;;; 4 | ; About php.ini ; 5 | ;;;;;;;;;;;;;;;;;;; 6 | ; PHP's initialization file, generally called php.ini, is responsible for 7 | ; configuring many of the aspects of PHP's behavior. 8 | 9 | ; PHP attempts to find and load this configuration from a number of locations. 10 | ; The following is a summary of its search order: 11 | ; 1. SAPI module specific location. 12 | ; 2. The PHPRC environment variable. (As of PHP 5.2.0) 13 | ; 3. A number of predefined registry keys on Windows (As of PHP 5.2.0) 14 | ; 4. Current working directory (except CLI) 15 | ; 5. The web server's directory (for SAPI modules), or directory of PHP 16 | ; (otherwise in Windows) 17 | ; 6. The directory from the --with-config-file-path compile time option, or the 18 | ; Windows directory (C:\windows or C:\winnt) 19 | ; See the PHP docs for more specific information. 20 | ; http://php.net/configuration.file 21 | 22 | ; The syntax of the file is extremely simple. Whitespace and lines 23 | ; beginning with a semicolon are silently ignored (as you probably guessed). 24 | ; Section headers (e.g. [Foo]) are also silently ignored, even though 25 | ; they might mean something in the future. 26 | 27 | ; Directives following the section heading [PATH=/www/mysite] only 28 | ; apply to PHP files in the /www/mysite directory. Directives 29 | ; following the section heading [HOST=www.example.com] only apply to 30 | ; PHP files served from www.example.com. Directives set in these 31 | ; special sections cannot be overridden by user-defined INI files or 32 | ; at runtime. Currently, [PATH=] and [HOST=] sections only work under 33 | ; CGI/FastCGI. 34 | ; http://php.net/ini.sections 35 | 36 | ; Directives are specified using the following syntax: 37 | ; directive = value 38 | ; Directive names are *case sensitive* - foo=bar is different from FOO=bar. 39 | ; Directives are variables used to configure PHP or PHP extensions. 40 | ; There is no name validation. If PHP can't find an expected 41 | ; directive because it is not set or is mistyped, a default value will be used. 42 | 43 | ; The value can be a string, a number, a PHP constant (e.g. E_ALL or M_PI), one 44 | ; of the INI constants (On, Off, True, False, Yes, No and None) or an expression 45 | ; (e.g. E_ALL & ~E_NOTICE), a quoted string ("bar"), or a reference to a 46 | ; previously set variable or directive (e.g. ${foo}) 47 | 48 | ; Expressions in the INI file are limited to bitwise operators and parentheses: 49 | ; | bitwise OR 50 | ; ^ bitwise XOR 51 | ; & bitwise AND 52 | ; ~ bitwise NOT 53 | ; ! boolean NOT 54 | 55 | ; Boolean flags can be turned on using the values 1, On, True or Yes. 56 | ; They can be turned off using the values 0, Off, False or No. 57 | 58 | ; An empty string can be denoted by simply not writing anything after the equal 59 | ; sign, or by using the None keyword: 60 | 61 | ; foo = ; sets foo to an empty string 62 | ; foo = None ; sets foo to an empty string 63 | ; foo = "None" ; sets foo to the string 'None' 64 | 65 | ; If you use constants in your value, and these constants belong to a 66 | ; dynamically loaded extension (either a PHP extension or a Zend extension), 67 | ; you may only use these constants *after* the line that loads the extension. 68 | 69 | ;;;;;;;;;;;;;;;;;;; 70 | ; About this file ; 71 | ;;;;;;;;;;;;;;;;;;; 72 | ; PHP comes packaged with two INI files. One that is recommended to be used 73 | ; in production environments and one that is recommended to be used in 74 | ; development environments. 75 | 76 | ; php.ini-production contains settings which hold security, performance and 77 | ; best practices at its core. But please be aware, these settings may break 78 | ; compatibility with older or less security conscience applications. We 79 | ; recommending using the production ini in production and testing environments. 80 | 81 | ; php.ini-development is very similar to its production variant, except it is 82 | ; much more verbose when it comes to errors. We recommend using the 83 | ; development version only in development environments, as errors shown to 84 | ; application users can inadvertently leak otherwise secure information. 85 | 86 | ; This is php.ini-production INI file. 87 | 88 | ;;;;;;;;;;;;;;;;;;; 89 | ; Quick Reference ; 90 | ;;;;;;;;;;;;;;;;;;; 91 | ; The following are all the settings which are different in either the production 92 | ; or development versions of the INIs with respect to PHP's default behavior. 93 | ; Please see the actual settings later in the document for more details as to why 94 | ; we recommend these changes in PHP's behavior. 95 | 96 | ; display_errors 97 | ; Default Value: On 98 | ; Development Value: On 99 | ; Production Value: Off 100 | 101 | ; display_startup_errors 102 | ; Default Value: Off 103 | ; Development Value: On 104 | ; Production Value: Off 105 | 106 | ; error_reporting 107 | ; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED 108 | ; Development Value: E_ALL 109 | ; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT 110 | 111 | ; html_errors 112 | ; Default Value: On 113 | ; Development Value: On 114 | ; Production value: On 115 | 116 | ; log_errors 117 | ; Default Value: Off 118 | ; Development Value: On 119 | ; Production Value: On 120 | 121 | ; max_input_time 122 | ; Default Value: -1 (Unlimited) 123 | ; Development Value: 60 (60 seconds) 124 | ; Production Value: 60 (60 seconds) 125 | 126 | ; output_buffering 127 | ; Default Value: Off 128 | ; Development Value: 4096 129 | ; Production Value: 4096 130 | 131 | ; register_argc_argv 132 | ; Default Value: On 133 | ; Development Value: Off 134 | ; Production Value: Off 135 | 136 | ; request_order 137 | ; Default Value: None 138 | ; Development Value: "GP" 139 | ; Production Value: "GP" 140 | 141 | ; session.gc_divisor 142 | ; Default Value: 100 143 | ; Development Value: 1000 144 | ; Production Value: 1000 145 | 146 | ; session.sid_bits_per_character 147 | ; Default Value: 4 148 | ; Development Value: 5 149 | ; Production Value: 5 150 | 151 | ; short_open_tag 152 | ; Default Value: On 153 | ; Development Value: Off 154 | ; Production Value: Off 155 | 156 | ; track_errors 157 | ; Default Value: Off 158 | ; Development Value: On 159 | ; Production Value: Off 160 | 161 | ; variables_order 162 | ; Default Value: "EGPCS" 163 | ; Development Value: "GPCS" 164 | ; Production Value: "GPCS" 165 | 166 | ;;;;;;;;;;;;;;;;;;;; 167 | ; php.ini Options ; 168 | ;;;;;;;;;;;;;;;;;;;; 169 | ; Name for user-defined php.ini (.htaccess) files. Default is ".user.ini" 170 | ;user_ini.filename = ".user.ini" 171 | 172 | ; To disable this feature set this option to empty value 173 | ;user_ini.filename = 174 | 175 | ; TTL for user-defined php.ini files (time-to-live) in seconds. Default is 300 seconds (5 minutes) 176 | ;user_ini.cache_ttl = 300 177 | 178 | ;;;;;;;;;;;;;;;;;;;; 179 | ; Language Options ; 180 | ;;;;;;;;;;;;;;;;;;;; 181 | 182 | ; Enable the PHP scripting language engine under Apache. 183 | ; http://php.net/engine 184 | engine = On 185 | 186 | ; This directive determines whether or not PHP will recognize code between 187 | ; tags as PHP source which should be processed as such. It is 188 | ; generally recommended that should be used and that this feature 189 | ; should be disabled, as enabling it may result in issues when generating XML 190 | ; documents, however this remains supported for backward compatibility reasons. 191 | ; Note that this directive does not control the would work. 324 | ; http://php.net/syntax-highlighting 325 | ;highlight.string = #DD0000 326 | ;highlight.comment = #FF9900 327 | ;highlight.keyword = #007700 328 | ;highlight.default = #0000BB 329 | ;highlight.html = #000000 330 | 331 | ; If enabled, the request will be allowed to complete even if the user aborts 332 | ; the request. Consider enabling it if executing long requests, which may end up 333 | ; being interrupted by the user or a browser timing out. PHP's default behavior 334 | ; is to disable this feature. 335 | ; http://php.net/ignore-user-abort 336 | ;ignore_user_abort = On 337 | 338 | ; Determines the size of the realpath cache to be used by PHP. This value should 339 | ; be increased on systems where PHP opens many files to reflect the quantity of 340 | ; the file operations performed. 341 | ; http://php.net/realpath-cache-size 342 | realpath_cache_size = 6M 343 | 344 | ; Duration of time, in seconds for which to cache realpath information for a given 345 | ; file or directory. For systems with rarely changing files, consider increasing this 346 | ; value. 347 | ; http://php.net/realpath-cache-ttl 348 | realpath_cache_ttl = 900 349 | 350 | ; Enables or disables the circular reference collector. 351 | ; http://php.net/zend.enable-gc 352 | zend.enable_gc = On 353 | 354 | ; If enabled, scripts may be written in encodings that are incompatible with 355 | ; the scanner. CP936, Big5, CP949 and Shift_JIS are the examples of such 356 | ; encodings. To use this feature, mbstring extension must be enabled. 357 | ; Default: Off 358 | ;zend.multibyte = Off 359 | 360 | ; Allows to set the default encoding for the scripts. This value will be used 361 | ; unless "declare(encoding=...)" directive appears at the top of the script. 362 | ; Only affects if zend.multibyte is set. 363 | ; Default: "" 364 | ;zend.script_encoding = 365 | 366 | ;;;;;;;;;;;;;;;;; 367 | ; Miscellaneous ; 368 | ;;;;;;;;;;;;;;;;; 369 | 370 | ; Decides whether PHP may expose the fact that it is installed on the server 371 | ; (e.g. by adding its signature to the Web server header). It is no security 372 | ; threat in any way, but it makes it possible to determine whether you use PHP 373 | ; on your server or not. 374 | ; http://php.net/expose-php 375 | expose_php = On 376 | 377 | ;;;;;;;;;;;;;;;;;;; 378 | ; Resource Limits ; 379 | ;;;;;;;;;;;;;;;;;;; 380 | 381 | ; Maximum execution time of each script, in seconds 382 | ; http://php.net/max-execution-time 383 | ; Note: This directive is hardcoded to 0 for the CLI SAPI 384 | max_execution_time = 600 385 | 386 | ; Maximum amount of time each script may spend parsing request data. It's a good 387 | ; idea to limit this time on productions servers in order to eliminate unexpectedly 388 | ; long running scripts. 389 | ; Note: This directive is hardcoded to -1 for the CLI SAPI 390 | ; Default Value: -1 (Unlimited) 391 | ; Development Value: 60 (60 seconds) 392 | ; Production Value: 60 (60 seconds) 393 | ; http://php.net/max-input-time 394 | max_input_time = 60 395 | 396 | ; Maximum input variable nesting level 397 | ; http://php.net/max-input-nesting-level 398 | ;max_input_nesting_level = 64 399 | 400 | ; How many GET/POST/COOKIE input variables may be accepted 401 | ; max_input_vars = 1000 402 | 403 | ; Maximum amount of memory a script may consume (128MB) 404 | ; http://php.net/memory-limit 405 | memory_limit = -1 406 | ;memory_limit = 256M 407 | 408 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 409 | ; Error handling and logging ; 410 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 411 | 412 | ; This directive informs PHP of which errors, warnings and notices you would like 413 | ; it to take action for. The recommended way of setting values for this 414 | ; directive is through the use of the error level constants and bitwise 415 | ; operators. The error level constants are below here for convenience as well as 416 | ; some common settings and their meanings. 417 | ; By default, PHP is set to take action on all errors, notices and warnings EXCEPT 418 | ; those related to E_NOTICE and E_STRICT, which together cover best practices and 419 | ; recommended coding standards in PHP. For performance reasons, this is the 420 | ; recommend error reporting setting. Your production server shouldn't be wasting 421 | ; resources complaining about best practices and coding standards. That's what 422 | ; development servers and development settings are for. 423 | ; Note: The php.ini-development file has this setting as E_ALL. This 424 | ; means it pretty much reports everything which is exactly what you want during 425 | ; development and early testing. 426 | ; 427 | ; Error Level Constants: 428 | ; E_ALL - All errors and warnings (includes E_STRICT as of PHP 5.4.0) 429 | ; E_ERROR - fatal run-time errors 430 | ; E_RECOVERABLE_ERROR - almost fatal run-time errors 431 | ; E_WARNING - run-time warnings (non-fatal errors) 432 | ; E_PARSE - compile-time parse errors 433 | ; E_NOTICE - run-time notices (these are warnings which often result 434 | ; from a bug in your code, but it's possible that it was 435 | ; intentional (e.g., using an uninitialized variable and 436 | ; relying on the fact it is automatically initialized to an 437 | ; empty string) 438 | ; E_STRICT - run-time notices, enable to have PHP suggest changes 439 | ; to your code which will ensure the best interoperability 440 | ; and forward compatibility of your code 441 | ; E_CORE_ERROR - fatal errors that occur during PHP's initial startup 442 | ; E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's 443 | ; initial startup 444 | ; E_COMPILE_ERROR - fatal compile-time errors 445 | ; E_COMPILE_WARNING - compile-time warnings (non-fatal errors) 446 | ; E_USER_ERROR - user-generated error message 447 | ; E_USER_WARNING - user-generated warning message 448 | ; E_USER_NOTICE - user-generated notice message 449 | ; E_DEPRECATED - warn about code that will not work in future versions 450 | ; of PHP 451 | ; E_USER_DEPRECATED - user-generated deprecation warnings 452 | ; 453 | ; Common Values: 454 | ; E_ALL (Show all errors, warnings and notices including coding standards.) 455 | ; E_ALL & ~E_NOTICE (Show all errors, except for notices) 456 | ; E_ALL & ~E_NOTICE & ~E_STRICT (Show all errors, except for notices and coding standards warnings.) 457 | ; E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors) 458 | ; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED 459 | ; Development Value: E_ALL 460 | ; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT 461 | ; http://php.net/error-reporting 462 | error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT 463 | 464 | ; This directive controls whether or not and where PHP will output errors, 465 | ; notices and warnings too. Error output is very useful during development, but 466 | ; it could be very dangerous in production environments. Depending on the code 467 | ; which is triggering the error, sensitive information could potentially leak 468 | ; out of your application such as database usernames and passwords or worse. 469 | ; For production environments, we recommend logging errors rather than 470 | ; sending them to STDOUT. 471 | ; Possible Values: 472 | ; Off = Do not display any errors 473 | ; stderr = Display errors to STDERR (affects only CGI/CLI binaries!) 474 | ; On or stdout = Display errors to STDOUT 475 | ; Default Value: On 476 | ; Development Value: On 477 | ; Production Value: Off 478 | ; http://php.net/display-errors 479 | display_errors = Off 480 | 481 | ; The display of errors which occur during PHP's startup sequence are handled 482 | ; separately from display_errors. PHP's default behavior is to suppress those 483 | ; errors from clients. Turning the display of startup errors on can be useful in 484 | ; debugging configuration problems. We strongly recommend you 485 | ; set this to 'off' for production servers. 486 | ; Default Value: Off 487 | ; Development Value: On 488 | ; Production Value: Off 489 | ; http://php.net/display-startup-errors 490 | display_startup_errors = Off 491 | 492 | ; Besides displaying errors, PHP can also log errors to locations such as a 493 | ; server-specific log, STDERR, or a location specified by the error_log 494 | ; directive found below. While errors should not be displayed on productions 495 | ; servers they should still be monitored and logging is a great way to do that. 496 | ; Default Value: Off 497 | ; Development Value: On 498 | ; Production Value: On 499 | ; http://php.net/log-errors 500 | log_errors = On 501 | 502 | ; Set maximum length of log_errors. In error_log information about the source is 503 | ; added. The default is 1024 and 0 allows to not apply any maximum length at all. 504 | ; http://php.net/log-errors-max-len 505 | log_errors_max_len = 1024 506 | 507 | ; Do not log repeated messages. Repeated errors must occur in same file on same 508 | ; line unless ignore_repeated_source is set true. 509 | ; http://php.net/ignore-repeated-errors 510 | ignore_repeated_errors = Off 511 | 512 | ; Ignore source of message when ignoring repeated messages. When this setting 513 | ; is On you will not log errors with repeated messages from different files or 514 | ; source lines. 515 | ; http://php.net/ignore-repeated-source 516 | ignore_repeated_source = Off 517 | 518 | ; If this parameter is set to Off, then memory leaks will not be shown (on 519 | ; stdout or in the log). This has only effect in a debug compile, and if 520 | ; error reporting includes E_WARNING in the allowed list 521 | ; http://php.net/report-memleaks 522 | report_memleaks = On 523 | 524 | ; This setting is on by default. 525 | ;report_zend_debug = 0 526 | 527 | ; Store the last error/warning message in $php_errormsg (boolean). Setting this value 528 | ; to On can assist in debugging and is appropriate for development servers. It should 529 | ; however be disabled on production servers. 530 | ; Default Value: Off 531 | ; Development Value: On 532 | ; Production Value: Off 533 | ; http://php.net/track-errors 534 | track_errors = Off 535 | 536 | ; Turn off normal error reporting and emit XML-RPC error XML 537 | ; http://php.net/xmlrpc-errors 538 | ;xmlrpc_errors = 0 539 | 540 | ; An XML-RPC faultCode 541 | ;xmlrpc_error_number = 0 542 | 543 | ; When PHP displays or logs an error, it has the capability of formatting the 544 | ; error message as HTML for easier reading. This directive controls whether 545 | ; the error message is formatted as HTML or not. 546 | ; Note: This directive is hardcoded to Off for the CLI SAPI 547 | ; Default Value: On 548 | ; Development Value: On 549 | ; Production value: On 550 | ; http://php.net/html-errors 551 | html_errors = On 552 | 553 | ; If html_errors is set to On *and* docref_root is not empty, then PHP 554 | ; produces clickable error messages that direct to a page describing the error 555 | ; or function causing the error in detail. 556 | ; You can download a copy of the PHP manual from http://php.net/docs 557 | ; and change docref_root to the base URL of your local copy including the 558 | ; leading '/'. You must also specify the file extension being used including 559 | ; the dot. PHP's default behavior is to leave these settings empty, in which 560 | ; case no links to documentation are generated. 561 | ; Note: Never use this feature for production boxes. 562 | ; http://php.net/docref-root 563 | ; Examples 564 | ;docref_root = "/phpmanual/" 565 | 566 | ; http://php.net/docref-ext 567 | ;docref_ext = .html 568 | 569 | ; String to output before an error message. PHP's default behavior is to leave 570 | ; this setting blank. 571 | ; http://php.net/error-prepend-string 572 | ; Example: 573 | ;error_prepend_string = "" 574 | 575 | ; String to output after an error message. PHP's default behavior is to leave 576 | ; this setting blank. 577 | ; http://php.net/error-append-string 578 | ; Example: 579 | ;error_append_string = "" 580 | 581 | ; Log errors to specified file. PHP's default behavior is to leave this value 582 | ; empty. 583 | ; http://php.net/error-log 584 | ; Example: 585 | ;error_log = php_errors.log 586 | ; Log errors to syslog (Event Log on Windows). 587 | ;error_log = syslog 588 | 589 | ;windows.show_crt_warning 590 | ; Default value: 0 591 | ; Development value: 0 592 | ; Production value: 0 593 | 594 | ;;;;;;;;;;;;;;;;; 595 | ; Data Handling ; 596 | ;;;;;;;;;;;;;;;;; 597 | 598 | ; The separator used in PHP generated URLs to separate arguments. 599 | ; PHP's default setting is "&". 600 | ; http://php.net/arg-separator.output 601 | ; Example: 602 | ;arg_separator.output = "&" 603 | 604 | ; List of separator(s) used by PHP to parse input URLs into variables. 605 | ; PHP's default setting is "&". 606 | ; NOTE: Every character in this directive is considered as separator! 607 | ; http://php.net/arg-separator.input 608 | ; Example: 609 | ;arg_separator.input = ";&" 610 | 611 | ; This directive determines which super global arrays are registered when PHP 612 | ; starts up. G,P,C,E & S are abbreviations for the following respective super 613 | ; globals: GET, POST, COOKIE, ENV and SERVER. There is a performance penalty 614 | ; paid for the registration of these arrays and because ENV is not as commonly 615 | ; used as the others, ENV is not recommended on productions servers. You 616 | ; can still get access to the environment variables through getenv() should you 617 | ; need to. 618 | ; Default Value: "EGPCS" 619 | ; Development Value: "GPCS" 620 | ; Production Value: "GPCS"; 621 | ; http://php.net/variables-order 622 | variables_order = "GPCS" 623 | 624 | ; This directive determines which super global data (G,P & C) should be 625 | ; registered into the super global array REQUEST. If so, it also determines 626 | ; the order in which that data is registered. The values for this directive 627 | ; are specified in the same manner as the variables_order directive, 628 | ; EXCEPT one. Leaving this value empty will cause PHP to use the value set 629 | ; in the variables_order directive. It does not mean it will leave the super 630 | ; globals array REQUEST empty. 631 | ; Default Value: None 632 | ; Development Value: "GP" 633 | ; Production Value: "GP" 634 | ; http://php.net/request-order 635 | request_order = "CGP" 636 | 637 | ; This directive determines whether PHP registers $argv & $argc each time it 638 | ; runs. $argv contains an array of all the arguments passed to PHP when a script 639 | ; is invoked. $argc contains an integer representing the number of arguments 640 | ; that were passed when the script was invoked. These arrays are extremely 641 | ; useful when running scripts from the command line. When this directive is 642 | ; enabled, registering these variables consumes CPU cycles and memory each time 643 | ; a script is executed. For performance reasons, this feature should be disabled 644 | ; on production servers. 645 | ; Note: This directive is hardcoded to On for the CLI SAPI 646 | ; Default Value: On 647 | ; Development Value: Off 648 | ; Production Value: Off 649 | ; http://php.net/register-argc-argv 650 | register_argc_argv = Off 651 | 652 | ; When enabled, the ENV, REQUEST and SERVER variables are created when they're 653 | ; first used (Just In Time) instead of when the script starts. If these 654 | ; variables are not used within a script, having this directive on will result 655 | ; in a performance gain. The PHP directive register_argc_argv must be disabled 656 | ; for this directive to have any affect. 657 | ; http://php.net/auto-globals-jit 658 | auto_globals_jit = On 659 | 660 | ; Whether PHP will read the POST data. 661 | ; This option is enabled by default. 662 | ; Most likely, you won't want to disable this option globally. It causes $_POST 663 | ; and $_FILES to always be empty; the only way you will be able to read the 664 | ; POST data will be through the php://input stream wrapper. This can be useful 665 | ; to proxy requests or to process the POST data in a memory efficient fashion. 666 | ; http://php.net/enable-post-data-reading 667 | ;enable_post_data_reading = Off 668 | 669 | ; Maximum size of POST data that PHP will accept. 670 | ; Its value may be 0 to disable the limit. It is ignored if POST data reading 671 | ; is disabled through enable_post_data_reading. 672 | ; http://php.net/post-max-size 673 | post_max_size = 100M 674 | 675 | ; Automatically add files before PHP document. 676 | ; http://php.net/auto-prepend-file 677 | auto_prepend_file = 678 | 679 | ; Automatically add files after PHP document. 680 | ; http://php.net/auto-append-file 681 | auto_append_file = 682 | 683 | ; By default, PHP will output a media type using the Content-Type header. To 684 | ; disable this, simply set it to be empty. 685 | ; 686 | ; PHP's built-in default media type is set to text/html. 687 | ; http://php.net/default-mimetype 688 | default_mimetype = "text/html" 689 | 690 | ; PHP's default character set is set to UTF-8. 691 | ; http://php.net/default-charset 692 | default_charset = "UTF-8" 693 | 694 | ; PHP internal character encoding is set to empty. 695 | ; If empty, default_charset is used. 696 | ; http://php.net/internal-encoding 697 | ;internal_encoding = 698 | 699 | ; PHP input character encoding is set to empty. 700 | ; If empty, default_charset is used. 701 | ; http://php.net/input-encoding 702 | ;input_encoding = 703 | 704 | ; PHP output character encoding is set to empty. 705 | ; If empty, default_charset is used. 706 | ; See also output_buffer. 707 | ; http://php.net/output-encoding 708 | ;output_encoding = 709 | 710 | ;;;;;;;;;;;;;;;;;;;;;;;;; 711 | ; Paths and Directories ; 712 | ;;;;;;;;;;;;;;;;;;;;;;;;; 713 | 714 | ; UNIX: "/path1:/path2" 715 | ;include_path = ".:/php/includes" 716 | ; 717 | include_path = ".:/usr/share/pear:/usr/share/php" 718 | 719 | ; Windows: "\path1;\path2" 720 | ;include_path = ".;c:\php\includes" 721 | ; 722 | ; PHP's default setting for include_path is ".;/path/to/php/pear" 723 | ; http://php.net/include-path 724 | 725 | ; The root of the PHP pages, used only if nonempty. 726 | ; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root 727 | ; if you are running php as a CGI under any web server (other than IIS) 728 | ; see documentation for security issues. The alternate is to use the 729 | ; cgi.force_redirect configuration below 730 | ; http://php.net/doc-root 731 | doc_root = 732 | 733 | ; The directory under which PHP opens the script using /~username used only 734 | ; if nonempty. 735 | ; http://php.net/user-dir 736 | user_dir = 737 | 738 | ; Directory in which the loadable extensions (modules) reside. 739 | ; http://php.net/extension-dir 740 | ; extension_dir = "./" 741 | ; On windows: 742 | ; extension_dir = "ext" 743 | 744 | ; Directory where the temporary files should be placed. 745 | ; Defaults to the system default (see sys_get_temp_dir) 746 | ; sys_temp_dir = "/tmp" 747 | 748 | ; Whether or not to enable the dl() function. The dl() function does NOT work 749 | ; properly in multithreaded servers, such as IIS or Zeus, and is automatically 750 | ; disabled on them. 751 | ; http://php.net/enable-dl 752 | enable_dl = Off 753 | 754 | ; cgi.force_redirect is necessary to provide security running PHP as a CGI under 755 | ; most web servers. Left undefined, PHP turns this on by default. You can 756 | ; turn it off here AT YOUR OWN RISK 757 | ; **You CAN safely turn this off for IIS, in fact, you MUST.** 758 | ; http://php.net/cgi.force-redirect 759 | ;cgi.force_redirect = 1 760 | 761 | ; if cgi.nph is enabled it will force cgi to always sent Status: 200 with 762 | ; every request. PHP's default behavior is to disable this feature. 763 | ;cgi.nph = 1 764 | 765 | ; if cgi.force_redirect is turned on, and you are not running under Apache or Netscape 766 | ; (iPlanet) web servers, you MAY need to set an environment variable name that PHP 767 | ; will look for to know it is OK to continue execution. Setting this variable MAY 768 | ; cause security issues, KNOW WHAT YOU ARE DOING FIRST. 769 | ; http://php.net/cgi.redirect-status-env 770 | ;cgi.redirect_status_env = 771 | 772 | ; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's 773 | ; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok 774 | ; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting 775 | ; this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting 776 | ; of zero causes PHP to behave as before. Default is 1. You should fix your scripts 777 | ; to use SCRIPT_FILENAME rather than PATH_TRANSLATED. 778 | ; http://php.net/cgi.fix-pathinfo 779 | cgi.fix_pathinfo=0 780 | 781 | ; if cgi.discard_path is enabled, the PHP CGI binary can safely be placed outside 782 | ; of the web tree and people will not be able to circumvent .htaccess security. 783 | ; http://php.net/cgi.dicard-path 784 | ;cgi.discard_path=1 785 | 786 | ; FastCGI under IIS (on WINNT based OS) supports the ability to impersonate 787 | ; security tokens of the calling client. This allows IIS to define the 788 | ; security context that the request runs under. mod_fastcgi under Apache 789 | ; does not currently support this feature (03/17/2002) 790 | ; Set to 1 if running under IIS. Default is zero. 791 | ; http://php.net/fastcgi.impersonate 792 | ;fastcgi.impersonate = 1 793 | 794 | ; Disable logging through FastCGI connection. PHP's default behavior is to enable 795 | ; this feature. 796 | ;fastcgi.logging = 0 797 | 798 | ; cgi.rfc2616_headers configuration option tells PHP what type of headers to 799 | ; use when sending HTTP response code. If set to 0, PHP sends Status: header that 800 | ; is supported by Apache. When this option is set to 1, PHP will send 801 | ; RFC2616 compliant header. 802 | ; Default is zero. 803 | ; http://php.net/cgi.rfc2616-headers 804 | ;cgi.rfc2616_headers = 0 805 | 806 | ; cgi.check_shebang_line controls whether CGI PHP checks for line starting with #! 807 | ; (shebang) at the top of the running script. This line might be needed if the 808 | ; script support running both as stand-alone script and via PHP CGI<. PHP in CGI 809 | ; mode skips this line and ignores its content if this directive is turned on. 810 | ; http://php.net/cgi.check-shebang-line 811 | ;cgi.check_shebang_line=1 812 | 813 | ;;;;;;;;;;;;;;;; 814 | ; File Uploads ; 815 | ;;;;;;;;;;;;;;;; 816 | 817 | ; Whether to allow HTTP file uploads. 818 | ; http://php.net/file-uploads 819 | file_uploads = On 820 | 821 | ; Temporary directory for HTTP uploaded files (will use system default if not 822 | ; specified). 823 | ; http://php.net/upload-tmp-dir 824 | ;upload_tmp_dir = 825 | 826 | ; Maximum allowed size for uploaded files. 827 | ; http://php.net/upload-max-filesize 828 | upload_max_filesize = 100M 829 | 830 | ; Maximum number of files that can be uploaded via a single request 831 | max_file_uploads = 20 832 | 833 | ;;;;;;;;;;;;;;;;;; 834 | ; Fopen wrappers ; 835 | ;;;;;;;;;;;;;;;;;; 836 | 837 | ; Whether to allow the treatment of URLs (like http:// or ftp://) as files. 838 | ; http://php.net/allow-url-fopen 839 | allow_url_fopen = On 840 | 841 | ; Whether to allow include/require to open URLs (like http:// or ftp://) as files. 842 | ; http://php.net/allow-url-include 843 | allow_url_include = Off 844 | 845 | ; Define the anonymous ftp password (your email address). PHP's default setting 846 | ; for this is empty. 847 | ; http://php.net/from 848 | ;from="john@doe.com" 849 | 850 | ; Define the User-Agent string. PHP's default setting for this is empty. 851 | ; http://php.net/user-agent 852 | ;user_agent="PHP" 853 | 854 | ; Default timeout for socket based streams (seconds) 855 | ; http://php.net/default-socket-timeout 856 | default_socket_timeout = 60 857 | 858 | ; If your scripts have to deal with files from Macintosh systems, 859 | ; or you are running on a Mac and need to deal with files from 860 | ; unix or win32 systems, setting this flag will cause PHP to 861 | ; automatically detect the EOL character in those files so that 862 | ; fgets() and file() will work regardless of the source of the file. 863 | ; http://php.net/auto-detect-line-endings 864 | ;auto_detect_line_endings = Off 865 | 866 | ;;;;;;;;;;;;;;;;;;;;;; 867 | ; Dynamic Extensions ; 868 | ;;;;;;;;;;;;;;;;;;;;;; 869 | 870 | ; If you wish to have an extension loaded automatically, use the following 871 | ; syntax: 872 | ; 873 | ; extension=modulename.extension 874 | ; 875 | ; For example, on Windows: 876 | ; 877 | ; extension=msql.dll 878 | ; 879 | ; ... or under UNIX: 880 | ; 881 | ; extension=msql.so 882 | ; 883 | ; ... or with a path: 884 | ; 885 | ; extension=/path/to/extension/msql.so 886 | ; 887 | ; If you only provide the name of the extension, PHP will look for it in its 888 | ; default extension directory. 889 | ; 890 | ; Windows Extensions 891 | ; Note that ODBC support is built in, so no dll is needed for it. 892 | ; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5+) 893 | ; extension folders as well as the separate PECL DLL download (PHP 5+). 894 | ; Be sure to appropriately set the extension_dir directive. 895 | ; 896 | ;extension=php_bz2.dll 897 | ;extension=php_curl.dll 898 | ;extension=php_fileinfo.dll 899 | ;extension=php_ftp.dll 900 | ;extension=php_gd2.dll 901 | ;extension=php_gettext.dll 902 | ;extension=php_gmp.dll 903 | ;extension=php_intl.dll 904 | ;extension=php_imap.dll 905 | ;extension=php_interbase.dll 906 | ;extension=php_ldap.dll 907 | ;extension=php_mbstring.dll 908 | ;extension=php_exif.dll ; Must be after mbstring as it depends on it 909 | ;extension=php_mysqli.dll 910 | ;extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client 911 | ;extension=php_openssl.dll 912 | ;extension=php_pdo_firebird.dll 913 | ;extension=php_pdo_mysql.dll 914 | ;extension=php_pdo_oci.dll 915 | ;extension=php_pdo_odbc.dll 916 | ;extension=php_pdo_pgsql.dll 917 | ;extension=php_pdo_sqlite.dll 918 | ;extension=php_pgsql.dll 919 | ;extension=php_shmop.dll 920 | 921 | ; The MIBS data available in the PHP distribution must be installed. 922 | ; See http://www.php.net/manual/en/snmp.installation.php 923 | ;extension=php_snmp.dll 924 | 925 | ;extension=php_soap.dll 926 | ;extension=php_sockets.dll 927 | ;extension=php_sqlite3.dll 928 | ;extension=php_tidy.dll 929 | ;extension=php_xmlrpc.dll 930 | ;extension=php_xsl.dll 931 | 932 | ;;;;;;;;;;;;;;;;;;; 933 | ; Module Settings ; 934 | ;;;;;;;;;;;;;;;;;;; 935 | 936 | [CLI Server] 937 | ; Whether the CLI web server uses ANSI color coding in its terminal output. 938 | cli_server.color = On 939 | 940 | [Date] 941 | ; Defines the default timezone used by the date functions 942 | ; http://php.net/date.timezone 943 | date.timezone = Asia/Shanghai 944 | 945 | ; http://php.net/date.default-latitude 946 | ;date.default_latitude = 31.7667 947 | 948 | ; http://php.net/date.default-longitude 949 | ;date.default_longitude = 35.2333 950 | 951 | ; http://php.net/date.sunrise-zenith 952 | ;date.sunrise_zenith = 90.583333 953 | 954 | ; http://php.net/date.sunset-zenith 955 | ;date.sunset_zenith = 90.583333 956 | 957 | [filter] 958 | ; http://php.net/filter.default 959 | ;filter.default = unsafe_raw 960 | 961 | ; http://php.net/filter.default-flags 962 | ;filter.default_flags = 963 | 964 | [iconv] 965 | ; Use of this INI entry is deprecated, use global input_encoding instead. 966 | ; If empty, default_charset or input_encoding or iconv.input_encoding is used. 967 | ; The precedence is: default_charset < intput_encoding < iconv.input_encoding 968 | ;iconv.input_encoding = 969 | 970 | ; Use of this INI entry is deprecated, use global internal_encoding instead. 971 | ; If empty, default_charset or internal_encoding or iconv.internal_encoding is used. 972 | ; The precedence is: default_charset < internal_encoding < iconv.internal_encoding 973 | ;iconv.internal_encoding = 974 | 975 | ; Use of this INI entry is deprecated, use global output_encoding instead. 976 | ; If empty, default_charset or output_encoding or iconv.output_encoding is used. 977 | ; The precedence is: default_charset < output_encoding < iconv.output_encoding 978 | ; To use an output encoding conversion, iconv's output handler must be set 979 | ; otherwise output encoding conversion cannot be performed. 980 | ;iconv.output_encoding = 981 | 982 | [intl] 983 | ;intl.default_locale = 984 | ; This directive allows you to produce PHP errors when some error 985 | ; happens within intl functions. The value is the level of the error produced. 986 | ; Default is 0, which does not produce any errors. 987 | ;intl.error_level = E_WARNING 988 | ;intl.use_exceptions = 0 989 | 990 | [sqlite3] 991 | ;sqlite3.extension_dir = 992 | 993 | [Pcre] 994 | ;PCRE library backtracking limit. 995 | ; http://php.net/pcre.backtrack-limit 996 | ;pcre.backtrack_limit=100000 997 | 998 | ;PCRE library recursion limit. 999 | ;Please note that if you set this value to a high number you may consume all 1000 | ;the available process stack and eventually crash PHP (due to reaching the 1001 | ;stack size limit imposed by the Operating System). 1002 | ; http://php.net/pcre.recursion-limit 1003 | ;pcre.recursion_limit=100000 1004 | 1005 | ;Enables or disables JIT compilation of patterns. This requires the PCRE 1006 | ;library to be compiled with JIT support. 1007 | pcre.jit=1 1008 | 1009 | [Pdo] 1010 | ; Whether to pool ODBC connections. Can be one of "strict", "relaxed" or "off" 1011 | ; http://php.net/pdo-odbc.connection-pooling 1012 | ;pdo_odbc.connection_pooling=strict 1013 | 1014 | ;pdo_odbc.db2_instance_name 1015 | 1016 | [Pdo_mysql] 1017 | ; If mysqlnd is used: Number of cache slots for the internal result set cache 1018 | ; http://php.net/pdo_mysql.cache_size 1019 | pdo_mysql.cache_size = 2000 1020 | 1021 | ; Default socket name for local MySQL connects. If empty, uses the built-in 1022 | ; MySQL defaults. 1023 | ; http://php.net/pdo_mysql.default-socket 1024 | ;pdo_mysql.default_socket=/var/lib/mysql/mysql.sock 1025 | pdo_mysql.default_socket=/dev/shm/mysql.sock 1026 | 1027 | [Phar] 1028 | ; http://php.net/phar.readonly 1029 | ;phar.readonly = On 1030 | 1031 | ; http://php.net/phar.require-hash 1032 | ;phar.require_hash = On 1033 | 1034 | ;phar.cache_list = 1035 | 1036 | [mail function] 1037 | ; For Win32 only. 1038 | ; http://php.net/smtp 1039 | SMTP = localhost 1040 | ; http://php.net/smtp-port 1041 | smtp_port = 25 1042 | 1043 | ; For Win32 only. 1044 | ; http://php.net/sendmail-from 1045 | ;sendmail_from = me@example.com 1046 | 1047 | ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). 1048 | ; http://php.net/sendmail-path 1049 | sendmail_path = /usr/sbin/sendmail -t -i 1050 | 1051 | ; Force the addition of the specified parameters to be passed as extra parameters 1052 | ; to the sendmail binary. These parameters will always replace the value of 1053 | ; the 5th parameter to mail(). 1054 | ;mail.force_extra_parameters = 1055 | 1056 | ; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename 1057 | mail.add_x_header = On 1058 | 1059 | ; The path to a log file that will log all mail() calls. Log entries include 1060 | ; the full path of the script, line number, To address and headers. 1061 | ;mail.log = 1062 | ; Log mail to syslog (Event Log on Windows). 1063 | ;mail.log = syslog 1064 | 1065 | [SQL] 1066 | ; http://php.net/sql.safe-mode 1067 | sql.safe_mode = Off 1068 | 1069 | [ODBC] 1070 | ; http://php.net/odbc.default-db 1071 | ;odbc.default_db = Not yet implemented 1072 | 1073 | ; http://php.net/odbc.default-user 1074 | ;odbc.default_user = Not yet implemented 1075 | 1076 | ; http://php.net/odbc.default-pw 1077 | ;odbc.default_pw = Not yet implemented 1078 | 1079 | ; Controls the ODBC cursor model. 1080 | ; Default: SQL_CURSOR_STATIC (default). 1081 | ;odbc.default_cursortype 1082 | 1083 | ; Allow or prevent persistent links. 1084 | ; http://php.net/odbc.allow-persistent 1085 | odbc.allow_persistent = On 1086 | 1087 | ; Check that a connection is still valid before reuse. 1088 | ; http://php.net/odbc.check-persistent 1089 | odbc.check_persistent = On 1090 | 1091 | ; Maximum number of persistent links. -1 means no limit. 1092 | ; http://php.net/odbc.max-persistent 1093 | odbc.max_persistent = -1 1094 | 1095 | ; Maximum number of links (persistent + non-persistent). -1 means no limit. 1096 | ; http://php.net/odbc.max-links 1097 | odbc.max_links = -1 1098 | 1099 | ; Handling of LONG fields. Returns number of bytes to variables. 0 means 1100 | ; passthru. 1101 | ; http://php.net/odbc.defaultlrl 1102 | odbc.defaultlrl = 4096 1103 | 1104 | ; Handling of binary data. 0 means passthru, 1 return as is, 2 convert to char. 1105 | ; See the documentation on odbc_binmode and odbc_longreadlen for an explanation 1106 | ; of odbc.defaultlrl and odbc.defaultbinmode 1107 | ; http://php.net/odbc.defaultbinmode 1108 | odbc.defaultbinmode = 1 1109 | 1110 | ;birdstep.max_links = -1 1111 | 1112 | [Interbase] 1113 | ; Allow or prevent persistent links. 1114 | ibase.allow_persistent = 1 1115 | 1116 | ; Maximum number of persistent links. -1 means no limit. 1117 | ibase.max_persistent = -1 1118 | 1119 | ; Maximum number of links (persistent + non-persistent). -1 means no limit. 1120 | ibase.max_links = -1 1121 | 1122 | ; Default database name for ibase_connect(). 1123 | ;ibase.default_db = 1124 | 1125 | ; Default username for ibase_connect(). 1126 | ;ibase.default_user = 1127 | 1128 | ; Default password for ibase_connect(). 1129 | ;ibase.default_password = 1130 | 1131 | ; Default charset for ibase_connect(). 1132 | ;ibase.default_charset = 1133 | 1134 | ; Default timestamp format. 1135 | ibase.timestampformat = "%Y-%m-%d %H:%M:%S" 1136 | 1137 | ; Default date format. 1138 | ibase.dateformat = "%Y-%m-%d" 1139 | 1140 | ; Default time format. 1141 | ibase.timeformat = "%H:%M:%S" 1142 | 1143 | [MySQLi] 1144 | 1145 | ; Maximum number of persistent links. -1 means no limit. 1146 | ; http://php.net/mysqli.max-persistent 1147 | mysqli.max_persistent = -1 1148 | 1149 | ; Allow accessing, from PHP's perspective, local files with LOAD DATA statements 1150 | ; http://php.net/mysqli.allow_local_infile 1151 | ;mysqli.allow_local_infile = On 1152 | 1153 | ; Allow or prevent persistent links. 1154 | ; http://php.net/mysqli.allow-persistent 1155 | mysqli.allow_persistent = On 1156 | 1157 | ; Maximum number of links. -1 means no limit. 1158 | ; http://php.net/mysqli.max-links 1159 | mysqli.max_links = -1 1160 | 1161 | ; If mysqlnd is used: Number of cache slots for the internal result set cache 1162 | ; http://php.net/mysqli.cache_size 1163 | mysqli.cache_size = 2000 1164 | 1165 | ; Default port number for mysqli_connect(). If unset, mysqli_connect() will use 1166 | ; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the 1167 | ; compile-time value defined MYSQL_PORT (in that order). Win32 will only look 1168 | ; at MYSQL_PORT. 1169 | ; http://php.net/mysqli.default-port 1170 | mysqli.default_port = 3306 1171 | 1172 | ; Default socket name for local MySQL connects. If empty, uses the built-in 1173 | ; MySQL defaults. 1174 | ; http://php.net/mysqli.default-socket 1175 | ; 1176 | ;mysqli.default_socket = /var/lib/mysql/mysql.sock 1177 | mysqli.default_socket = /dev/shm/mysql.sock 1178 | 1179 | ; Default host for mysql_connect() (doesn't apply in safe mode). 1180 | ; http://php.net/mysqli.default-host 1181 | mysqli.default_host = 1182 | 1183 | ; Default user for mysql_connect() (doesn't apply in safe mode). 1184 | ; http://php.net/mysqli.default-user 1185 | mysqli.default_user = 1186 | 1187 | ; Default password for mysqli_connect() (doesn't apply in safe mode). 1188 | ; Note that this is generally a *bad* idea to store passwords in this file. 1189 | ; *Any* user with PHP access can run 'echo get_cfg_var("mysqli.default_pw") 1190 | ; and reveal this password! And of course, any users with read access to this 1191 | ; file will be able to reveal the password as well. 1192 | ; http://php.net/mysqli.default-pw 1193 | mysqli.default_pw = 1194 | 1195 | ; Allow or prevent reconnect 1196 | mysqli.reconnect = Off 1197 | 1198 | [mysqlnd] 1199 | ; Enable / Disable collection of general statistics by mysqlnd which can be 1200 | ; used to tune and monitor MySQL operations. 1201 | ; http://php.net/mysqlnd.collect_statistics 1202 | mysqlnd.collect_statistics = On 1203 | 1204 | ; Enable / Disable collection of memory usage statistics by mysqlnd which can be 1205 | ; used to tune and monitor MySQL operations. 1206 | ; http://php.net/mysqlnd.collect_memory_statistics 1207 | mysqlnd.collect_memory_statistics = Off 1208 | 1209 | ; Records communication from all extensions using mysqlnd to the specified log 1210 | ; file. 1211 | ; http://php.net/mysqlnd.debug 1212 | ;mysqlnd.debug = 1213 | 1214 | ; Defines which queries will be logged. 1215 | ; http://php.net/mysqlnd.log_mask 1216 | ;mysqlnd.log_mask = 0 1217 | 1218 | ; Default size of the mysqlnd memory pool, which is used by result sets. 1219 | ; http://php.net/mysqlnd.mempool_default_size 1220 | ;mysqlnd.mempool_default_size = 16000 1221 | 1222 | ; Size of a pre-allocated buffer used when sending commands to MySQL in bytes. 1223 | ; http://php.net/mysqlnd.net_cmd_buffer_size 1224 | ;mysqlnd.net_cmd_buffer_size = 2048 1225 | 1226 | ; Size of a pre-allocated buffer used for reading data sent by the server in 1227 | ; bytes. 1228 | ; http://php.net/mysqlnd.net_read_buffer_size 1229 | ;mysqlnd.net_read_buffer_size = 32768 1230 | 1231 | ; Timeout for network requests in seconds. 1232 | ; http://php.net/mysqlnd.net_read_timeout 1233 | ;mysqlnd.net_read_timeout = 31536000 1234 | 1235 | ; SHA-256 Authentication Plugin related. File with the MySQL server public RSA 1236 | ; key. 1237 | ; http://php.net/mysqlnd.sha256_server_public_key 1238 | ;mysqlnd.sha256_server_public_key = 1239 | 1240 | [OCI8] 1241 | 1242 | ; Connection: Enables privileged connections using external 1243 | ; credentials (OCI_SYSOPER, OCI_SYSDBA) 1244 | ; http://php.net/oci8.privileged-connect 1245 | ;oci8.privileged_connect = Off 1246 | 1247 | ; Connection: The maximum number of persistent OCI8 connections per 1248 | ; process. Using -1 means no limit. 1249 | ; http://php.net/oci8.max-persistent 1250 | ;oci8.max_persistent = -1 1251 | 1252 | ; Connection: The maximum number of seconds a process is allowed to 1253 | ; maintain an idle persistent connection. Using -1 means idle 1254 | ; persistent connections will be maintained forever. 1255 | ; http://php.net/oci8.persistent-timeout 1256 | ;oci8.persistent_timeout = -1 1257 | 1258 | ; Connection: The number of seconds that must pass before issuing a 1259 | ; ping during oci_pconnect() to check the connection validity. When 1260 | ; set to 0, each oci_pconnect() will cause a ping. Using -1 disables 1261 | ; pings completely. 1262 | ; http://php.net/oci8.ping-interval 1263 | ;oci8.ping_interval = 60 1264 | 1265 | ; Connection: Set this to a user chosen connection class to be used 1266 | ; for all pooled server requests with Oracle 11g Database Resident 1267 | ; Connection Pooling (DRCP). To use DRCP, this value should be set to 1268 | ; the same string for all web servers running the same application, 1269 | ; the database pool must be configured, and the connection string must 1270 | ; specify to use a pooled server. 1271 | ;oci8.connection_class = 1272 | 1273 | ; High Availability: Using On lets PHP receive Fast Application 1274 | ; Notification (FAN) events generated when a database node fails. The 1275 | ; database must also be configured to post FAN events. 1276 | ;oci8.events = Off 1277 | 1278 | ; Tuning: This option enables statement caching, and specifies how 1279 | ; many statements to cache. Using 0 disables statement caching. 1280 | ; http://php.net/oci8.statement-cache-size 1281 | ;oci8.statement_cache_size = 20 1282 | 1283 | ; Tuning: Enables statement prefetching and sets the default number of 1284 | ; rows that will be fetched automatically after statement execution. 1285 | ; http://php.net/oci8.default-prefetch 1286 | ;oci8.default_prefetch = 100 1287 | 1288 | ; Compatibility. Using On means oci_close() will not close 1289 | ; oci_connect() and oci_new_connect() connections. 1290 | ; http://php.net/oci8.old-oci-close-semantics 1291 | ;oci8.old_oci_close_semantics = Off 1292 | 1293 | [PostgreSQL] 1294 | ; Allow or prevent persistent links. 1295 | ; http://php.net/pgsql.allow-persistent 1296 | pgsql.allow_persistent = On 1297 | 1298 | ; Detect broken persistent links always with pg_pconnect(). 1299 | ; Auto reset feature requires a little overheads. 1300 | ; http://php.net/pgsql.auto-reset-persistent 1301 | pgsql.auto_reset_persistent = Off 1302 | 1303 | ; Maximum number of persistent links. -1 means no limit. 1304 | ; http://php.net/pgsql.max-persistent 1305 | pgsql.max_persistent = -1 1306 | 1307 | ; Maximum number of links (persistent+non persistent). -1 means no limit. 1308 | ; http://php.net/pgsql.max-links 1309 | pgsql.max_links = -1 1310 | 1311 | ; Ignore PostgreSQL backends Notice message or not. 1312 | ; Notice message logging require a little overheads. 1313 | ; http://php.net/pgsql.ignore-notice 1314 | pgsql.ignore_notice = 0 1315 | 1316 | ; Log PostgreSQL backends Notice message or not. 1317 | ; Unless pgsql.ignore_notice=0, module cannot log notice message. 1318 | ; http://php.net/pgsql.log-notice 1319 | pgsql.log_notice = 0 1320 | 1321 | [bcmath] 1322 | ; Number of decimal digits for all bcmath functions. 1323 | ; http://php.net/bcmath.scale 1324 | bcmath.scale = 0 1325 | 1326 | [browscap] 1327 | ; http://php.net/browscap 1328 | ;browscap = extra/browscap.ini 1329 | 1330 | [Session] 1331 | ; Handler used to store/retrieve data. 1332 | ; http://php.net/session.save-handler 1333 | session.save_handler = files 1334 | ;session.save_handler = redis 1335 | ;session.save_path = "unix:///usr/local/redis/var/run/redis.sock?persistent=1" 1336 | 1337 | ; Argument passed to save_handler. In the case of files, this is the path 1338 | ; where data files are stored. Note: Windows users have to change this 1339 | ; variable in order to use PHP's session functions. 1340 | ; 1341 | ; The path can be defined as: 1342 | ; 1343 | ; session.save_path = "N;/path" 1344 | ; 1345 | ; where N is an integer. Instead of storing all the session files in 1346 | ; /path, what this will do is use subdirectories N-levels deep, and 1347 | ; store the session data in those directories. This is useful if 1348 | ; your OS has problems with many files in one directory, and is 1349 | ; a more efficient layout for servers that handle many sessions. 1350 | ; 1351 | ; NOTE 1: PHP will not create this directory structure automatically. 1352 | ; You can use the script in the ext/session dir for that purpose. 1353 | ; NOTE 2: See the section on garbage collection below if you choose to 1354 | ; use subdirectories for session storage 1355 | ; 1356 | ; The file storage module creates files using mode 600 by default. 1357 | ; You can change that by using 1358 | ; 1359 | ; session.save_path = "N;MODE;/path" 1360 | ; 1361 | ; where MODE is the octal representation of the mode. Note that this 1362 | ; does not overwrite the process's umask. 1363 | ; http://php.net/session.save-path 1364 | ;session.save_path = "/tmp" 1365 | 1366 | ; Whether to use strict session mode. 1367 | ; Strict session mode does not accept uninitialized session ID and regenerate 1368 | ; session ID if browser sends uninitialized session ID. Strict mode protects 1369 | ; applications from session fixation via session adoption vulnerability. It is 1370 | ; disabled by default for maximum compatibility, but enabling it is encouraged. 1371 | ; https://wiki.php.net/rfc/strict_sessions 1372 | session.use_strict_mode = 0 1373 | 1374 | ; Whether to use cookies. 1375 | ; http://php.net/session.use-cookies 1376 | session.use_cookies = 1 1377 | 1378 | ; http://php.net/session.cookie-secure 1379 | ;session.cookie_secure = 1380 | 1381 | ; This option forces PHP to fetch and use a cookie for storing and maintaining 1382 | ; the session id. We encourage this operation as it's very helpful in combating 1383 | ; session hijacking when not specifying and managing your own session id. It is 1384 | ; not the be-all and end-all of session hijacking defense, but it's a good start. 1385 | ; http://php.net/session.use-only-cookies 1386 | session.use_only_cookies = 1 1387 | 1388 | ; Name of the session (used as cookie name). 1389 | ; http://php.net/session.name 1390 | session.name = PHPSESSID 1391 | 1392 | ; Initialize session on request startup. 1393 | ; http://php.net/session.auto-start 1394 | session.auto_start = 0 1395 | 1396 | ; Lifetime in seconds of cookie or, if 0, until browser is restarted. 1397 | ; http://php.net/session.cookie-lifetime 1398 | session.cookie_lifetime = 0 1399 | 1400 | ; The path for which the cookie is valid. 1401 | ; http://php.net/session.cookie-path 1402 | session.cookie_path = / 1403 | 1404 | ; The domain for which the cookie is valid. 1405 | ; http://php.net/session.cookie-domain 1406 | session.cookie_domain = 1407 | 1408 | ; Whether or not to add the httpOnly flag to the cookie, which makes it inaccessible to browser scripting languages such as JavaScript. 1409 | ; http://php.net/session.cookie-httponly 1410 | session.cookie_httponly = 1411 | 1412 | ; Handler used to serialize data. php is the standard serializer of PHP. 1413 | ; http://php.net/session.serialize-handler 1414 | session.serialize_handler = php 1415 | 1416 | ; Defines the probability that the 'garbage collection' process is started 1417 | ; on every session initialization. The probability is calculated by using 1418 | ; gc_probability/gc_divisor. Where session.gc_probability is the numerator 1419 | ; and gc_divisor is the denominator in the equation. Setting this value to 1 1420 | ; when the session.gc_divisor value is 100 will give you approximately a 1% chance 1421 | ; the gc will run on any give request. 1422 | ; Default Value: 1 1423 | ; Development Value: 1 1424 | ; Production Value: 1 1425 | ; http://php.net/session.gc-probability 1426 | session.gc_probability = 1 1427 | 1428 | ; Defines the probability that the 'garbage collection' process is started on every 1429 | ; session initialization. The probability is calculated by using the following equation: 1430 | ; gc_probability/gc_divisor. Where session.gc_probability is the numerator and 1431 | ; session.gc_divisor is the denominator in the equation. Setting this value to 1 1432 | ; when the session.gc_divisor value is 100 will give you approximately a 1% chance 1433 | ; the gc will run on any give request. Increasing this value to 1000 will give you 1434 | ; a 0.1% chance the gc will run on any give request. For high volume production servers, 1435 | ; this is a more efficient approach. 1436 | ; Default Value: 100 1437 | ; Development Value: 1000 1438 | ; Production Value: 1000 1439 | ; http://php.net/session.gc-divisor 1440 | session.gc_divisor = 1000 1441 | 1442 | ; After this number of seconds, stored data will be seen as 'garbage' and 1443 | ; cleaned up by the garbage collection process. 1444 | ; http://php.net/session.gc-maxlifetime 1445 | session.gc_maxlifetime = 31536000 1446 | 1447 | ; NOTE: If you are using the subdirectory option for storing session files 1448 | ; (see session.save_path above), then garbage collection does *not* 1449 | ; happen automatically. You will need to do your own garbage 1450 | ; collection through a shell script, cron entry, or some other method. 1451 | ; For example, the following script would is the equivalent of 1452 | ; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes): 1453 | ; find /path/to/sessions -cmin +24 -type f | xargs rm 1454 | 1455 | ; Check HTTP Referer to invalidate externally stored URLs containing ids. 1456 | ; HTTP_REFERER has to contain this substring for the session to be 1457 | ; considered as valid. 1458 | ; http://php.net/session.referer-check 1459 | session.referer_check = 1460 | 1461 | ; Set to {nocache,private,public,} to determine HTTP caching aspects 1462 | ; or leave this empty to avoid sending anti-caching headers. 1463 | ; http://php.net/session.cache-limiter 1464 | session.cache_limiter = nocache 1465 | 1466 | ; Document expires after n minutes. 1467 | ; http://php.net/session.cache-expire 1468 | session.cache_expire = 180 1469 | 1470 | ; trans sid support is disabled by default. 1471 | ; Use of trans sid may risk your users' security. 1472 | ; Use this option with caution. 1473 | ; - User may send URL contains active session ID 1474 | ; to other person via. email/irc/etc. 1475 | ; - URL that contains active session ID may be stored 1476 | ; in publicly accessible computer. 1477 | ; - User may access your site with the same session ID 1478 | ; always using URL stored in browser's history or bookmarks. 1479 | ; http://php.net/session.use-trans-sid 1480 | session.use_trans_sid = 0 1481 | 1482 | ; Set session ID character length. This value could be between 22 to 256. 1483 | ; Shorter length than default is supported only for compatibility reason. 1484 | ; Users should use 32 or more chars. 1485 | ; http://php.net/session.sid_length 1486 | ; Default Value: 32 1487 | ; Development Value: 26 1488 | ; Production Value: 26 1489 | session.sid_length = 26 1490 | 1491 | ; The URL rewriter will look for URLs in a defined set of HTML tags. 1492 | ;
is special; if you include them here, the rewriter will 1493 | ; add a hidden field with the info which is otherwise appended 1494 | ; to URLs. tag's action attribute URL will not be modified 1495 | ; unless it is specified. 1496 | ; Note that all valid entries require a "=", even if no value follows. 1497 | ; Default Value: "a=href,area=href,frame=src,form=" 1498 | ; Development Value: "a=href,area=href,frame=src,form=" 1499 | ; Production Value: "a=href,area=href,frame=src,form=" 1500 | ; http://php.net/url-rewriter.tags 1501 | session.trans_sid_tags = "a=href,area=href,frame=src,form=" 1502 | 1503 | ; URL rewriter does not rewrite absolute URLs by default. 1504 | ; To enable rewrites for absolute pathes, target hosts must be specified 1505 | ; at RUNTIME. i.e. use ini_set() 1506 | ; tags is special. PHP will check action attribute's URL regardless 1507 | ; of session.trans_sid_tags setting. 1508 | ; If no host is defined, HTTP_HOST will be used for allowed host. 1509 | ; Example value: php.net,www.php.net,wiki.php.net 1510 | ; Use "," for multiple hosts. No spaces are allowed. 1511 | ; Default Value: "" 1512 | ; Development Value: "" 1513 | ; Production Value: "" 1514 | ;session.trans_sid_hosts="" 1515 | 1516 | ; Define how many bits are stored in each character when converting 1517 | ; the binary hash data to something readable. 1518 | ; Possible values: 1519 | ; 4 (4 bits: 0-9, a-f) 1520 | ; 5 (5 bits: 0-9, a-v) 1521 | ; 6 (6 bits: 0-9, a-z, A-Z, "-", ",") 1522 | ; Default Value: 4 1523 | ; Development Value: 5 1524 | ; Production Value: 5 1525 | ; http://php.net/session.hash-bits-per-character 1526 | session.sid_bits_per_character = 5 1527 | 1528 | ; Enable upload progress tracking in $_SESSION 1529 | ; Default Value: On 1530 | ; Development Value: On 1531 | ; Production Value: On 1532 | ; http://php.net/session.upload-progress.enabled 1533 | ;session.upload_progress.enabled = On 1534 | 1535 | ; Cleanup the progress information as soon as all POST data has been read 1536 | ; (i.e. upload completed). 1537 | ; Default Value: On 1538 | ; Development Value: On 1539 | ; Production Value: On 1540 | ; http://php.net/session.upload-progress.cleanup 1541 | ;session.upload_progress.cleanup = On 1542 | 1543 | ; A prefix used for the upload progress key in $_SESSION 1544 | ; Default Value: "upload_progress_" 1545 | ; Development Value: "upload_progress_" 1546 | ; Production Value: "upload_progress_" 1547 | ; http://php.net/session.upload-progress.prefix 1548 | ;session.upload_progress.prefix = "upload_progress_" 1549 | 1550 | ; The index name (concatenated with the prefix) in $_SESSION 1551 | ; containing the upload progress information 1552 | ; Default Value: "PHP_SESSION_UPLOAD_PROGRESS" 1553 | ; Development Value: "PHP_SESSION_UPLOAD_PROGRESS" 1554 | ; Production Value: "PHP_SESSION_UPLOAD_PROGRESS" 1555 | ; http://php.net/session.upload-progress.name 1556 | ;session.upload_progress.name = "PHP_SESSION_UPLOAD_PROGRESS" 1557 | 1558 | ; How frequently the upload progress should be updated. 1559 | ; Given either in percentages (per-file), or in bytes 1560 | ; Default Value: "1%" 1561 | ; Development Value: "1%" 1562 | ; Production Value: "1%" 1563 | ; http://php.net/session.upload-progress.freq 1564 | ;session.upload_progress.freq = "1%" 1565 | 1566 | ; The minimum delay between updates, in seconds 1567 | ; Default Value: 1 1568 | ; Development Value: 1 1569 | ; Production Value: 1 1570 | ; http://php.net/session.upload-progress.min-freq 1571 | ;session.upload_progress.min_freq = "1" 1572 | 1573 | ; Only write session data when session data is changed. Enabled by default. 1574 | ; http://php.net/session.lazy-write 1575 | ;session.lazy_write = On 1576 | 1577 | [Assertion] 1578 | ; Switch whether to compile assertions at all (to have no overhead at run-time) 1579 | ; -1: Do not compile at all 1580 | ; 0: Jump over assertion at run-time 1581 | ; 1: Execute assertions 1582 | ; Changing from or to a negative value is only possible in php.ini! (For turning assertions on and off at run-time, see assert.active, when zend.assertions = 1) 1583 | ; Default Value: 1 1584 | ; Development Value: 1 1585 | ; Production Value: -1 1586 | ; http://php.net/zend.assertions 1587 | zend.assertions = -1 1588 | 1589 | ; Assert(expr); active by default. 1590 | ; http://php.net/assert.active 1591 | ;assert.active = On 1592 | 1593 | ; Throw an AssertationException on failed assertions 1594 | ; http://php.net/assert.exception 1595 | ;assert.exception = On 1596 | 1597 | ; Issue a PHP warning for each failed assertion. (Overridden by assert.exception if active) 1598 | ; http://php.net/assert.warning 1599 | ;assert.warning = On 1600 | 1601 | ; Don't bail out by default. 1602 | ; http://php.net/assert.bail 1603 | ;assert.bail = Off 1604 | 1605 | ; User-function to be called if an assertion fails. 1606 | ; http://php.net/assert.callback 1607 | ;assert.callback = 0 1608 | 1609 | ; Eval the expression with current error_reporting(). Set to true if you want 1610 | ; error_reporting(0) around the eval(). 1611 | ; http://php.net/assert.quiet-eval 1612 | ;assert.quiet_eval = 0 1613 | 1614 | [COM] 1615 | ; path to a file containing GUIDs, IIDs or filenames of files with TypeLibs 1616 | ; http://php.net/com.typelib-file 1617 | ;com.typelib_file = 1618 | 1619 | ; allow Distributed-COM calls 1620 | ; http://php.net/com.allow-dcom 1621 | ;com.allow_dcom = true 1622 | 1623 | ; autoregister constants of a components typlib on com_load() 1624 | ; http://php.net/com.autoregister-typelib 1625 | ;com.autoregister_typelib = true 1626 | 1627 | ; register constants casesensitive 1628 | ; http://php.net/com.autoregister-casesensitive 1629 | ;com.autoregister_casesensitive = false 1630 | 1631 | ; show warnings on duplicate constant registrations 1632 | ; http://php.net/com.autoregister-verbose 1633 | ;com.autoregister_verbose = true 1634 | 1635 | ; The default character set code-page to use when passing strings to and from COM objects. 1636 | ; Default: system ANSI code page 1637 | ;com.code_page= 1638 | 1639 | [mbstring] 1640 | ; language for internal character representation. 1641 | ; This affects mb_send_mail() and mbstring.detect_order. 1642 | ; http://php.net/mbstring.language 1643 | ;mbstring.language = Japanese 1644 | 1645 | ; Use of this INI entry is deprecated, use global internal_encoding instead. 1646 | ; internal/script encoding. 1647 | ; Some encoding cannot work as internal encoding. (e.g. SJIS, BIG5, ISO-2022-*) 1648 | ; If empty, default_charset or internal_encoding or iconv.internal_encoding is used. 1649 | ; The precedence is: default_charset < internal_encoding < iconv.internal_encoding 1650 | ;mbstring.internal_encoding = 1651 | 1652 | ; Use of this INI entry is deprecated, use global input_encoding instead. 1653 | ; http input encoding. 1654 | ; mbstring.encoding_traslation = On is needed to use this setting. 1655 | ; If empty, default_charset or input_encoding or mbstring.input is used. 1656 | ; The precedence is: default_charset < intput_encoding < mbsting.http_input 1657 | ; http://php.net/mbstring.http-input 1658 | ;mbstring.http_input = 1659 | 1660 | ; Use of this INI entry is deprecated, use global output_encoding instead. 1661 | ; http output encoding. 1662 | ; mb_output_handler must be registered as output buffer to function. 1663 | ; If empty, default_charset or output_encoding or mbstring.http_output is used. 1664 | ; The precedence is: default_charset < output_encoding < mbstring.http_output 1665 | ; To use an output encoding conversion, mbstring's output handler must be set 1666 | ; otherwise output encoding conversion cannot be performed. 1667 | ; http://php.net/mbstring.http-output 1668 | ;mbstring.http_output = 1669 | 1670 | ; enable automatic encoding translation according to 1671 | ; mbstring.internal_encoding setting. Input chars are 1672 | ; converted to internal encoding by setting this to On. 1673 | ; Note: Do _not_ use automatic encoding translation for 1674 | ; portable libs/applications. 1675 | ; http://php.net/mbstring.encoding-translation 1676 | ;mbstring.encoding_translation = Off 1677 | 1678 | ; automatic encoding detection order. 1679 | ; "auto" detect order is changed according to mbstring.language 1680 | ; http://php.net/mbstring.detect-order 1681 | ;mbstring.detect_order = auto 1682 | 1683 | ; substitute_character used when character cannot be converted 1684 | ; one from another 1685 | ; http://php.net/mbstring.substitute-character 1686 | ;mbstring.substitute_character = none 1687 | 1688 | ; overload(replace) single byte functions by mbstring functions. 1689 | ; mail(), ereg(), etc are overloaded by mb_send_mail(), mb_ereg(), 1690 | ; etc. Possible values are 0,1,2,4 or combination of them. 1691 | ; For example, 7 for overload everything. 1692 | ; 0: No overload 1693 | ; 1: Overload mail() function 1694 | ; 2: Overload str*() functions 1695 | ; 4: Overload ereg*() functions 1696 | ; http://php.net/mbstring.func-overload 1697 | ;mbstring.func_overload = 0 1698 | 1699 | ; enable strict encoding detection. 1700 | ; Default: Off 1701 | ;mbstring.strict_detection = On 1702 | 1703 | ; This directive specifies the regex pattern of content types for which mb_output_handler() 1704 | ; is activated. 1705 | ; Default: mbstring.http_output_conv_mimetype=^(text/|application/xhtml\+xml) 1706 | ;mbstring.http_output_conv_mimetype= 1707 | 1708 | [gd] 1709 | ; Tell the jpeg decode to ignore warnings and try to create 1710 | ; a gd image. The warning will then be displayed as notices 1711 | ; disabled by default 1712 | ; http://php.net/gd.jpeg-ignore-warning 1713 | ;gd.jpeg_ignore_warning = 1 1714 | 1715 | [exif] 1716 | ; Exif UNICODE user comments are handled as UCS-2BE/UCS-2LE and JIS as JIS. 1717 | ; With mbstring support this will automatically be converted into the encoding 1718 | ; given by corresponding encode setting. When empty mbstring.internal_encoding 1719 | ; is used. For the decode settings you can distinguish between motorola and 1720 | ; intel byte order. A decode setting cannot be empty. 1721 | ; http://php.net/exif.encode-unicode 1722 | ;exif.encode_unicode = ISO-8859-15 1723 | 1724 | ; http://php.net/exif.decode-unicode-motorola 1725 | ;exif.decode_unicode_motorola = UCS-2BE 1726 | 1727 | ; http://php.net/exif.decode-unicode-intel 1728 | ;exif.decode_unicode_intel = UCS-2LE 1729 | 1730 | ; http://php.net/exif.encode-jis 1731 | ;exif.encode_jis = 1732 | 1733 | ; http://php.net/exif.decode-jis-motorola 1734 | ;exif.decode_jis_motorola = JIS 1735 | 1736 | ; http://php.net/exif.decode-jis-intel 1737 | ;exif.decode_jis_intel = JIS 1738 | 1739 | [Tidy] 1740 | ; The path to a default tidy configuration file to use when using tidy 1741 | ; http://php.net/tidy.default-config 1742 | ;tidy.default_config = /usr/local/lib/php/default.tcfg 1743 | 1744 | ; Should tidy clean and repair output automatically? 1745 | ; WARNING: Do not use this option if you are generating non-html content 1746 | ; such as dynamic images 1747 | ; http://php.net/tidy.clean-output 1748 | tidy.clean_output = Off 1749 | 1750 | [soap] 1751 | ; Enables or disables WSDL caching feature. 1752 | ; http://php.net/soap.wsdl-cache-enabled 1753 | soap.wsdl_cache_enabled=1 1754 | 1755 | ; Sets the directory name where SOAP extension will put cache files. 1756 | ; http://php.net/soap.wsdl-cache-dir 1757 | soap.wsdl_cache_dir="/tmp" 1758 | 1759 | ; (time to live) Sets the number of second while cached file will be used 1760 | ; instead of original one. 1761 | ; http://php.net/soap.wsdl-cache-ttl 1762 | soap.wsdl_cache_ttl=86400 1763 | 1764 | ; Sets the size of the cache limit. (Max. number of WSDL files to cache) 1765 | soap.wsdl_cache_limit = 5 1766 | 1767 | [sysvshm] 1768 | ; A default size of the shared memory segment 1769 | ;sysvshm.init_mem = 10000 1770 | 1771 | [ldap] 1772 | ; Sets the maximum number of open links or -1 for unlimited. 1773 | ldap.max_links = -1 1774 | 1775 | [mcrypt] 1776 | ; For more information about mcrypt settings see http://php.net/mcrypt-module-open 1777 | 1778 | ; Directory where to load mcrypt algorithms 1779 | ; Default: Compiled in into libmcrypt (usually /usr/local/lib/libmcrypt) 1780 | ;mcrypt.algorithms_dir= 1781 | 1782 | ; Directory where to load mcrypt modes 1783 | ; Default: Compiled in into libmcrypt (usually /usr/local/lib/libmcrypt) 1784 | ;mcrypt.modes_dir= 1785 | 1786 | [dba] 1787 | ;dba.default_handler= 1788 | 1789 | [opcache] 1790 | ; Determines if Zend OPCache is enabled 1791 | ;opcache.enable=1 1792 | 1793 | ; Determines if Zend OPCache is enabled for the CLI version of PHP 1794 | ;opcache.enable_cli=0 1795 | 1796 | ; The OPcache shared memory storage size. 1797 | ;opcache.memory_consumption=64 1798 | 1799 | ; The amount of memory for interned strings in Mbytes. 1800 | ;opcache.interned_strings_buffer=4 1801 | 1802 | ; The maximum number of keys (scripts) in the OPcache hash table. 1803 | ; Only numbers between 200 and 100000 are allowed. 1804 | ;opcache.max_accelerated_files=2000 1805 | 1806 | ; The maximum percentage of "wasted" memory until a restart is scheduled. 1807 | ;opcache.max_wasted_percentage=5 1808 | 1809 | ; When this directive is enabled, the OPcache appends the current working 1810 | ; directory to the script key, thus eliminating possible collisions between 1811 | ; files with the same name (basename). Disabling the directive improves 1812 | ; performance, but may break existing applications. 1813 | ;opcache.use_cwd=1 1814 | 1815 | ; When disabled, you must reset the OPcache manually or restart the 1816 | ; webserver for changes to the filesystem to take effect. 1817 | ;opcache.validate_timestamps=1 1818 | 1819 | ; How often (in seconds) to check file timestamps for changes to the shared 1820 | ; memory storage allocation. ("1" means validate once per second, but only 1821 | ; once per request. "0" means always validate) 1822 | ;opcache.revalidate_freq=2 1823 | 1824 | ; Enables or disables file search in include_path optimization 1825 | ;opcache.revalidate_path=0 1826 | 1827 | ; If disabled, all PHPDoc comments are dropped from the code to reduce the 1828 | ; size of the optimized code. 1829 | ;opcache.save_comments=1 1830 | 1831 | ; If enabled, a fast shutdown sequence is used for the accelerated code 1832 | ;opcache.fast_shutdown=0 1833 | 1834 | ; Allow file existence override (file_exists, etc.) performance feature. 1835 | ;opcache.enable_file_override=0 1836 | 1837 | ; A bitmask, where each bit enables or disables the appropriate OPcache 1838 | ; passes 1839 | ;opcache.optimization_level=0xffffffff 1840 | 1841 | ;opcache.inherited_hack=1 1842 | ;opcache.dups_fix=0 1843 | 1844 | ; The location of the OPcache blacklist file (wildcards allowed). 1845 | ; Each OPcache blacklist file is a text file that holds the names of files 1846 | ; that should not be accelerated. The file format is to add each filename 1847 | ; to a new line. The filename may be a full path or just a file prefix 1848 | ; (i.e., /var/www/x blacklists all the files and directories in /var/www 1849 | ; that start with 'x'). Line starting with a ; are ignored (comments). 1850 | ;opcache.blacklist_filename= 1851 | 1852 | ; Allows exclusion of large files from being cached. By default all files 1853 | ; are cached. 1854 | ;opcache.max_file_size=0 1855 | 1856 | ; Check the cache checksum each N requests. 1857 | ; The default value of "0" means that the checks are disabled. 1858 | ;opcache.consistency_checks=0 1859 | 1860 | ; How long to wait (in seconds) for a scheduled restart to begin if the cache 1861 | ; is not being accessed. 1862 | ;opcache.force_restart_timeout=180 1863 | 1864 | ; OPcache error_log file name. Empty string assumes "stderr". 1865 | ;opcache.error_log= 1866 | 1867 | ; All OPcache errors go to the Web server log. 1868 | ; By default, only fatal errors (level 0) or errors (level 1) are logged. 1869 | ; You can also enable warnings (level 2), info messages (level 3) or 1870 | ; debug messages (level 4). 1871 | ;opcache.log_verbosity_level=1 1872 | 1873 | ; Preferred Shared Memory back-end. Leave empty and let the system decide. 1874 | ;opcache.preferred_memory_model= 1875 | 1876 | ; Protect the shared memory from unexpected writing during script execution. 1877 | ; Useful for internal debugging only. 1878 | ;opcache.protect_memory=0 1879 | 1880 | ; Allows calling OPcache API functions only from PHP scripts which path is 1881 | ; started from specified string. The default "" means no restriction 1882 | ;opcache.restrict_api= 1883 | 1884 | ; Mapping base of shared memory segments (for Windows only). All the PHP 1885 | ; processes have to map shared memory into the same address space. This 1886 | ; directive allows to manually fix the "Unable to reattach to base address" 1887 | ; errors. 1888 | ;opcache.mmap_base= 1889 | 1890 | ; Enables and sets the second level cache directory. 1891 | ; It should improve performance when SHM memory is full, at server restart or 1892 | ; SHM reset. The default "" disables file based caching. 1893 | ;opcache.file_cache= 1894 | 1895 | ; Enables or disables opcode caching in shared memory. 1896 | ;opcache.file_cache_only=0 1897 | 1898 | ; Enables or disables checksum validation when script loaded from file cache. 1899 | ;opcache.file_cache_consistency_checks=1 1900 | 1901 | ; Implies opcache.file_cache_only=1 for a certain process that failed to 1902 | ; reattach to the shared memory (for Windows only). Explicitly enabled file 1903 | ; cache is required. 1904 | ;opcache.file_cache_fallback=1 1905 | 1906 | ; Enables or disables copying of PHP code (text segment) into HUGE PAGES. 1907 | ; This should improve performance, but requires appropriate OS configuration. 1908 | ;opcache.huge_code_pages=1 1909 | 1910 | ; Validate cached file permissions. 1911 | ;opcache.validate_permission=0 1912 | 1913 | ; Prevent name collisions in chroot'ed environment. 1914 | ;opcache.validate_root=0 1915 | 1916 | [curl] 1917 | ; A default value for the CURLOPT_CAINFO option. This is required to be an 1918 | ; absolute path. 1919 | ;curl.cainfo = 1920 | 1921 | [openssl] 1922 | ; The location of a Certificate Authority (CA) file on the local filesystem 1923 | ; to use when verifying the identity of SSL/TLS peers. Most users should 1924 | ; not specify a value for this directive as PHP will attempt to use the 1925 | ; OS-managed cert stores in its absence. If specified, this value may still 1926 | ; be overridden on a per-stream basis via the "cafile" SSL stream context 1927 | ; option. 1928 | ;openssl.cafile= 1929 | 1930 | ; If openssl.cafile is not specified or if the CA file is not found, the 1931 | ; directory pointed to by openssl.capath is searched for a suitable 1932 | ; certificate. This value must be a correctly hashed certificate directory. 1933 | ; Most users should not specify a value for this directive as PHP will 1934 | ; attempt to use the OS-managed cert stores in its absence. If specified, 1935 | ; this value may still be overridden on a per-stream basis via the "capath" 1936 | ; SSL stream context option. 1937 | ;openssl.capath= 1938 | 1939 | ; Local Variables: 1940 | ; tab-width: 4 1941 | ; End: 1942 | 1943 | -------------------------------------------------------------------------------- /general/web_server/compile_php7.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #------------------------------------------# 4 | # This script compiles PHP 7+. # 5 | # # 6 | # Author: Jack Cherng # 7 | #------------------------------------------# 8 | 9 | SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" 10 | THREAD_CNT=$(getconf _NPROCESSORS_ONLN) 11 | MEMSIZE_MB=$(free -m | awk '/^Mem:/{print $2}') 12 | 13 | NOW="$(date +%Y%m%d%H%M%S)" 14 | LOG_FILE="${SCRIPT_DIR}/compile_php7-${NOW}.log" 15 | 16 | function git_repo_clean { 17 | make clean >/dev/null 2>&1 18 | git clean -dfx 19 | git checkout -- . 20 | } 21 | 22 | declare -A PHP_CMD=( 23 | ["libzip"]="git clone https://github.com/nih-at/libzip.git" 24 | ["php-src"]="git clone https://github.com/php/php-src.git" 25 | ) 26 | 27 | { 28 | 29 | #-------# 30 | # begin # 31 | #-------# 32 | 33 | pushd "${SCRIPT_DIR}" || exit 34 | 35 | # prefer the latest user-installed libs if possible 36 | PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:${PKG_CONFIG_PATH}" 37 | 38 | #-------------# 39 | # check repos # 40 | #-------------# 41 | 42 | for repoName in "${!PHP_CMD[@]}"; do 43 | echo "===================================" 44 | echo "Check '${repoName}' repo..." 45 | echo "===================================" 46 | # clone new repos 47 | if [ ! -d "${repoName}/.git" ]; then 48 | rm -rf "${repoName}" 49 | eval "${PHP_CMD[${repoName}]}" || exit 50 | fi 51 | 52 | pushd "${repoName}" || exit 53 | 54 | git_repo_clean 55 | 56 | # fetch the latest source 57 | git fetch --tags --force --prune --all && git reset --hard "@{upstream}" 58 | git submodule update --init 59 | git submodule foreach --recursive git pull 60 | 61 | popd || exit 62 | done 63 | 64 | #----------------------# 65 | # read option: php_rev # 66 | #----------------------# 67 | 68 | read -erp "PHP revision to be compiled (such as '7.3.2', '3c3775fc38' or 'origin/master'): " php_rev 69 | 70 | pushd "php-src" || exit 71 | 72 | # some possible revisions to be tried 73 | php_test_revs=( 74 | # tags 75 | "tags/${php_rev}" 76 | "tags/php-${php_rev}" 77 | "tags/php-${php_rev^^}" # all uppercase, such as "RC" 78 | "tags/php-${php_rev,,}" # all lowercase, such as "alpha" 79 | # branches 80 | "origin/${php_rev}" 81 | "origin/PHP-${php_rev}" 82 | "origin/PHP-${php_rev^^}" # all uppercase, such as "RC" 83 | "origin/PHP-${php_rev,,}" # all lowercase, such as "alpha" 84 | # customized 85 | "${php_rev}" 86 | "${php_rev^^}" 87 | "${php_rev,,}" 88 | ) 89 | 90 | php_full_rev="" 91 | for php_test_rev in "${php_test_revs[@]}"; do 92 | if git rev-parse --verify "${php_test_rev}" 2>/dev/null; then 93 | php_full_rev="${php_test_rev}" 94 | break 95 | fi 96 | done 97 | 98 | if [ "${php_full_rev}" = "" ]; then 99 | echo "[*] Cannot found related PHP revision: ${php_rev}" 100 | exit 1 101 | fi 102 | 103 | echo "[*] Use PHP revision: ${php_full_rev}" 104 | 105 | # such as "7.3.0" 106 | php_version=$(git show "${php_full_rev}:./NEWS" | command grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1) 107 | # such as "7.3.0" => "73" 108 | php_version_path=$(echo "${php_version}" | sed -r 's/^([0-9]+)(\.([0-9]+))?.*$/\1\3/g') 109 | # such as "73" => "/usr/local/php73" 110 | php_install_dir_default="/usr/local/php${php_version_path}" 111 | 112 | popd || exit 113 | 114 | #------------------------------# 115 | # read option: php_install_dir # 116 | #------------------------------# 117 | 118 | read -erp "Where to install PHP (default = '${php_install_dir_default}'): " php_install_dir 119 | 120 | if [ "${php_install_dir}" = "" ]; then 121 | php_install_dir=${php_install_dir_default} 122 | echo "[*] Use '${php_install_dir}' as the default install path." 123 | fi 124 | 125 | #---------------------------# 126 | # read option: php_run_user # 127 | #---------------------------# 128 | 129 | php_run_user_default="www" 130 | 131 | read -erp "Which user to launch PHP-FPM (default = '${php_run_user_default}'): " php_run_user 132 | 133 | if [ "${php_run_user}" = "" ]; then 134 | php_run_user=${php_run_user_default} 135 | echo "[*] Use '${php_run_user}' as the default user." 136 | fi 137 | 138 | #-----------------------------# 139 | # read option: compile_libzip # 140 | #-----------------------------# 141 | 142 | read -erp "Compile libzip library (Y/n): " compile_libzip 143 | 144 | compile_libzip=${compile_libzip^^} 145 | if [ "${compile_libzip}" != "N" ]; then 146 | compile_libzip="Y" 147 | fi 148 | 149 | #---------------------------# 150 | # read option: thread_count # 151 | #---------------------------# 152 | 153 | read -erp "Parallel compilation with thread counts (default = ${THREAD_CNT}): " thread_count 154 | 155 | if [ "${thread_count}" = "" ]; then 156 | thread_count=${THREAD_CNT} 157 | fi 158 | 159 | #--------------# 160 | # confirmation # 161 | #--------------# 162 | 163 | echo 164 | echo "===================================" 165 | echo "compile_libzip = ${compile_libzip}" 166 | echo "thread_count = ${thread_count}" 167 | echo "php_full_rev = ${php_full_rev}" 168 | echo "php_install_dir = ${php_install_dir}" 169 | echo "php_run_user = ${php_run_user}" 170 | echo "===================================" 171 | echo 172 | echo "Is the above information correct?" 173 | echo "Press any key to start or Ctrl+C to cancel." 174 | read -rn 1 # wait for a key press 175 | echo 176 | 177 | #-----------------# 178 | # compile libdzip # 179 | #-----------------# 180 | 181 | if [ "${compile_libzip}" = "Y" ]; then 182 | 183 | echo "===================================" 184 | echo "Begin compile 'libzip'..." 185 | echo "===================================" 186 | 187 | pushd "libzip" || exit 188 | 189 | rm -rf "build" && mkdir "build" 190 | pushd "build" || exit 191 | cmake .. || exit 192 | make clean 193 | make -j "${thread_count}" || exit 194 | make install || exit 195 | popd || exit 196 | 197 | popd || exit 198 | 199 | echo "===================================" 200 | echo "End compile 'libzip'..." 201 | echo "===================================" 202 | 203 | fi 204 | 205 | #-------------# 206 | # compile PHP # 207 | #-------------# 208 | 209 | echo "===================================" 210 | echo "Begin install 'PHP' dependencies..." 211 | echo "===================================" 212 | 213 | # yum 214 | if command -v yum >/dev/null 2>&1; then 215 | yum install -y --skip-broken \ 216 | aspell-en aspell-devel \ 217 | bison \ 218 | bzip2 bzip2-devel \ 219 | curl curl-devel \ 220 | freetype-devel \ 221 | gmp-devel \ 222 | icu libicu libicu-devel \ 223 | libc-client uw-imap-devel \ 224 | libffi libffi-devel \ 225 | libjpeg-devel libpng-devel libwebp7-devel libwebp-devel libXpm-devel \ 226 | libsodium libsodium-devel \ 227 | libxml2 libxml2-devel \ 228 | libxslt libxslt-devel \ 229 | ncurses ncurses-devel \ 230 | pcre-devel oniguruma-devel \ 231 | re2c \ 232 | readline-devel \ 233 | sqlite-devel 234 | # apt 235 | elif command -v apt >/dev/null 2>&1; then 236 | apt update 237 | apt install -y \ 238 | bison \ 239 | bzip2 bzip2-dev \ 240 | libc-client-dev libkrb5-dev \ 241 | libffi libffi-dev \ 242 | libfreetype6-dev \ 243 | libgmp-dev \ 244 | libjpeg-dev libpng-dev libwebp-dev libwebp7-dev libxpm-dev \ 245 | libncurses libncurses-dev \ 246 | libonig libonig-dev \ 247 | libsodium23 libsodium-dev \ 248 | libsqlite3 libsqlite3-dev \ 249 | libxml2 libxml2-dev \ 250 | re2c \ 251 | sqlite-devel 252 | else 253 | echo "Could not find 'yum' or 'apt'..." 254 | fi 255 | 256 | echo "===================================" 257 | echo "End install 'PHP' dependencies..." 258 | echo "===================================" 259 | 260 | echo "===================================" 261 | echo "Begin compile 'PHP'..." 262 | echo "===================================" 263 | 264 | # add user custom libs into search paths 265 | cat </etc/ld.so.conf.d/usr-local.conf 266 | /usr/local/lib 267 | /usr/local/lib64 268 | EOT 269 | 270 | # update library link paths 271 | ldconfig 272 | 273 | LOW_MEMORY_FLAGS=() 274 | 275 | if [ "${MEMSIZE_MB}" -lt "512" ]; then 276 | LOW_MEMORY_FLAGS+=('--disable-fileinfo') 277 | fi 278 | 279 | EXTRA_FLAGS=() 280 | 281 | # if we could link to the iconv library, add a flag for it 282 | if ldconfig -p | grep libiconv >/dev/null 2>&1; then 283 | EXTRA_FLAGS+=('-liconv') 284 | fi 285 | 286 | pushd "php-src" || exit 287 | 288 | git_repo_clean 289 | 290 | git checkout -f "${php_full_rev}" 291 | git reset --hard "@{upstream}" 292 | git submodule update --init 293 | git submodule foreach --recursive git pull 294 | 295 | # use the git commit hash to replace the "-dev" in the PHP version tag 296 | sed -i"" -E "s/-dev/-dev@$(git rev-parse --short HEAD)/g" ./configure.ac 297 | 298 | ./buildconf --force 299 | 300 | # there are some mixed --enable/--with switches because some of them are different among versions. 301 | # for example, gd/zlib switches have been changed since PHP 7.4. 302 | ./configure \ 303 | --prefix="${php_install_dir}" \ 304 | --with-config-file-path="${php_install_dir}/etc" \ 305 | --with-config-file-scan-dir="${php_install_dir}/etc/php.d" \ 306 | --with-fpm-group="${php_run_user}" \ 307 | --with-fpm-user="${php_run_user}" \ 308 | --disable-debug \ 309 | --disable-phpdbg \ 310 | --disable-rpath \ 311 | --enable-bcmath \ 312 | --enable-calendar \ 313 | --enable-exif \ 314 | --enable-fpm \ 315 | --enable-ftp \ 316 | --enable-inline-optimization \ 317 | --enable-intl \ 318 | --enable-mbregex --enable-mbstring \ 319 | --enable-pcntl \ 320 | --enable-shmop \ 321 | --enable-soap \ 322 | --enable-sockets \ 323 | --enable-sysvmsg --enable-sysvsem --enable-sysvshm \ 324 | --enable-wddx \ 325 | --enable-xml \ 326 | --enable-zip \ 327 | --with-bz2 \ 328 | --with-curl="/usr/local" \ 329 | --with-ffi \ 330 | --with-gd --enable-gd \ 331 | --enable-gd-native-ttf --enable-gd-jis-conv \ 332 | --with-freetype-dir --with-freetype \ 333 | --with-jpeg-dir --with-jpeg \ 334 | --with-png-dir --with-png \ 335 | --with-webp-dir --with-webp \ 336 | --with-xpm-dir --with-xpm \ 337 | --with-gettext \ 338 | --with-gmp \ 339 | --with-iconv-dir="/usr/local" \ 340 | --with-imap --with-kerberos --with-imap-ssl --with-libdir="lib64" \ 341 | --with-libxml-dir="/usr" \ 342 | --with-libzip="/usr/local" \ 343 | --with-mhash \ 344 | --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd \ 345 | --with-openssl \ 346 | --with-pspell \ 347 | --with-readline \ 348 | --with-xmlrpc \ 349 | --with-xsl \ 350 | --with-zip \ 351 | --with-zlib --with-zlib-dir \ 352 | LDFLAGS="${EXTRA_FLAGS[*]}" \ 353 | ${LOW_MEMORY_FLAGS[*]} 354 | 355 | # PEAR is no longer maintained, ignore errors about PEAR 356 | sed -i"" -E "s/^(install-pear):/.IGNORE: \1\n\1:/g" ./Makefile 357 | 358 | make -j"${thread_count}" install ZEND_EXTRA_LIBS="${EXTRA_FLAGS[*]}" || exit 359 | git_repo_clean 360 | 361 | popd || exit 362 | 363 | echo "===================================" 364 | echo "End compile 'PHP'..." 365 | echo "===================================" 366 | 367 | #-----# 368 | # end # 369 | #-----# 370 | 371 | "${php_install_dir}/bin/php" -v 372 | 373 | # try to restart the daemon if PHP works normally 374 | if [ $? -eq 0 ]; then 375 | daemon="/etc/init.d/php${php_version_path}-fpm" 376 | 377 | [ -x "${daemon}" ] && "${daemon}" restart 378 | fi 379 | 380 | popd || exit 381 | 382 | } 2>&1 | tee "${LOG_FILE}" 383 | -------------------------------------------------------------------------------- /general/web_server/compile_php_exts.ini: -------------------------------------------------------------------------------- 1 | ; this is the extra php.ini config 2 | ; for extensions compiled from compile_php_exts.sh 3 | 4 | ;zend_extension=xdebug.so 5 | 6 | extension=apcu.so 7 | extension=ast.so 8 | extension=ds.so 9 | extension=event.so 10 | extension=hashids.so 11 | extension=igbinary.so 12 | extension=imagick.so 13 | extension=mcrypt.so 14 | extension=mongodb.so 15 | extension=msgpack.so 16 | extension=mysql.so 17 | extension=redis.so 18 | extension=sodium.so 19 | extension=ssh2.so 20 | extension=swoole.so 21 | extension=xlswriter.so 22 | 23 | [igbinary] 24 | ; Use igbinary as session serializer 25 | session.serialize_handler=igbinary 26 | ; Enable or disable compacting of duplicate strings 27 | igbinary.compact_strings=On 28 | ; Use igbinary as serializer in APC cache (3.1.7 or later) 29 | apc.serializer=igbinary 30 | 31 | [opcache] 32 | zend_extension=opcache.so 33 | opcache.enable=1 34 | opcache.enable_cli=1 35 | opcache.memory_consumption=384 36 | opcache.interned_strings_buffer=8 37 | opcache.max_accelerated_files=100000 38 | opcache.max_wasted_percentage=5 39 | opcache.use_cwd=1 40 | opcache.validate_timestamps=1 41 | opcache.revalidate_freq=60 42 | opcache.save_comments=1 43 | opcache.fast_shutdown=1 44 | opcache.consistency_checks=0 45 | ;opcache.optimization_level=0 46 | 47 | [MySQL] 48 | ; Allow accessing, from PHP's perspective, local files with LOAD DATA statements 49 | ; http://php.net/mysql.allow_local_infile 50 | mysql.allow_local_infile = On 51 | 52 | ; Allow or prevent persistent links. 53 | ; http://php.net/mysql.allow-persistent 54 | mysql.allow_persistent = On 55 | 56 | ; If mysqlnd is used: Number of cache slots for the internal result set cache 57 | ; http://php.net/mysql.cache_size 58 | mysql.cache_size = 2000 59 | 60 | ; Maximum number of persistent links. -1 means no limit. 61 | ; http://php.net/mysql.max-persistent 62 | mysql.max_persistent = -1 63 | 64 | ; Maximum number of links (persistent + non-persistent). -1 means no limit. 65 | ; http://php.net/mysql.max-links 66 | mysql.max_links = -1 67 | 68 | ; Default port number for mysql_connect(). If unset, mysql_connect() will use 69 | ; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the 70 | ; compile-time value defined MYSQL_PORT (in that order). Win32 will only look 71 | ; at MYSQL_PORT. 72 | ; http://php.net/mysql.default-port 73 | mysql.default_port = 74 | 75 | ; Default socket name for local MySQL connects. If empty, uses the built-in 76 | ; MySQL defaults. 77 | ; http://php.net/mysql.default-socket 78 | mysql.default_socket = 79 | 80 | ; Default host for mysql_connect() (doesn't apply in safe mode). 81 | ; http://php.net/mysql.default-host 82 | mysql.default_host = 83 | 84 | ; Default user for mysql_connect() (doesn't apply in safe mode). 85 | ; http://php.net/mysql.default-user 86 | mysql.default_user = 87 | 88 | ; Default password for mysql_connect() (doesn't apply in safe mode). 89 | ; Note that this is generally a *bad* idea to store passwords in this file. 90 | ; *Any* user with PHP access can run 'echo get_cfg_var("mysql.default_password") 91 | ; and reveal this password! And of course, any users with read access to this 92 | ; file will be able to reveal the password as well. 93 | ; http://php.net/mysql.default-password 94 | mysql.default_password = 95 | 96 | ; Maximum time (in seconds) for connect timeout. -1 means no limit 97 | ; http://php.net/mysql.connect-timeout 98 | mysql.connect_timeout = 60 99 | 100 | ; Trace mode. When trace_mode is active (=On), warnings for table/index scans and 101 | ; SQL-Errors will be displayed. 102 | ; http://php.net/mysql.trace-mode 103 | mysql.trace_mode = Off 104 | -------------------------------------------------------------------------------- /general/web_server/compile_php_exts.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #--------------------------------------------------# 4 | # This script compiles some extensions for PHP 7+. # 5 | # # 6 | # Author: Jack Cherng # 7 | #--------------------------------------------------# 8 | 9 | SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" 10 | THREAD_CNT=$(getconf _NPROCESSORS_ONLN) 11 | 12 | NOW="$(date +%Y%m%d%H%M%S)" 13 | LOG_FILE="${SCRIPT_DIR}/compile_php_exts-${NOW}.log" 14 | 15 | PHP_BASE_DIRS=( 16 | "/usr/local/php70" 17 | "/usr/local/php71" 18 | "/usr/local/php72" 19 | "/usr/local/php73" 20 | "/usr/local/php74" 21 | "/usr/local/php80" 22 | "/usr/local/php81" 23 | "/usr/local/php82" 24 | "/usr/local/php83" 25 | ) 26 | 27 | # the command used to clone a repo 28 | declare -A PHP_EXTS_CMD=( 29 | ["apcu"]="git clone https://github.com/krakjoe/apcu.git apcu" 30 | ["ast"]="git clone https://github.com/nikic/php-ast.git ast" 31 | ["ds"]="git clone https://github.com/php-ds/extension.git ds" 32 | ["event"]="git clone https://bitbucket.org/osmanov/pecl-event.git event" 33 | ["hashids"]="git clone https://github.com/cdoco/hashids.phpc.git hashids" 34 | ["igbinary"]="git clone https://github.com/igbinary/igbinary.git igbinary" 35 | ["imagick"]="git clone https://github.com/mkoppanen/imagick.git imagick" 36 | ["mcrypt"]="git clone https://github.com/php/pecl-encryption-mcrypt mcrypt" 37 | ["mongodb"]="git clone https://github.com/mongodb/mongo-php-driver.git mongodb" 38 | ["msgpack"]="git clone https://github.com/msgpack/msgpack-php.git msgpack" 39 | ["mysql"]="git clone https://github.com/php/pecl-database-mysql.git --recursive mysql" 40 | ["redis"]="git clone https://github.com/phpredis/phpredis.git redis" 41 | ["sodium"]="git clone https://github.com/jedisct1/libsodium-php.git sodium" 42 | ["ssh2"]="git clone https://github.com/php/pecl-networking-ssh2.git ssh2" 43 | ["swoole"]="git clone https://github.com/swoole/swoole-src.git swoole" 44 | ["xdebug"]="git clone https://github.com/xdebug/xdebug.git xdebug" 45 | ["xlswriter"]="git clone https://github.com/viest/php-ext-excel-export.git xlswriter" 46 | ) 47 | 48 | # checkout repo to a specific commit before compilation 49 | declare -A PHP_EXTS_CHECKOUT=( 50 | ["swoole"]="v5.0.3" 51 | ) 52 | 53 | # extra flags appended to php-config 54 | declare -A PHP_EXTS_CONFIG=( 55 | ["imagick"]="--with-imagick=/usr/local/imagemagick" 56 | ["redis"]="--enable-redis-igbinary --enable-redis-lzf" 57 | ["xdebug"]="--enable-xdebug" 58 | ) 59 | 60 | function tab_title { 61 | if [ -z "$1" ]; then 62 | title=${PWD##*/} # current directory 63 | else 64 | title=$1 # first param 65 | fi 66 | 67 | echo -n -e "\033]0;${title}\007" 68 | } 69 | 70 | function git_repo_clean { 71 | make clean >/dev/null 2>&1 72 | git clean -dfx 73 | git checkout -- . 74 | } 75 | 76 | { 77 | 78 | #-------# 79 | # begin # 80 | #-------# 81 | 82 | pushd "${SCRIPT_DIR}" || exit 83 | 84 | # prefer the latest user-installed libs if possible 85 | PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:${PKG_CONFIG_PATH}" 86 | 87 | #-----------------------------------------# 88 | # filter out useless PHP base directories # 89 | #-----------------------------------------# 90 | 91 | for IDX in "${!PHP_BASE_DIRS[@]}"; do 92 | PHP_BASE_DIR=${PHP_BASE_DIRS[${IDX}]} 93 | 94 | # required files 95 | declare -A files=( 96 | ["phpize"]="${PHP_BASE_DIR}/bin/phpize" 97 | ["php_config"]="${PHP_BASE_DIR}/bin/php-config" 98 | ) 99 | 100 | # eleminate PHP base directory if required files not found 101 | for file in "${files[@]}"; do 102 | if [ ! -f "${file}" ]; then 103 | echo "[*] Skip '${PHP_BASE_DIR}' because '${file}' is not a file..." 104 | unset PHP_BASE_DIRS["${IDX}"] 105 | continue 2 106 | fi 107 | done 108 | done 109 | 110 | #----------------------# 111 | # install dependencies # 112 | #----------------------# 113 | 114 | echo "===================================" 115 | echo "Begin install 'PHP' dependencies..." 116 | echo "===================================" 117 | 118 | # yum 119 | if command -v yum >/dev/null 2>&1; then 120 | yum install -y --skip-broken \ 121 | mpdecimal mpdecimal-devel \ 122 | libsodium libsodium-devel \ 123 | liblzf liblzf-devel \ 124 | ImageMagick ImageMagick-devel ImageMagick-perl 125 | # apt 126 | elif command -v apt >/dev/null 2>&1; then 127 | apt update 128 | apt install -y \ 129 | libmpdec libmpdec-dev \ 130 | libsodium23 libsodium-dev 131 | else 132 | echo "Could not find 'yum' or 'apt'..." 133 | fi 134 | 135 | #------------------------# 136 | # compile PHP extensions # 137 | #------------------------# 138 | 139 | BUILD_DIR="${SCRIPT_DIR}/php_exts_clone" 140 | 141 | mkdir -p "${BUILD_DIR}" 142 | 143 | pushd "${BUILD_DIR}" || exit 144 | 145 | for PHP_EXT_NAME in "${!PHP_EXTS_CMD[@]}"; do 146 | echo "===================================" 147 | echo "Begin compile '${PHP_EXT_NAME}'..." 148 | echo "===================================" 149 | 150 | # clone new repos 151 | if [ ! -d "${PHP_EXT_NAME}/.git" ]; then 152 | rm -rf "${PHP_EXT_NAME}" 153 | eval "${PHP_EXTS_CMD[${PHP_EXT_NAME}]}" || exit 154 | fi 155 | 156 | pushd "${PHP_EXT_NAME}/" || exit 157 | 158 | git_repo_clean 159 | 160 | # fetch the latest source 161 | git fetch --tags --force --prune --all && git reset --hard "@{upstream}" 162 | git submodule update --init --force 163 | git submodule foreach --recursive git pull 164 | 165 | # checkout a specific commit 166 | commit=${PHP_EXTS_CHECKOUT[${PHP_EXT_NAME}]} 167 | if [ "${commit}" != "" ]; then 168 | git checkout -f "${commit}" 169 | fi 170 | 171 | for PHP_BASE_DIR in "${PHP_BASE_DIRS[@]}"; do 172 | # paths 173 | phpize="${PHP_BASE_DIR}/bin/phpize" 174 | php_config="${PHP_BASE_DIR}/bin/php-config" 175 | config_options=${PHP_EXTS_CONFIG[${PHP_EXT_NAME}]} 176 | 177 | # set tab title (for tmux) 178 | tab_title "${PHP_BASE_DIR}: ${PHP_EXT_NAME}" 179 | 180 | # compile 181 | "${phpize}" 182 | ./configure --with-php-config="${php_config}" ${config_options} 183 | make -j"${THREAD_CNT}" install 184 | git_repo_clean 185 | done 186 | 187 | popd || exit 188 | 189 | # restore tab title 190 | tab_title 191 | 192 | echo "===================================" 193 | echo "End compile '${PHP_EXT_NAME}'..." 194 | echo "===================================" 195 | done 196 | 197 | popd || exit 198 | 199 | #-----# 200 | # end # 201 | #-----# 202 | 203 | # restore tab title 204 | tab_title 205 | 206 | popd || exit 207 | 208 | } | tee "${LOG_FILE}" 209 | -------------------------------------------------------------------------------- /general/web_server/extract_uniq_url.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | command grep -hoE "https?://[^ ,;()'\"]+" -- *.log | 4 | sed -E "s;^https:;http:;g" | 5 | sed -E "s;//www\.;//;g" | 6 | sed -E "s;/$;;g" | 7 | sort | 8 | uniq 9 | -------------------------------------------------------------------------------- /general/web_server/prefer_latest_kernel.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | grep CentOS <"/boot/grub2/grub.cfg" 4 | 5 | if [ "$?" = "1" ]; then 6 | echo "This script only designed to work on CentOS..." 7 | exit 1 8 | fi 9 | 10 | grub2-set-default 0 11 | grub2-editenv list 12 | grub2-mkconfig -o "/etc/grub2.cfg" 13 | 14 | echo "The system will use the latest kernel as of next boot..." 15 | -------------------------------------------------------------------------------- /sublime_hq/mirror_official_docs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" 4 | NOW="$(date +'%Y/%m/%d %H:%M:%S')" 5 | TODAY="$(date +'%Y%m%d')" 6 | 7 | # ------ # 8 | # colors # 9 | # ------ # 10 | 11 | if [[ ${FORCE_COLOR} == "0" ]]; then 12 | C_RESET="" 13 | H_DEBUG="[DEBUG]" 14 | H_INFO="[INFO]" 15 | H_WARNING="[WARNING]" 16 | H_ERROR="[ERROR]" 17 | else 18 | C_RESET="\e[0m" 19 | H_DEBUG="[\e[0;30;47mDEBUG${C_RESET}]" 20 | H_INFO="[\e[0;37;44mINFO${C_RESET}]" 21 | H_WARNING="[\e[0;30;43mWARNING${C_RESET}]" 22 | H_ERROR="[\e[0;37;41mERROR${C_RESET}]" 23 | fi 24 | 25 | #---------# 26 | # configs # 27 | #---------# 28 | 29 | HTTRACK=${HTTRACK:-"httrack"} 30 | USER_AGENT=${USER_AGENT-"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36"} 31 | FOOTER=${FOOTER-"
Snapshot on ${NOW}
"} 32 | 33 | function mirror() { 34 | local output_dir="$1" 35 | local start_url="$2" 36 | 37 | rm -rf "${output_dir}" 38 | 39 | pushd "${SCRIPT_DIR}" || exit 40 | 41 | echo -e "${H_INFO} ⌛ Downloading..." 42 | 43 | "${HTTRACK}" \ 44 | --path "${output_dir}" \ 45 | --user-agent "${USER_AGENT}" \ 46 | --referer "${start_url}" \ 47 | --mirror "${start_url}" \ 48 | --footer "${FOOTER}" \ 49 | --stay-on-same-address \ 50 | --display \ 51 | --quiet \ 52 | --max-rate=0 \ 53 | +*.png +*.gif +*.jpg +*.jpeg +*.webp +*.svg +*.css +*.js \ 54 | -ad.doubleclick.net/* 55 | 56 | # redirect index page to website index 57 | index_file="${output_dir}/index.html" 58 | if [ -f "${index_file}" ]; then 59 | index_url=$(sed -zE 's/.* HREF="([^"]+)".*/\1/g' "${index_file}") 60 | echo "" \ 61 | >"${output_dir}/index.html" 62 | fi 63 | 64 | cleanup "${output_dir}" 65 | 66 | popd || exit 67 | } 68 | 69 | function cleanup() { 70 | local output_dir="$1" 71 | 72 | pushd "${output_dir}" || exit 73 | 74 | echo -e "${H_INFO} 🧹 Clean up..." 75 | 76 | rm -rf \ 77 | hts-cache/ \ 78 | hts-log.txt \ 79 | ./*.gif 80 | 81 | popd || exit 82 | } 83 | 84 | mirror \ 85 | "${SCRIPT_DIR}/docs/ST_official_docs_${TODAY}" \ 86 | "https://www.sublimetext.com/docs/index.html" 87 | 88 | mirror \ 89 | "${SCRIPT_DIR}/docs/SM_official_docs_${TODAY}" \ 90 | "https://www.sublimemerge.com/docs/index.html" 91 | -------------------------------------------------------------------------------- /sublime_hq/update_official_packages.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" 4 | 5 | # ------ # 6 | # colors # 7 | # ------ # 8 | 9 | if [[ ${FORCE_COLOR} == "0" ]]; then 10 | C_RESET="" 11 | H_DEBUG="[DEBUG]" 12 | H_INFO="[INFO]" 13 | H_WARNING="[WARNING]" 14 | H_ERROR="[ERROR]" 15 | else 16 | C_RESET="\e[0m" 17 | H_DEBUG="[\e[0;30;47mDEBUG${C_RESET}]" 18 | H_INFO="[\e[0;37;44mINFO${C_RESET}]" 19 | H_WARNING="[\e[0;30;43mWARNING${C_RESET}]" 20 | H_ERROR="[\e[0;37;41mERROR${C_RESET}]" 21 | fi 22 | 23 | #---------# 24 | # configs # 25 | #---------# 26 | 27 | TEMP_DIR="${SCRIPT_DIR}/.Sublime-Official-Packages" 28 | PKG_GITHUB_URL="https://github.com/sublimehq/Packages" 29 | PKG_REMOTE_REPO="${PKG_GITHUB_URL}.git" 30 | 31 | ST_INSTALL_DIRS=( 32 | # this script's dir and its parents (in case you put this script in "Data/" or deeper) 33 | "${SCRIPT_DIR}" 34 | "${SCRIPT_DIR}/.." 35 | "${SCRIPT_DIR}/../.." 36 | # Windows 37 | "C:/Program Files/Sublime Text" 38 | "C:/Program Files/Sublime Text 3" 39 | # Linux 40 | "${HOME}/opt/sublime_text" 41 | "${HOME}/opt/sublime_text_3" 42 | "/opt/sublime_text" 43 | "/opt/sublime_text_3" 44 | # Mac 45 | "/Applications/Sublime Text.app/Contents/MacOS" 46 | "/Applications/Sublime Text 3.app/Contents/MacOS" 47 | ) 48 | 49 | #-----------# 50 | # functions # 51 | #-----------# 52 | 53 | pushd() { 54 | # suppress messages from pushd, which is usually verbose 55 | command pushd "$@" >/dev/null 56 | } 57 | 58 | popd() { 59 | # suppress messages from popd, which is usually verbose 60 | command popd >/dev/null 61 | } 62 | 63 | ## 64 | ## @brief Clone the repo with ref 65 | ## 66 | ## @param $1 Destination directory 67 | ## @param $2 Repo URL 68 | ## @param $3 Commit ref 69 | ## 70 | ## @return The return code of last git operation 71 | ## 72 | clone_repo_ref() { 73 | local repo_dir="$1" 74 | local repo_url="$2" 75 | local commit_ref="$3" 76 | 77 | rm -rf "${repo_dir}" && mkdir -p "${repo_dir}" 78 | pushd "${repo_dir}" || exit 79 | 80 | # @see https://stackoverflow.com/questions/3489173 81 | git init 82 | git remote add origin "${repo_url}" 83 | git fetch --depth=1 origin "${commit_ref}" 84 | git cherry-pick -n FETCH_HEAD 85 | local retcode="$?" 86 | 87 | popd || exit 88 | 89 | return "${retcode}" 90 | } 91 | 92 | #-------# 93 | # begin # 94 | #-------# 95 | 96 | rm -rf "${TEMP_DIR}" && mkdir -p "${TEMP_DIR}" 97 | 98 | #-------------------------------------------# 99 | # try to find the ST installation directory # 100 | #-------------------------------------------# 101 | 102 | paths_to_check=( 103 | "Packages/" 104 | "changelog.txt" 105 | ) 106 | 107 | for st_install_dir in "${ST_INSTALL_DIRS[@]}"; do 108 | st_install_dir="${st_install_dir%/}" 109 | 110 | is_passed=1 111 | for path_to_check in "${paths_to_check[@]}"; do 112 | path_to_check="${st_install_dir}/${path_to_check}" 113 | 114 | # if the path under checking is a dir, it ends with a slash 115 | if [[ ${path_to_check} =~ /$ ]]; then 116 | if [[ ! -d ${path_to_check} ]]; then 117 | is_passed=0 118 | break 119 | fi 120 | else 121 | if [[ ! -f ${path_to_check} ]]; then 122 | is_passed=0 123 | break 124 | fi 125 | fi 126 | done 127 | 128 | if [[ ${is_passed} == "1" ]]; then 129 | st_install_dir="$(realpath "${st_install_dir}")" 130 | echo -e "${H_INFO} ✔️ Found ST installation directory: ${st_install_dir}" 131 | break 132 | else 133 | st_install_dir="" 134 | fi 135 | done 136 | 137 | if [[ ${st_install_dir} == "" ]]; then 138 | echo -e "${H_ERROR} ❌ Could not find ST installation directory..." 139 | exit 1 140 | fi 141 | 142 | st_pkgs_dir="${st_install_dir}/Packages" 143 | 144 | #-------------------------# 145 | # read option: commit_ref # 146 | #-------------------------# 147 | 148 | echo -e "${H_INFO} 💡 You can use either branch, tag or even SHA as the ref." 149 | echo -e "${H_INFO} 💡 You can check out refs on \"${PKG_GITHUB_URL}/commits\"." 150 | read -rp "$(echo -e "${H_INFO} ❓ Which ref you want to used (such as 'v4134', default = 'master'): ")" commit_ref 151 | 152 | if [[ ${commit_ref} == "" ]]; then 153 | commit_ref="master" 154 | echo -e "${H_WARNING} ⚠️ Use the default ref: ${commit_ref}" 155 | fi 156 | 157 | #-------------------------------# 158 | # get the latest package source # 159 | #-------------------------------# 160 | 161 | repo_dir="${TEMP_DIR}/repo" 162 | commit_sha="" 163 | 164 | echo -e "${H_INFO} 💬 Downloading repository..." 165 | 166 | if clone_repo_ref "${repo_dir}" "${PKG_REMOTE_REPO}" "${commit_ref}"; then 167 | echo -e "${H_INFO} ✔️ Download repository successfully!" 168 | commit_sha="$(git rev-parse HEAD)" 169 | else 170 | echo -e "${H_ERROR} ❌ Fail to checkout ref: ${commit_ref}" 171 | exit 1 172 | fi 173 | 174 | #------------------# 175 | # pack up packages # 176 | #------------------# 177 | 178 | packed_pkgs_dir="${TEMP_DIR}/packages" 179 | 180 | mkdir -p "${packed_pkgs_dir}" 181 | 182 | echo -e "${H_INFO} 💬 Pack up packages (${commit_sha})..." 183 | 184 | # traverse all packages in the repo 185 | for dir in "${repo_dir}/"*/; do 186 | pushd "${dir}" || exit 187 | 188 | pkg_name=$(basename "${dir}") 189 | 190 | echo -e "${H_DEBUG} 📦 Packaging: ${pkg_name}" 191 | 192 | zip -9rq "${packed_pkgs_dir}/${pkg_name}.sublime-package" . -z <