#!/usr/bin/env bash readonly toolName=rspamd readonly knownVersion="3.4" readonly toolGit="https://github.com/vstakhov/rspamd.git" # Already defined by sequencer.sh, but may be overwritten #readonly seq_configName="${sq_scriptName:?}.cfg" #readonly seq_configTemplate="${seq_origin:?}/${sq_configName:?}.example" sq_aptOpt= sq_config=0 seq_config() { ## Called once before executing steps. ## e.g. to source a config file manually: #. "${seq_origin:?}/${seq_configName:?}" ## or to use sequencer api with profile config file support: #if initSeqConfig -p "${seq_fileName:?}" "${seq_configTemplate:?}" ; then ## or to use sequencer api with global config file: #if initSeqConfig "${seq_configName:?}" "${seq_configTemplate:?}" ; then # sq_config=1 #else # # End if no configuration file exists # dry || return 1 #fi ## Apt cmdline option to suppress user interaction interactive || sq_aptOpt="-y" ## Disable error checks if external scripts are used ## e.g. error on unbound variables #disableErrorCheck ## Return of non zero value will abort the sequence return 0 } step_1_info() { echo "Setup custom repository for raspberry pi OS"; } step_1_alias() { echo "install"; } step_1() { local lRaspbianRelease="Raspbian_$(lsb_release -sr)" local lFileName="home_susenerf_rspamd-exotic-debian" local lRepoUrl="http://download.opensuse.org/repositories/home:/susenerf:/rspamd-exotic-debian" exep echo "deb ${lRepoUrl}/${lRaspbianRelease}/ /" "|" sudo tee /etc/apt/sources.list.d/${lFileName}.list exep curl -fsSL "${lRepoUrl}/${lRaspbianRelease}/Release.key" "|" gpg --dearmor "|" sudo tee /etc/apt/trusted.gpg.d/${lFileName}.gpg ">" /dev/null exe apt update } step_2_info() { echo "Install ${toolName} with apt"; } step_2() { exe apt install rspamd redis-server } step_10_info() { echo "Add ufw rule for WebUI (11334)"; } step_10_alias() { echo "ufw"; } step_10() { exe ufw allow 11334/tcp comment "rspamd WebUI" } step_50_info() { echo "Notes"; } step_50_alias() { echo "notes"; } step_50() { color green cat < enable_password = [/etc/rspamd/local.d/redis.conf] server = "127.0.0.1"; timeout = 3s; [/etc/rspamd/local.d/classifier-bayes.conf] backend = "redis"; autolearn = true; [/etc/rspamd/local.d/dkim_signing.conf] enabled = false; [/etc/rspamd/local.d/milter_headers.conf] authenticated_headers = ["authentication-results"]; use = ["x-spamd-result","x-spam-level","x-spamd-bar", "my-x-spam-score","x-spam-status", "authentication-results"]; # add X-Spam-Score header (like SA does) # Source: https://groups.google.com/forum/#!topic/rspamd/fEdbnG0J18I custom { my-x-spam-score = </dev/null exe rm -rf "${rbuild_confDir}" exe rm -rf "/usr/local/share/rspamd" exe rm -rf "/usr/local/lib/rspamd" exe rm -rf "/usr/local/lib/systemd/system/rspamd.service" exe rm -rf "/usr/local/share/man"/man*/rspam[dca]*.* # rspamadm, rspamc, rspamd exe rm -rf "/usr/local/bin/rspam"[adc]* exe systemctl daemon-reload } step_64_info() { echoinfoArgs "[VERSION]"; echo "Install build dependencies for .deb build"; } step_64_alias() { echo "builddeb"; } step_64() { exe apt install cmake ragel pkg-config libglib2.0-dev libsqlite3-dev libicu-dev libmagic-dev libssl-dev libsodium-dev redis libjemalloc-dev libcurl4-openssl-dev liblua5.1-0-dev libunwind-dev liblua5.1-0-dev } step_65_info() { echoinfoArgs "[VERSION]"; echo "Build .deb from source"; } step_65() { shift local version="${1:-"${knownVersion}"}" local buildHome="${HOME}/build" local cloneDir="${buildHome}/rspamd" local buildDir="${buildHome}/rspamd.dist" local distDir="${buildDir}/rspamd.deb" local tarball="rspamd.deb.tar.xz" info "Building version ${version} in ${buildDir}" exe mkdir -p "${buildHome}" exe cd "${buildHome}" exe git clone --recursive "${toolGit}" info "Checkout version ${version}" exe cd "${cloneDir}" exe git checkout tags/${version} # check for latest tag exe ./dist.sh "${buildDir}/${tarball}" exe cd "${buildDir}" exe tar xf "${tarball}" exe cd "${distDir}" exe ./setVersion.sh "${version}" # check for latest tag exe editor debian/rules # remove arm64 from ENABLE_LUAJIT ifneq # dpkg-source: -i[regex], --diff-ignore[=regex] # dpkg-buildpackage: -b Equivalent to --build=binary or --build=any,all. exe debuild -i --unsigned-source --unsigned-changes -b } # shellcheck disable=SC2034 # Appears unused readonly sqr_minVersion=16 # shellcheck disable=SC1091 # Don't follow this source . /usr/local/bin/sequencer.sh