├── .gitattributes ├── .gitignore ├── README.md ├── fix5to6upgrade ├── fix6to7upgrade ├── install ├── installOld ├── md5sum ├── preinstall └── upgrade4to5 /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | 3 | *.gif binary 4 | *.jpg binary 5 | *.png binary 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # General 2 | *.tmp 3 | *.bak 4 | *.swp 5 | *~ 6 | 7 | # Eclipse 8 | .project 9 | .metadata 10 | .settings/ 11 | *.launch 12 | .buildpath 13 | 14 | # Sublime Text 15 | *.sublime-workspace 16 | *.sublime-project 17 | 18 | # Vim 19 | [._]*.s[a-w][a-z] 20 | [._]s[a-w][a-z] 21 | *.un~ 22 | Session.vim 23 | .netrwhist 24 | 25 | # SVN 26 | .svn/ 27 | 28 | # Mac 29 | .DS_Store 30 | .AppleDouble 31 | .LSOverride 32 | 33 | # Windows 34 | Thumbs.db 35 | ehthumbs.db 36 | Desktop.ini 37 | 38 | # OpenMediaVault / Debian 39 | debian/openmediavault-* 40 | debian/files 41 | debian/*.debhelper.log 42 | debian/*.debhelper 43 | debian/*substvars 44 | debian/debhelper-build-stamp 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### READ THE WIKI 2 | These instructions are very basic and may not include everything needed for all systems. The wiki does. 3 | 4 | - For Raspberry Pi - https://wiki.omv-extras.org/doku.php?id=omv7:raspberry_pi_install 5 | - For AMD64 - https://wiki.omv-extras.org/doku.php?id=omv7:alternate_amd64_install 6 | - For Armbian - https://wiki.omv-extras.org/doku.php?id=omv7:armbian_bookworm_install 7 | - See wiki for other systems 8 | 9 | For the new user guide, visit https://wiki.omv-extras.org/doku.php?id=omv6:new_user_guide 10 | 11 | ### installScript 12 | - Please use a new SD card if installing on an arm/sbc device and flash it with the latest (see notes below about version) Debian OS Lite (without desktop environment) or Server image available for your SBC. 13 | - This script will install openmediavault, omv-extras, and flashmemory. If you already have openmediavault installed don't worry, your openmediavault will be preserved, only the not installed will be added to the system. 14 | - Installing OMV with a desktop environment is NOT supported. Please read the forum for the many reasons why. 15 | - This script may alter previous network setups. This has a greater chance of breaking wifi setup. Please read the install manual for more help - https://wiki.omv-extras.org/ 16 | 17 | ### Notes 18 | - This script will always install 19 | - OMV 6.x on Debian 11 (Bullseye) 20 | - OMV 7.x on Debian 12 (Bookworm) 21 | 22 | ### Installation 23 | To install OMV, OMV-Extras and Flashmemory copy and paste this line in the Terminal and press Enter. The installation will take some time, so enjoy the text flying on the screen. 24 | 25 | ***The installation process demands sudo utilization.*** 26 | 27 | To download and execute the script you can use either *wget* or *curl*, feel free to use what you prefer! 28 | 29 | *wget script* 30 | #### 31 | ```bash 32 | sudo wget -O - https://github.com/OpenMediaVault-Plugin-Developers/installScript/raw/master/install | sudo bash 33 | ``` 34 | 35 | *curl script* 36 | ```bash 37 | sudo curl -sSL https://github.com/OpenMediaVault-Plugin-Developers/installScript/raw/master/install | sudo bash 38 | ``` 39 | ### To skip network setup 40 | If you don't wanna use the network setup steps of the script, please use copy and paste the followings lines to the terminal. 41 | ```bash 42 | wget https://github.com/OpenMediaVault-Plugin-Developers/installScript/raw/master/install 43 | chmod +x install 44 | sudo ./install -n 45 | ``` 46 | 47 | ### A detailed guide is available for this script as well 48 | openmediavault is primarily designed to be used in home environments or small home offices, but is not limited to those scenarios. It is a simple and easy to use out-of-the-box solution that everyone can install and administer without needing expert level knowledge of Networking and Storage Systems. 49 | 50 | For the OMV-Extras documentation, visit https://wiki.omv-extras.org/ 51 | 52 | For the new user guide, visit https://wiki.omv-extras.org/doku.php?id=omv6:new_user_guide 53 | 54 | ### Get help for this script in the forum 55 | If you got stuck in any part of this script the openmediavault forum will be the place to find a solution https://forum.openmediavault.org/ 56 | 57 | -------------------------------------------------------------------------------- /fix5to6upgrade: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # shellcheck disable=SC1090,SC1091,SC1117,SC2016,SC2046,SC2086 4 | # 5 | # version: 0.0.3 6 | # 7 | 8 | if [[ $(id -u) -ne 0 ]]; then 9 | echo "This script must be executed as root or using sudo." 10 | exit 99 11 | fi 12 | 13 | export DEBIAN_FRONTEND=noninteractive 14 | export APT_LISTCHANGES_FRONTEND=none 15 | export LANG=C.UTF-8 16 | 17 | echo "Removing old sources ..." 18 | rm -f /etc/apt/sources.list.d/omvextras.list /etc/apt/sources.list.d/omv-extras-org.list 19 | 20 | xmlstarlet ed --inplace -u /config/system/omvextras/extras -v 0 /etc/openmediavault/config.xml 21 | xmlstarlet ed --inplace -u /config/system/omvextras/testing -v 0 /etc/openmediavault/config.xml 22 | 23 | echo "Clearing cache ..." 24 | /usr/bin/salt-call --local saltutil.clear_cache 25 | omv-salt stage run prepare 26 | 27 | echo "Rebuilding sources.list* ..." 28 | omv-salt deploy run apt omvextras 29 | 30 | echo "Change to bullseye and shaitan just in case ..." 31 | sed -i "s/buster/bullseye/g" /etc/apt/sources.list 32 | sed -i "s/buster/bullseye/g" /etc/apt/sources.list.d/* 33 | sed -i "s/usul/shaitan/g" /etc/apt/sources.list.d/* 34 | 35 | if [ -f /etc/apt/apt.conf ]; then 36 | echo "Changing apt.conf ..." 37 | sed -i "s/buster/bullseye/g" /etc/apt/apt.conf 38 | fi 39 | 40 | armbian="/etc/apt/sources.list.d/armbian.list" 41 | if [ -f "${armbian}" ]; then 42 | echo "Fixing Armbian repo ..." 43 | echo "deb http://apt.armbian.com bullseye main bullseye-utils" | tee ${armbian} 44 | fi 45 | 46 | security="/etc/apt/sources.list.d/openmediavault-os-security.list" 47 | if [ -f "${security}" ]; then 48 | echo "Fixing Debian security repo ..." 49 | echo "deb http://security.debian.org/debian-security bullseye-security main contrib non-free" | tee ${security} 50 | fi 51 | 52 | echo "Running apt-get update ..." 53 | apt-get update 54 | 55 | echo "Running apt-get dist-upgrade ..." 56 | apt-get --yes \ 57 | --option DPkg::Options::="--force-confdef" \ 58 | --option DPkg::Options::="--force-confold" \ 59 | dist-upgrade 60 | 61 | echo "Enable cron-apt ..." 62 | rm -f /etc/cron-apt/refrain 63 | 64 | echo "Enable apt index ..." 65 | cp /usr/sbin/omv-mkaptidx /root/ 66 | rm -f /usr/sbin/omv-mkaptidx 67 | 68 | if [ ! -f "/usr/sbin/omv-mkaptidx" ]; then 69 | echo "omv-mkaptidx does not exist. Downloading..." 70 | wget -O /usr/sbin/omv-mkaptidx https://github.com/openmediavault/openmediavault/raw/master/deb/openmediavault/usr/sbin/omv-mkaptidx 71 | chmod +x /usr/sbin/omv-mkaptidx 72 | fi 73 | 74 | echo "Rebuild apt index ..." 75 | omv-mkaptidx 76 | 77 | echo "Rebuild OMV pam config ..." 78 | dpkg-divert --remove --rename /etc/pam.d/openmediavault 79 | dpkg-divert --remove --rename /etc/pam.d/openmediavault-common-auth 80 | dpkg-divert --remove --rename /etc/pam.d/openmediavault-webgui 81 | 82 | echo "Done." 83 | 84 | exit 0 85 | -------------------------------------------------------------------------------- /fix6to7upgrade: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # shellcheck disable=SC1090,SC1091,SC1117,SC2016,SC2046,SC2086 4 | # 5 | # version: 0.0.9 6 | # 7 | 8 | if [[ $(id -u) -ne 0 ]]; then 9 | echo "This script must be executed as root or using sudo." 10 | exit 99 11 | fi 12 | 13 | export DEBIAN_FRONTEND=noninteractive 14 | export APT_LISTCHANGES_FRONTEND=none 15 | export LANG=C.UTF-8 16 | 17 | echo "Removing old sources ..." 18 | rm -f /etc/apt/sources.list.d/omvextras.list /etc/apt/sources.list.d/omv-extras-org.list 19 | 20 | if [ -f "/etc/apt/sources.list.d/pvekernel.list" ]; then 21 | rm -fv /etc/apt/sources.list.d/pvekernel.list 22 | fi 23 | 24 | echo "Installing omv-extras 7.x ..." 25 | url="https://github.com/OpenMediaVault-Plugin-Developers/packages/raw/master/" 26 | file="openmediavault-omvextrasorg_latest_all7.deb" 27 | deb="omvextras7.deb" 28 | wget "${url}/${file}" -O ${deb} 29 | if [ -f "${deb}" ]; then 30 | dpkg -i ${deb} 31 | fi 32 | 33 | echo "Clearing cache ..." 34 | /usr/bin/salt-call --local saltutil.clear_cache 35 | omv-salt stage run prepare 36 | 37 | echo "Change to bullseye and shaitan just in case ..." 38 | sed -i "s/bullseye/bookworm/g" /etc/apt/sources.list 39 | sed -i "s/bullseye/bookworm/g" /etc/apt/sources.list.d/* 40 | sed -i "s/shaitan/sandworm/g" /etc/apt/sources.list.d/* 41 | 42 | if [ -f /etc/apt/apt.conf ]; then 43 | echo "Changing apt.conf ..." 44 | sed -i "s/bullseye/bookworm/g" /etc/apt/apt.conf 45 | fi 46 | 47 | armbian="/etc/apt/sources.list.d/armbian.list" 48 | if [ -f "${armbian}" ]; then 49 | echo "Fixing Armbian repo ..." 50 | echo "deb http://apt.armbian.com bookworm main bookworm-utils" | tee ${armbian} 51 | fi 52 | 53 | security="/etc/apt/sources.list.d/openmediavault-os-security.list" 54 | if [ -f "${security}" ]; then 55 | echo "Fixing Debian security repo ..." 56 | echo "deb http://security.debian.org/debian-security bookworm-security main contrib non-free" | tee ${security} 57 | fi 58 | 59 | echo "Running apt-get update ..." 60 | if ! apt-get update; then 61 | echo "apt-get update failed. Your repos need to be fixed." 62 | exit 1 63 | fi 64 | 65 | echo "Running apt-get dist-upgrade ..." 66 | apt-get --yes \ 67 | --option DPkg::Options::="--force-confdef" \ 68 | --option DPkg::Options::="--force-confold" \ 69 | dist-upgrade 70 | 71 | mkaptidx_url="https://github.com/openmediavault/openmediavault/raw/master/deb/openmediavault/usr/sbin/omv-mkaptidx" 72 | mkaptidx_path="/usr/sbin/omv-mkaptidx" 73 | rm -fv "${mkaptidx_path}" 74 | echo "Downloading omv-mkaptidx..." 75 | wget --output-document="${mkaptidx_path}" "${mkaptidx_url}" 76 | chmod +x "${mkaptidx_path}" 77 | 78 | echo "Rebuild apt index ..." 79 | omv-mkaptidx 80 | 81 | sudo omv-salt deploy run nginx phpfpm ssh 82 | sudo systemctl restart nginx 83 | sudo systemctl restart php8.2-fpm 84 | 85 | echo "Done." 86 | 87 | exit 0 88 | -------------------------------------------------------------------------------- /install: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # shellcheck disable=SC1090,SC1091,SC2010,SC2016,SC2046,SC2086,SC2174 4 | # 5 | # Copyright (c) 2015-2024 OpenMediaVault Plugin Developers 6 | # Copyright (c) 2017-2020 Armbian Developers 7 | # 8 | # This file is licensed under the terms of the GNU General Public 9 | # License version 2. This program is licensed "as is" without any 10 | # warranty of any kind, whether express or implied. 11 | # 12 | # Ideas/code used from: 13 | # https://github.com/armbian/config/blob/master/debian-software 14 | # https://forum.openmediavault.org/index.php/Thread/25062-Install-OMV5-on-Debian-10-Buster/ 15 | # 16 | 17 | logfile="omv_install.log" 18 | scriptversion="2.3.10" 19 | 20 | 21 | _log() 22 | { 23 | msg=${1} 24 | echo "[$(date +'%Y-%m-%d %H:%M:%S%z')] [omvinstall] ${msg}" | tee -a ${logfile} 25 | } 26 | 27 | _log "script version :: ${scriptversion}" 28 | 29 | if [[ $(id -u) -ne 0 ]]; then 30 | echo "This script must be executed as root or using sudo." 31 | exit 99 32 | fi 33 | 34 | systemd="$(ps --no-headers -o comm 1)" 35 | if [ ! "${systemd}" = "systemd" ]; then 36 | echo "This system is not running systemd. Exiting..." 37 | exit 100 38 | fi 39 | 40 | if dpkg -l | grep -Eqw "gdm3|sddm|lxdm|xdm|lightdm|slim|wdm"; then 41 | echo "This system is running a desktop environment!" 42 | echo "Please use a Lite version of the image or" 43 | echo "do not choose to install a desktop environment." 44 | echo "This install is not supported." 45 | echo "Search the forum for more info - https://forum.openmediavault.org" 46 | echo "Exiting..." 47 | exit 101 48 | fi 49 | 50 | if [ ! -L "/sbin" ] || [ ! -L "/bin" ]; then 51 | echo "The /usr directories seem not to be migrated. Please check the" 52 | echo "following pages for more information:" 53 | echo "- https://wiki.debian.org/UsrMerge" 54 | echo "- https://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge" 55 | echo "Exiting..." 56 | exit 102 57 | fi 58 | 59 | if [ -f "/.dockerenv" ]; then 60 | echo "Docker detected. OMV does not work in Docker!" 61 | exit 103 62 | fi 63 | 64 | if grep -q 'machine-lxc' /proc/1/cgroup; then 65 | echo "LXC detected. OMV does not work in LXC!" 66 | exit 104 67 | fi 68 | 69 | declare -i armbian=0 70 | declare -i cfg=0 71 | declare -i ipv6=0 72 | declare -i rpi=0 73 | declare -i skipFlash=0 74 | declare -i skipNet=0 75 | declare -i skipReboot=0 76 | declare -i useMirror=0 77 | declare -i version 78 | 79 | declare -l codename 80 | declare -l omvCodename 81 | declare -l omvInstall="" 82 | declare -l omvextrasInstall="" 83 | 84 | declare gov="" 85 | declare minspd="" 86 | declare maxspd="" 87 | 88 | aptclean="/usr/sbin/omv-aptclean" 89 | confCmd="omv-salt deploy run" 90 | cpuFreqDef="/etc/default/cpufrequtils" 91 | crda="/etc/default/crda" 92 | defaultGovSearch="^CONFIG_CPU_FREQ_DEFAULT_GOV_" 93 | forceIpv4="/etc/apt/apt.conf.d/99force-ipv4" 94 | ioniceCron="/etc/cron.d/make_nas_processes_faster" 95 | ioniceScript="/usr/sbin/omv-ionice" 96 | keyserver="hkp://keyserver.ubuntu.com:80" 97 | mirror="https://mirrors.tuna.tsinghua.edu.cn" 98 | omvKey="/usr/share/keyrings/openmediavault-archive-keyring.gpg" 99 | omvRepo="http://packages.openmediavault.org/public" 100 | omvKeyUrl="${omvRepo}/archive.key" 101 | omvSources="/etc/apt/sources.list.d/openmediavault.list" 102 | resolvTmp="/root/resolv.conf" 103 | rfkill="/usr/sbin/rfkill" 104 | smbOptions="" 105 | sshGrp="ssh" 106 | url="https://github.com/OpenMediaVault-Plugin-Developers/packages/raw/master" 107 | vsCodeList="/etc/apt/sources.list.d/vscode.list" 108 | wpaConf="/etc/wpa_supplicant/wpa_supplicant.conf" 109 | 110 | export DEBIAN_FRONTEND=noninteractive 111 | export APT_LISTCHANGES_FRONTEND=none 112 | export LANG=C.UTF-8 113 | export LANGUAGE=C 114 | export LC_ALL=C.UTF-8 115 | 116 | if [ -f /etc/armbian-release ]; then 117 | . /etc/armbian-release 118 | armbian=1 119 | _log "Armbian" 120 | fi 121 | 122 | while getopts "fhimnr" opt; do 123 | _log "option ${opt}" 124 | case "${opt}" in 125 | f) 126 | skipFlash=1 127 | ;; 128 | h) 129 | echo "Use the following flags:" 130 | echo " -f" 131 | echo " to skip the installation of the flashmemory plugin" 132 | echo " -i" 133 | echo " enable using IPv6 for apt" 134 | echo " -m" 135 | echo " to repo mirror from ${mirror}" 136 | echo " -n" 137 | echo " to skip the network setup" 138 | echo " -r" 139 | echo " to skip reboot" 140 | echo "" 141 | echo "Examples:" 142 | echo " install" 143 | echo " install -f" 144 | echo " install -n" 145 | echo "" 146 | echo "Notes:" 147 | echo " This script will always install:" 148 | echo " - OMV 6.x (shaitan) on Debian 11 (Bullseye)" 149 | echo " - OMV 7.x (sandworm) on Debian 12 (Bookworm)" 150 | echo "" 151 | exit 100 152 | ;; 153 | i) 154 | ipv6=1 155 | ;; 156 | m) 157 | useMirror=1 158 | omvRepo="${mirror}/OpenMediaVault/public" 159 | ;; 160 | n) 161 | skipNet=1 162 | ;; 163 | r) 164 | skipReboot=1 165 | ;; 166 | \?) 167 | _log "Invalid option: -${OPTARG}" 168 | ;; 169 | esac 170 | done 171 | 172 | _log "Starting ..." 173 | 174 | # Fix permissions on / if wrong 175 | _log "Current / permissions = $(stat -c %a /)" 176 | chmod -v g-w,o-w / 2>&1 | tee -a ${logfile} 177 | _log "New / permissions = $(stat -c %a /)" 178 | 179 | # if ipv6 is not enabled, create apt config file to force ipv4 180 | if [ ${ipv6} -ne 1 ]; then 181 | _log "Forcing IPv4 only for apt..." 182 | echo 'Acquire::ForceIPv4 "true";' > ${forceIpv4} 183 | fi 184 | 185 | 186 | if [ -f "/usr/libexec/config-rtl8367rb.sh" ]; then 187 | _log "Skipping network because swconfig controlled switch found." 188 | skipNet=1 189 | fi 190 | 191 | _log "Updating repos before installing..." 192 | apt-get --allow-releaseinfo-change update 2>&1 | tee -a ${logfile} 193 | 194 | _log "Installing lsb_release..." 195 | apt-get --yes --no-install-recommends --reinstall install lsb-release 2>&1 | tee -a ${logfile} 196 | 197 | arch="$(dpkg --print-architecture)" 198 | _log "Arch :: ${arch}" 199 | 200 | # exit if not supported architecture 201 | case ${arch} in 202 | arm64|armhf|amd64|i386) 203 | _log "Supported architecture" 204 | ;; 205 | *) 206 | _log "Unsupported architecture :: ${arch}" 207 | exit 5 208 | ;; 209 | esac 210 | 211 | codename="$(lsb_release --codename --short)" 212 | _log "Codename :: ${codename}" 213 | 214 | case ${codename} in 215 | bullseye) 216 | keys="0E98404D386FA1D9 A48449044AAD5C5D" 217 | omvCodename="shaitan" 218 | version=6 219 | ;; 220 | bookworm) 221 | omvCodename="sandworm" 222 | version=7 223 | _log "Copying /etc/resolv.conf to ${resolvTmp} ..." 224 | cp -fv /etc/resolv.conf "${resolvTmp}" 225 | _log "$(cat /etc/resolv.conf)" 226 | sshGrp="_ssh" 227 | ;; 228 | *) 229 | _log "Unsupported version. Only 11 (Bullseye) and 12 (Bookworm) are supported. Exiting..." 230 | exit 1 231 | ;; 232 | esac 233 | _log "Debian :: ${codename}" 234 | _log "${omvCodename} :: ${version}" 235 | 236 | hostname="$(hostname --short)" 237 | _log "Hostname :: ${hostname}" 238 | domainname="$(hostname --domain)" 239 | _log "Domain name :: ${domainname}" 240 | tz="$(timedatectl show --property=Timezone --value)" 241 | _log "timezone :: ${tz}" 242 | 243 | regex='[a-zA-Z]([-a-zA-Z0-9]{0,61}[a-zA-Z0-9])' 244 | if [[ ! ${hostname} =~ ${regex} ]]; then 245 | _log "Invalid hostname. Exiting..." 246 | exit 6 247 | fi 248 | 249 | # Add Debian signing keys to raspbian to prevent apt-get update failures 250 | # when OMV adds security and/or backports repos 251 | if grep -rq raspberrypi.org /etc/apt/*; then 252 | rpivers="$(awk '$1 == "Revision" { print $3 }' /proc/cpuinfo)" 253 | _log "RPi revision code :: ${rpivers}" 254 | # https://elinux.org/RPi_HardwareHistory 255 | if [[ "${rpivers:0:1}" =~ [09] ]] && [[ ! "${rpivers:0:3}" =~ 902 ]]; then 256 | _log "This RPi1 is not supported (not true armhf). Exiting..." 257 | exit 7 258 | fi 259 | rpi=1 260 | _log "Adding Debian signing keys..." 261 | for key in ${keys}; do 262 | apt-key adv --no-tty --keyserver ${keyserver} --recv-keys "${key}" 2>&1 | tee -a ${logfile} 263 | done 264 | _log "Installing monit from raspberrypi repo..." 265 | apt-get --yes --no-install-recommends install -t ${codename} monit 2>&1 | tee -a ${logfile} 266 | 267 | # remove vscode repo if found since there is no desktop environment 268 | # empty file will exist to keep raspberrypi-sys-mods package from adding it back 269 | truncate -s 0 "${vsCodeList}" 270 | fi 271 | 272 | # remove armbian netplan file if found 273 | anp="/etc/netplan/armbian-default.yaml" 274 | if [ -e "${anp}" ]; then 275 | _log "Removing Armbian netplan file..." 276 | rm -fv "${anp}" 277 | fi 278 | 279 | dpkg -P udisks2 2>&1 | tee -a ${logfile} 280 | 281 | _log "Install prerequisites..." 282 | apt-get --yes --no-install-recommends install gnupg wget 2>&1 | tee -a ${logfile} 283 | 284 | if [ ${armbian} -eq 1 ]; then 285 | systemctl unmask systemd-networkd.service 2>&1 | tee -a ${logfile} 286 | # save off cpuFreq settings before installing the openmediavault 287 | if [ -f "${cpuFreqDef}" ]; then 288 | . ${cpuFreqDef} 289 | gov="${GOVERNOR}" 290 | minspd="${MIN_SPEED}" 291 | maxspd="${MAX_SPEED}" 292 | fi 293 | fi 294 | 295 | # make sure ssh is enabled 296 | systemctl enable ssh.service 297 | 298 | # install openmediavault if not installed already 299 | omvInstall=$(dpkg -l | awk '$2 == "openmediavault" { print $1 }') 300 | if [[ ! "${omvInstall}" == "ii" ]]; then 301 | _log "Installing openmediavault required packages..." 302 | apt-get --yes --no-install-recommends install postfix 2>&1 | tee -a ${logfile} 303 | if [ ${PIPESTATUS[0]} -gt 0 ]; then 304 | _log "failed installing postfix" 305 | sed -i '/^myhostname/d' /etc/postfix/main.cf 306 | apt-get --yes --fix-broken install 2>&1 | tee -a ${logfile} 307 | if [ ${PIPESTATUS[0]} -gt 0 ]; then 308 | _log "failed installing postfix and unable to fix" 309 | exit 2 310 | fi 311 | fi 312 | 313 | _log "Adding openmediavault repo and key..." 314 | echo "deb [signed-by=${omvKey}] ${omvRepo} ${omvCodename} main" | tee ${omvSources} 315 | wget --quiet --output-document=- "${omvKeyUrl}" | gpg --dearmor --yes --output "${omvKey}" 316 | 317 | _log "Updating repos..." 318 | apt-get update 2>&1 | tee -a ${logfile} 319 | if [ ${PIPESTATUS[0]} -gt 0 ]; then 320 | _log "failed to update apt repos." 321 | exit 2 322 | fi 323 | 324 | _log "Install openmediavault-keyring..." 325 | apt-get --yes install openmediavault-keyring 2>&1 | tee -a ${logfile} 326 | if [ ${PIPESTATUS[0]} -gt 0 ]; then 327 | _log "failed to install openmediavault-keyring package." 328 | exit 2 329 | fi 330 | 331 | monitInstall=$(dpkg -l | awk '$2 == "monit" { print $1 }') 332 | if [[ ! "${monitInstall}" == "ii" ]]; then 333 | apt-get --yes --no-install-recommends install monit 2>&1 | tee -a ${logfile} 334 | if [ ${PIPESTATUS[0]} -gt 0 ]; then 335 | _log "failed installing monit" 336 | exit 2 337 | fi 338 | fi 339 | 340 | _log "Installing openmediavault..." 341 | aptFlags="--yes --auto-remove --show-upgraded --allow-downgrades --allow-change-held-packages --no-install-recommends" 342 | apt-get ${aptFlags} install openmediavault 2>&1 | tee -a ${logfile} 343 | if [ ${PIPESTATUS[0]} -gt 0 ]; then 344 | _log "failed to install openmediavault package." 345 | exit 2 346 | fi 347 | 348 | omv-confdbadm populate 2>&1 | tee -a ${logfile} 349 | omv-salt deploy run hosts 2>&1 | tee -a ${logfile} 350 | fi 351 | _log "Testing DNS..." 352 | if ! ping -4 -q -c2 omv-extras.org 2>/dev/null; then 353 | _log "DNS failing to resolve. Fixing ..." 354 | if [ -f "${resolvTmp}" ]; then 355 | _log "Reverting /etc/resolv.conf to saved copy ..." 356 | rm -fv /etc/resolv.conf 357 | cp -v "${resolvTmp}" /etc/resolv.conf 358 | fi 359 | fi 360 | 361 | # check if openmediavault is install properly 362 | omvInstall=$(dpkg -l | awk '$2 == "openmediavault" { print $1 }') 363 | if [[ ! "${omvInstall}" == "ii" ]]; then 364 | _log "openmediavault package failed to install or is in a bad state." 365 | exit 3 366 | fi 367 | 368 | . /etc/default/openmediavault 369 | . /usr/share/openmediavault/scripts/helper-functions 370 | 371 | # remove backports from sources.list to avoid duplicate sources warning 372 | sed -i "/\(stretch\|buster\|bullseye\)-backports/d" /etc/apt/sources.list 373 | 374 | if [ ${rpi} -eq 1 ]; then 375 | if [ ! "${arch}" = "arm64" ]; then 376 | omv_set_default "OMV_APT_USE_OS_SECURITY" false true 377 | fi 378 | omv_set_default "OMV_APT_USE_KERNEL_BACKPORTS" false true 379 | fi 380 | 381 | # change repos if useMirror is specified 382 | if [ ${useMirror} -eq 1 ]; then 383 | _log "Changing repos to mirror from ${mirror} ..." 384 | omv_set_default OMV_APT_REPOSITORY_URL "${mirror}/OpenMediaVault/public" true 385 | omv_set_default OMV_APT_ALT_REPOSITORY_URL "${mirror}/OpenMediaVault/packages" true 386 | omv_set_default OMV_APT_KERNEL_BACKPORTS_REPOSITORY_URL "${mirror}/debian" true 387 | omv_set_default OMV_APT_SECURITY_REPOSITORY_URL "${mirror}/debian-security" true 388 | omv_set_default OMV_EXTRAS_APT_REPOSITORY_URL "${mirror}/OpenMediaVault/openmediavault-plugin-developers" true 389 | omv_set_default OMV_DOCKER_APT_REPOSITORY_URL "${mirror}/docker-ce/linux/debian" true 390 | omv_set_default OMV_PROXMOX_APT_REPOSITORY_URL "${mirror}/proxmox/debian" true 391 | 392 | # update pillar default list - /srv/pillar/omv/default.sls 393 | omv-salt stage run prepare 2>&1 | tee -a ${logfile} 394 | 395 | # update config files 396 | ${confCmd} apt 2>&1 | tee -a ${logfile} 397 | fi 398 | 399 | # install omv-extras 400 | _log "Downloading omv-extras.org plugin for openmediavault ${version}.x ..." 401 | file="openmediavault-omvextrasorg_latest_all${version}.deb" 402 | 403 | if [ -f "${file}" ]; then 404 | rm ${file} 405 | fi 406 | wget ${url}/${file} 407 | if [ -f "${file}" ]; then 408 | if ! dpkg --install ${file}; then 409 | _log "Installing other dependencies ..." 410 | apt-get --yes --fix-broken install 2>&1 | tee -a ${logfile} 411 | omvextrasInstall=$(dpkg -l | awk '$2 == "openmediavault-omvextrasorg" { print $1 }') 412 | if [[ ! "${omvextrasInstall}" == "ii" ]]; then 413 | _log "omv-extras failed to install correctly. Trying to fix apt ..." 414 | apt-get --yes --fix-broken install 2>&1 | tee -a ${logfile} 415 | if [ ${PIPESTATUS[0]} -gt 0 ]; then 416 | _log "Fix failed and openmediavault-omvextrasorg is in a bad state." 417 | exit 3 418 | fi 419 | fi 420 | omvextrasInstall=$(dpkg -l | awk '$2 == "openmediavault-omvextrasorg" { print $1 }') 421 | if [[ ! "${omvextrasInstall}" == "ii" ]]; then 422 | _log "openmediavault-omvextrasorg package failed to install or is in a bad state." 423 | exit 3 424 | fi 425 | fi 426 | 427 | _log "Updating repos ..." 428 | ${aptclean} repos 2>&1 | tee -a ${logfile} 429 | else 430 | _log "There was a problem downloading the package." 431 | fi 432 | 433 | # disable armbian log services if found 434 | for service in log2ram armbian-ramlog armbian-zram-config; do 435 | if systemctl list-units --full -all | grep ${service}; then 436 | systemctl stop ${service} 2>&1 | tee -a ${logfile} 437 | systemctl disable ${service} 2>&1 | tee -a ${logfile} 438 | fi 439 | done 440 | rm -f /etc/cron.daily/armbian-ram-logging 441 | if [ -f "/etc/default/armbian-ramlog" ]; then 442 | sed -i "s/ENABLED=.*/ENABLED=false/g" /etc/default/armbian-ramlog 443 | fi 444 | if [ -f "/etc/default/armbian-zram-config" ]; then 445 | sed -i "s/ENABLED=.*/ENABLED=false/g" /etc/default/armbian-zram-config 446 | fi 447 | if [ -f "/etc/systemd/system/logrotate.service" ]; then 448 | rm -f /etc/systemd/system/logrotate.service 449 | systemctl daemon-reload 450 | fi 451 | 452 | # install flashmemory plugin unless disabled 453 | if [ ${skipFlash} -eq 1 ]; then 454 | _log "Skipping installation of the flashmemory plugin." 455 | else 456 | _log "Install folder2ram..." 457 | apt-get --yes --fix-missing --no-install-recommends install folder2ram 2>&1 | tee -a ${logfile} 458 | if [ ${PIPESTATUS[0]} -eq 0 ]; then 459 | _log "Installed folder2ram." 460 | else 461 | _log "Failed to install folder2ram." 462 | fi 463 | _log "Install flashmemory plugin..." 464 | apt-get --yes install openmediavault-flashmemory 2>&1 | tee -a ${logfile} 465 | if [ ${PIPESTATUS[0]} -eq 0 ]; then 466 | _log "Installed flashmemory plugin." 467 | else 468 | _log "Failed to install flashmemory plugin." 469 | ${confCmd} flashmemory 2>&1 | tee -a ${logfile} 470 | apt-get --yes --fix-broken install 2>&1 | tee -a ${logfile} 471 | fi 472 | fi 473 | 474 | # change default OMV settings 475 | if [ -n "${smbOptions}" ]; then 476 | omv_config_update "/config/services/smb/extraoptions" "$(echo -e "${smbOptions}")" 477 | fi 478 | omv_config_update "/config/services/ssh/enable" "1" 479 | omv_config_update "/config/services/ssh/permitrootlogin" "1" 480 | omv_config_update "/config/system/time/ntp/enable" "1" 481 | omv_config_update "/config/system/time/timezone" "${tz}" 482 | omv_config_update "/config/system/network/dns/hostname" "${hostname}" 483 | if [ -n "${domainname}" ]; then 484 | omv_config_update "/config/system/network/dns/domainname" "${domainname}" 485 | fi 486 | 487 | # disable monitoring and apply changes 488 | _log "Disabling data collection ..." 489 | /usr/sbin/omv-rpc -u admin "perfstats" "set" '{"enable":false}' 2>&1 | tee -a ${logfile} 490 | /usr/sbin/omv-rpc -u admin "config" "applyChanges" '{ "modules": ["monit","rrdcached","collectd"],"force": true }' 2>&1 | tee -a ${logfile} 491 | 492 | # set min/max frequency and watchdog for RPi boards 493 | rpi_model="/proc/device-tree/model" 494 | if [ -f "${rpi_model}" ] && [[ $(awk '{ print $1 }' ${rpi_model}) = "Raspberry" ]]; then 495 | if [ ${version} -lt 6 ]; then 496 | omv_set_default "OMV_WATCHDOG_DEFAULT_MODULE" "bcm2835_wdt" 497 | omv_set_default "OMV_WATCHDOG_CONF_WATCHDOG_TIMEOUT" "14" 498 | fi 499 | omv_set_default "OMV_WATCHDOG_SYSTEMD_RUNTIMEWATCHDOGSEC" "14s" true 500 | 501 | MIN_SPEED="$( ${cpuFreqDef} 508 | GOVERNOR="schedutil" 509 | MIN_SPEED="${MIN_SPEED}" 510 | MAX_SPEED="${MAX_SPEED}" 511 | EOF 512 | fi 513 | 514 | # get default governor for kernel 515 | modprobe --quiet configs 516 | if [ -f "/proc/config.gz" ]; then 517 | defaultGov="$(zgrep "${defaultGovSearch}" /proc/config.gz | sed -e "s/${defaultGovSearch}\(.*\)=y/\1/")" 518 | elif [ -f "/boot/config-$(uname -r)" ]; then 519 | defaultGov="$(grep "${defaultGovSearch}" /boot/config-$(uname -r) | sed -e "s/${defaultGovSearch}\(.*\)=y/\1/")" 520 | fi 521 | 522 | # governor and speed variables 523 | if [ ${armbian} -eq 1 ]; then 524 | if [ -n "${defaultGov}" ]; then 525 | GOVERNOR="${defaultGov,,}" 526 | elif [ -n "${gov}" ]; then 527 | GOVERNOR="${gov}" 528 | fi 529 | if [ -n "${minspd}" ]; then 530 | MIN_SPEED="${minspd}" 531 | fi 532 | if [ -n "${maxspd}" ]; then 533 | MAX_SPEED="${maxspd}" 534 | fi 535 | elif [ -f "${cpuFreqDef}" ]; then 536 | . ${cpuFreqDef} 537 | else 538 | if [ -z "${DEFAULT_GOV}" ]; then 539 | defaultGov="ondemand" 540 | fi 541 | GOVERNOR=${defaultGov,,} 542 | MIN_SPEED="0" 543 | MAX_SPEED="0" 544 | fi 545 | 546 | # set defaults in /etc/default/openmediavault 547 | omv_set_default "OMV_CPUFREQUTILS_GOVERNOR" "${GOVERNOR}" 548 | omv_set_default "OMV_CPUFREQUTILS_MINSPEED" "${MIN_SPEED}" 549 | omv_set_default "OMV_CPUFREQUTILS_MAXSPEED" "${MAX_SPEED}" 550 | 551 | # update pillar default list - /srv/pillar/omv/default.sls 552 | omv-salt stage run prepare 2>&1 | tee -a ${logfile} 553 | 554 | # update config files 555 | ${confCmd} nginx phpfpm samba flashmemory ssh chrony timezone monit rrdcached collectd cpufrequtils apt watchdog 2>&1 | tee -a ${logfile} 556 | 557 | # create php directories if they don't exist 558 | modDir="/var/lib/php/modules" 559 | if [ ! -d "${modDir}" ]; then 560 | mkdir --parents --mode=0755 ${modDir} 561 | fi 562 | sessDir="/var/lib/php/sessions" 563 | if [ ! -d "${sessDir}" ]; then 564 | mkdir --parents --mode=1733 ${sessDir} 565 | fi 566 | 567 | if [ -f "${forceIpv4}" ]; then 568 | rm ${forceIpv4} 569 | fi 570 | 571 | if [ -f "/etc/init.d/proftpd" ]; then 572 | systemctl disable proftpd.service 573 | systemctl stop proftpd.service 574 | fi 575 | 576 | # add admin user to openmediavault-admin group if it exists 577 | if getent passwd admin > /dev/null; then 578 | usermod -a -G openmediavault-admin admin 2>&1 | tee -a ${logfile} 579 | fi 580 | 581 | if [[ "${arch}" == "amd64" ]] || [[ "${arch}" == "i386" ]]; then 582 | # skip ionice on x86 boards 583 | _log "Done." 584 | exit 0 585 | fi 586 | 587 | if [ ! "${GOVERNOR,,}" = "schedutil" ]; then 588 | _log "Add a cron job to make NAS processes more snappy and silence rsyslog" 589 | cat << EOF > /etc/rsyslog.d/omv-armbian.conf 590 | :msg, contains, "omv-ionice" ~ 591 | :msg, contains, "action " ~ 592 | :msg, contains, "netsnmp_assert" ~ 593 | :msg, contains, "Failed to initiate sched scan" ~ 594 | EOF 595 | systemctl restart rsyslog 2>&1 | tee -a ${logfile} 596 | 597 | # add taskset to ionice cronjob for biglittle boards 598 | case ${BOARD} in 599 | odroidxu4|bananapim3|nanopifire3|nanopct3plus|nanopim3|nanopi-r6s) 600 | taskset='; taskset -c -p 4-7 ${srv}' 601 | ;; 602 | *rk3399*|*edge*|nanopct4|nanopim4|nanopineo4|renegade-elite|rockpi-4*|rockpro64|helios64) 603 | taskset='; taskset -c -p 4-5 ${srv}' 604 | ;; 605 | odroidn2) 606 | taskset='; taskset -c -p 2-5 ${srv}' 607 | ;; 608 | esac 609 | 610 | # create ionice script 611 | cat << EOF > ${ioniceScript} 612 | #!/bin/sh 613 | 614 | for srv in \$(pgrep "ftpd|nfsiod|smbd"); do 615 | ionice -c1 -p \${srv} ${taskset}; 616 | done 617 | EOF 618 | chmod 755 ${ioniceScript} 619 | 620 | # create ionice cronjob 621 | cat << EOF > ${ioniceCron} 622 | * * * * * root ${ioniceScript} >/dev/null 2>&1 623 | EOF 624 | chmod 600 ${ioniceCron} 625 | fi 626 | 627 | # add pi user to ssh group if it exists 628 | if getent passwd pi > /dev/null; then 629 | _log "Adding pi user to ssh group ..." 630 | usermod -a -G ${sshGrp} pi 631 | fi 632 | 633 | # add user running the script to ssh group if not pi or root 634 | if [ -n "${SUDO_USER}" ] && [ ! "${SUDO_USER}" = "root" ] && [ ! "${SUDO_USER}" = "pi" ]; then 635 | if getent passwd ${SUDO_USER} > /dev/null; then 636 | _log "Adding ${SUDO_USER} to the ${sshGrp} group ..." 637 | usermod -a -G ${sshGrp} ${SUDO_USER} 638 | fi 639 | fi 640 | 641 | # remove networkmanager and dhcpcd5 then configure networkd 642 | if [ ${skipNet} -ne 1 ]; then 643 | 644 | if [ "${BOARD}" = "helios64" ]; then 645 | echo -e '#!/bin/sh\n/usr/sbin/ethtool --offload eth1 rx off tx off' > /usr/lib/networkd-dispatcher/routable.d/10-disable-offloading 646 | fi 647 | 648 | defLink="/etc/systemd/network/99-default.link" 649 | rm -fv "${defLink}" 650 | if [ ${rpi} -eq 1 ] && [ ${version} -eq 7 ]; then 651 | _log "Force eth0 name on RPi ..." 652 | mac="$(ip -j a show dev eth0 | jq -r .[].address | head -n1)" 653 | if [ -z "${mac}" ]; then 654 | mac="$(ip -j a show dev end0 | jq -r .[].address | head -n1)" 655 | fi 656 | _log "mac address - ${mac}" 657 | if [ -n "${mac}" ]; then 658 | echo -e "[Match]\nMACAddress=${mac}\n[Link]\nName=eth0" > /etc/systemd/network/10-persistent-eth0.link 659 | fi 660 | fi 661 | 662 | _log "Removing network-manager and dhcpcd5 ..." 663 | apt-get -y --autoremove purge network-manager dhcpcd5 2>&1 | tee -a ${logfile} 664 | 665 | _log "Enable and start systemd-resolved ..." 666 | systemctl enable systemd-resolved 2>&1 | tee -a ${logfile} 667 | systemctl start systemd-resolved 2>&1 | tee -a ${logfile} 668 | rm /etc/resolv.conf 669 | ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf 670 | 671 | if [ -f "${rfkill}" ]; then 672 | _log "Unblocking wifi with rfkill ..." 673 | ${rfkill} unblock all 674 | fi 675 | 676 | for nic in $(ls /sys/class/net | grep -vE "br-|docker|dummy|ip6|lo|sit|tun|veth|virbr|wg"); do 677 | if grep -q "${nic}" ${OMV_CONFIG_FILE}; then 678 | _log "${nic} already found in database. Skipping..." 679 | continue 680 | fi 681 | if udevadm info /sys/class/net/${nic} | grep -q wlan; then 682 | if [ -f "${wpaConf}" ]; then 683 | country=$(awk -F'=' '/country=/{gsub(/["\r]/,""); print $NF}' ${wpaConf}) 684 | wifiName=$(awk -F'=' '/ssid="/{st=index($0,"="); ssid=substr($0,st+1); gsub(/["\r]/,"",ssid); print ssid; exit}' ${wpaConf}) 685 | wifiPass=$(awk -F'=' '/psk="/{st=index($0,"="); pass=substr($0,st+1); gsub(/["\r]/,"",pass); print pass; exit}' ${wpaConf}) 686 | 687 | if [ -n "${country}" ] && [ -n "${wifiName}" ] && [ -n "${wifiPass}" ]; then 688 | if [ -f "${crda}" ]; then 689 | awk -i inplace -F'=' -v country="$country" '/REGDOMAIN=/{$0=$1"="country} {print $0}' ${crda} 690 | fi 691 | _log "Adding ${nic} to openmedivault database ..." 692 | jq --null-input --compact-output \ 693 | "{uuid: \"${OMV_CONFIGOBJECT_NEW_UUID}\", devicename: \"${nic}\", type: \"wifi\", method: \"dhcp\", method6: \"dhcp\", wpassid: \"${wifiName}\", wpapsk: \"${wifiPass}\"}" | \ 694 | omv-confdbadm update "conf.system.network.interface" - 695 | if grep -q "${nic}" ${OMV_CONFIG_FILE}; then 696 | cfg=1 697 | fi 698 | fi 699 | fi 700 | else 701 | _log "Adding ${nic} to openmedivault database ..." 702 | if [ -n "$(ip -j -o -4 addr show ${nic} | jq --raw-output '.[] | select(.addr_info[0].dev) | .addr_info[0].local')" ] && \ 703 | [ "$(ip -j -o -4 addr show ${nic} | jq --raw-output '.[] | select(.addr_info[0].dev) | .addr_info[0].dynamic')" == "null" ]; then 704 | ipv4Addr=$(ip -j -o -4 addr show ${nic} | jq --raw-output '.[] | select(.addr_info[0].dev) | .addr_info[0].local') 705 | ipv4CIDR=$(ip -j -o -4 addr show ${nic} | jq --raw-output '.[] | select(.addr_info[0].dev) | .addr_info[0].prefixlen') 706 | bitmaskValue=$(( 0xffffffff ^ ((1 << (32 - ipv4CIDR)) - 1) )) 707 | ipv4Netmask=$(( (bitmaskValue >> 24) & 0xff )).$(( (bitmaskValue >> 16) & 0xff )).$(( (bitmaskValue >> 8) & 0xff )).$(( bitmaskValue & 0xff )) 708 | ipv4GW=$(ip -j -o -4 route show | jq --raw-output '.[] | select(.dst=="default") | .gateway') 709 | jq --null-input --compact-output \ 710 | "{uuid: \"${OMV_CONFIGOBJECT_NEW_UUID}\", devicename: \"${nic}\", method: \"static\", address: \"${ipv4Addr}\", netmask: \"${ipv4Netmask}\", gateway: \"${ipv4GW}\", dnsnameservers: \"8.8.8.8 ${ipv4GW}\"}" | \ 711 | omv-confdbadm update "conf.system.network.interface" - 712 | else 713 | jq --null-input --compact-output \ 714 | "{uuid: \"${OMV_CONFIGOBJECT_NEW_UUID}\", devicename: \"${nic}\", method: \"dhcp\", method6: \"dhcp\"}" | \ 715 | omv-confdbadm update "conf.system.network.interface" - 716 | fi 717 | 718 | if grep -q "${nic}" ${OMV_CONFIG_FILE}; then 719 | cfg=1 720 | fi 721 | fi 722 | done 723 | 724 | if [ ${cfg} -eq 1 ]; then 725 | _log "IP address may change and you could lose connection if running this script via ssh." 726 | 727 | # create config files 728 | ${confCmd} systemd-networkd 2>&1 | tee -a ${logfile} 729 | if [ ${PIPESTATUS[0]} -gt 0 ]; then 730 | _log "Error applying network changes. Skipping reboot!" 731 | skipReboot=1 732 | fi 733 | 734 | if [ ${skipReboot} -ne 1 ]; then 735 | _log "Network setup. Rebooting..." 736 | reboot 737 | fi 738 | else 739 | _log "It is recommended to reboot and then setup the network adapter in the openmediavault web interface." 740 | fi 741 | 742 | fi 743 | 744 | _log "done." 745 | 746 | exit 0 747 | -------------------------------------------------------------------------------- /installOld: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # shellcheck disable=SC1090,SC1091,SC2010,SC2016,SC2046,SC2086,SC2174,SC2181 4 | # 5 | # Copyright (c) 2015-2023 OpenMediaVault Plugin Developers 6 | # Copyright (c) 2017-2020 Armbian Developers 7 | # 8 | # This file is licensed under the terms of the GNU General Public 9 | # License version 2. This program is licensed "as is" without any 10 | # warranty of any kind, whether express or implied. 11 | # 12 | # Ideas/code used from: 13 | # https://github.com/armbian/config/blob/master/debian-software 14 | # https://forum.openmediavault.org/index.php/Thread/25062-Install-OMV5-on-Debian-10-Buster/ 15 | # 16 | 17 | logfile="omv_install.log" 18 | version="2.2.3" 19 | 20 | 21 | _log() 22 | { 23 | msg=${1} 24 | echo "[$(date +'%Y-%m-%d %H:%M:%S%z')] [omvinstall] ${msg}" | tee -a ${logfile} 25 | } 26 | 27 | _log "version :: ${version}" 28 | 29 | if [[ $(id -u) -ne 0 ]]; then 30 | echo "This script must be executed as root or using sudo." 31 | exit 99 32 | fi 33 | 34 | systemd="$(ps --no-headers -o comm 1)" 35 | if [ ! "${systemd}" = "systemd" ]; then 36 | echo "This system is not running systemd. Exiting..." 37 | exit 100 38 | fi 39 | 40 | if dpkg -l | grep -Eqw "gdm3|sddm|lxdm|xdm|lightdm|slim|wdm"; then 41 | echo "This system is running a desktop environment!" 42 | echo "Please use a Lite version of the image or" 43 | echo "do not choose to install a desktop environment." 44 | echo "This install is not supported." 45 | echo "Search the forum for more info - https://forum.openmediavault.org" 46 | echo "Exiting..." 47 | exit 101 48 | fi 49 | 50 | if [ ! -L "/sbin" ] || [ ! -L "/bin" ]; then 51 | echo "The /usr directories seem not to be migrated. Please check the" 52 | echo "following pages for more information:" 53 | echo "- https://wiki.debian.org/UsrMerge" 54 | echo "- https://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge" 55 | echo "Exiting..." 56 | exit 102 57 | fi 58 | 59 | if [ -f "/.dockerenv" ]; then 60 | echo "Docker detected. OMV does not work in Docker!" 61 | exit 103 62 | fi 63 | 64 | if grep -q 'machine-lxc' /proc/1/cgroup; then 65 | echo "LXC detected. OMV does not work in LXC!" 66 | exit 104 67 | fi 68 | 69 | declare -i armbian=0 70 | declare -i beta=0 71 | declare -i cfg=0 72 | declare -i ipv6=0 73 | declare -i rpi=0 74 | declare -i skipFlash=0 75 | declare -i skipNet=0 76 | declare -i skipReboot=0 77 | declare -i useMirror=0 78 | declare -i version 79 | 80 | declare -l codename 81 | declare -l omvCodename 82 | declare -l omvInstall="" 83 | declare -l omvextrasInstall="" 84 | 85 | declare gov="" 86 | declare minspd="" 87 | declare maxspd="" 88 | 89 | aptclean="/usr/sbin/omv-aptclean" 90 | confCmd="omv-salt deploy run" 91 | cpuFreqDef="/etc/default/cpufrequtils" 92 | crda="/etc/default/crda" 93 | defaultGovSearch="^CONFIG_CPU_FREQ_DEFAULT_GOV_" 94 | forceIpv4="/etc/apt/apt.conf.d/99force-ipv4" 95 | ioniceCron="/etc/cron.d/make_nas_processes_faster" 96 | ioniceScript="/usr/sbin/omv-ionice" 97 | keyserver="hkp://keyserver.ubuntu.com:80" 98 | mirror="https://mirrors.tuna.tsinghua.edu.cn" 99 | omvKey="/usr/share/keyrings/openmediavault-archive-keyring.gpg" 100 | omvRepo="http://packages.openmediavault.org/public" 101 | omvKeyUrl="${omvRepo}/archive.key" 102 | omvSources="/etc/apt/sources.list.d/openmediavault.list" 103 | resolvTmp="/root/resolv.conf" 104 | rfkill="/usr/sbin/rfkill" 105 | smbOptions="" 106 | sshGrp="ssh" 107 | url="https://github.com/OpenMediaVault-Plugin-Developers/packages/raw/master" 108 | vsCodeList="/etc/apt/sources.list.d/vscode.list" 109 | wpaConf="/etc/wpa_supplicant/wpa_supplicant.conf" 110 | 111 | export DEBIAN_FRONTEND=noninteractive 112 | export APT_LISTCHANGES_FRONTEND=none 113 | export LANG=C.UTF-8 114 | export LANGUAGE=C 115 | export LC_ALL=C.UTF-8 116 | 117 | if [ -f /etc/armbian-release ]; then 118 | . /etc/armbian-release 119 | armbian=1 120 | _log "Armbian" 121 | fi 122 | 123 | while getopts "bfhimnr" opt; do 124 | _log "option ${opt}" 125 | case "${opt}" in 126 | b) 127 | beta=1 128 | ;; 129 | f) 130 | skipFlash=1 131 | ;; 132 | h) 133 | echo "Use the following flags:" 134 | echo " -f" 135 | echo " to skip the installation of the flashmemory plugin" 136 | echo " -i" 137 | echo " enable using IPv6 for apt" 138 | echo " -m" 139 | echo " to repo mirror from ${mirror}" 140 | echo " -n" 141 | echo " to skip the network setup" 142 | echo " -r" 143 | echo " to skip reboot" 144 | echo "" 145 | echo "Examples:" 146 | echo " install" 147 | echo " install -f" 148 | echo " install -n" 149 | echo "" 150 | echo "Notes:" 151 | echo " This script will always install:" 152 | echo " - OMV 5.x on Debian 10 (Buster) EOL" 153 | echo " - OMV 6.x on Debian 11 (Bullseye)" 154 | echo "" 155 | exit 100 156 | ;; 157 | i) 158 | ipv6=1 159 | ;; 160 | m) 161 | useMirror=1 162 | omvRepo="${mirror}/OpenMediaVault/public" 163 | ;; 164 | n) 165 | skipNet=1 166 | ;; 167 | r) 168 | skipReboot=1 169 | ;; 170 | \?) 171 | _log "Invalid option: -${OPTARG}" 172 | ;; 173 | esac 174 | done 175 | 176 | _log "Starting ..." 177 | 178 | # Fix permissions on / if wrong 179 | _log "Current / permissions = $(stat -c %a /)" 180 | chmod -v g-w,o-w / 2>&1 | tee -a ${logfile} 181 | _log "New / permissions = $(stat -c %a /)" 182 | 183 | # if ipv6 is not enabled, create apt config file to force ipv4 184 | if [ ${ipv6} -ne 1 ]; then 185 | _log "Forcing IPv4 only for apt..." 186 | echo 'Acquire::ForceIPv4 "true";' > ${forceIpv4} 187 | fi 188 | 189 | 190 | if [ -f "/usr/libexec/config-rtl8367rb.sh" ]; then 191 | _log "Skipping network because swconfig controlled switch found." 192 | skipNet=1 193 | fi 194 | 195 | _log "Updating repos before installing..." 196 | apt-get --allow-releaseinfo-change update 2>&1 | tee -a ${logfile} 197 | 198 | _log "Installing lsb_release..." 199 | apt-get --yes --no-install-recommends --reinstall install lsb-release 2>&1 | tee -a ${logfile} 200 | 201 | arch="$(dpkg --print-architecture)" 202 | _log "Arch :: ${arch}" 203 | 204 | # exit if not supported architecture 205 | case ${arch} in 206 | arm64|armhf|amd64|i386) 207 | _log "Supported architecture" 208 | ;; 209 | *) 210 | _log "Unsupported architecture :: ${arch}" 211 | exit 5 212 | ;; 213 | esac 214 | 215 | codename="$(lsb_release --codename --short)" 216 | _log "Codename :: ${codename}" 217 | 218 | case ${codename} in 219 | buster) 220 | keys="648ACFD622F3D138 112695A0E562B32A" 221 | omvCodename="usul" 222 | version=5 223 | smbOptions="${smbOptions}\nwrite cache size = 524288" 224 | _log "This version of OMV is End of Life. Please consider using OMV 6.x." 225 | ;; 226 | bullseye) 227 | keys="0E98404D386FA1D9 A48449044AAD5C5D" 228 | omvCodename="shaitan" 229 | version=6 230 | ;; 231 | bookworm) 232 | if [ ${beta} -eq 1 ]; then 233 | omvCodename="sandworm" 234 | version=7 235 | else 236 | _log "Unsupported version. Only Debian 10 (Buster) and 11 (Bullseye) are supported. Exiting..." 237 | exit 1 238 | fi 239 | _log "Copying /etc/resolv.conf to ${resolvTmp} ..." 240 | cp -fv /etc/resolv.conf "${resolvTmp}" 241 | _log "$(cat /etc/resolv.conf)" 242 | sshGrp="_ssh" 243 | ;; 244 | *) 245 | _log "Unsupported version. Only Debian 10 (Buster) and 11 (Bullseye) are supported. Exiting..." 246 | exit 1 247 | ;; 248 | esac 249 | _log "Debian :: ${codename}" 250 | _log "${omvCodename} :: ${version}" 251 | 252 | hostname="$(hostname --short)" 253 | _log "Hostname :: ${hostname}" 254 | domainname="$(hostname --domain)" 255 | _log "Domain name :: ${domainname}" 256 | tz="$(timedatectl show --property=Timezone --value)" 257 | _log "timezone :: ${tz}" 258 | 259 | regex='[a-zA-Z]([-a-zA-Z0-9]{0,61}[a-zA-Z0-9])' 260 | if [[ ! ${hostname} =~ ${regex} ]]; then 261 | _log "Invalid hostname. Exiting..." 262 | exit 6 263 | fi 264 | 265 | # Add Debian signing keys to raspbian to prevent apt-get update failures 266 | # when OMV adds security and/or backports repos 267 | if grep -rq raspberrypi.org /etc/apt/*; then 268 | rpivers="$(awk '$1 == "Revision" { print $3 }' /proc/cpuinfo)" 269 | _log "RPi revision code :: ${rpivers}" 270 | # https://elinux.org/RPi_HardwareHistory 271 | if [[ "${rpivers:0:1}" =~ [09] ]] && [[ ! "${rpivers:0:3}" =~ 902 ]]; then 272 | _log "This RPi1 is not supported (not true armhf). Exiting..." 273 | exit 7 274 | fi 275 | rpi=1 276 | _log "Adding Debian signing keys..." 277 | for key in ${keys}; do 278 | apt-key adv --no-tty --keyserver ${keyserver} --recv-keys "${key}" 2>&1 | tee -a ${logfile} 279 | done 280 | _log "Installing monit from raspberrypi repo..." 281 | apt-get --yes --no-install-recommends install -t ${codename} monit 2>&1 | tee -a ${logfile} 282 | 283 | # remove vscode repo if found since there is no desktop environment 284 | # empty file will exist to keep raspberrypi-sys-mods package from adding it back 285 | truncate -s 0 "${vsCodeList}" 286 | fi 287 | 288 | # remove armbian netplan file if found 289 | anp="/etc/netplan/armbian-default.yaml" 290 | if [ -e "${anp}" ]; then 291 | _log "Removing Armbian netplan file..." 292 | rm -fv "${anp}" 293 | fi 294 | 295 | dpkg -P udisks2 2>&1 | tee -a ${logfile} 296 | 297 | _log "Install prerequisites..." 298 | apt-get --yes --no-install-recommends install gnupg wget 2>&1 | tee -a ${logfile} 299 | 300 | if [ ${armbian} -eq 1 ]; then 301 | systemctl unmask systemd-networkd.service 2>&1 | tee -a ${logfile} 302 | # save off cpuFreq settings before installing the openmediavault 303 | if [ -f "${cpuFreqDef}" ]; then 304 | . ${cpuFreqDef} 305 | gov="${GOVERNOR}" 306 | minspd="${MIN_SPEED}" 307 | maxspd="${MAX_SPEED}" 308 | fi 309 | fi 310 | 311 | # install openmediavault if not installed already 312 | omvInstall=$(dpkg -l | awk '$2 == "openmediavault" { print $1 }') 313 | if [[ ! "${omvInstall}" == "ii" ]]; then 314 | _log "Installing openmediavault required packages..." 315 | apt-get --yes --no-install-recommends install postfix 2>&1 | tee -a ${logfile} 316 | if [ $? -gt 0 ]; then 317 | _log "failed installing postfix" 318 | sed -i '/^myhostname/d' /etc/postfix/main.cf 319 | apt-get --yes --fix-broken install 2>&1 | tee -a ${logfile} 320 | if [ $? -gt 0 ]; then 321 | _log "failed installing postfix and unable to fix" 322 | exit 2 323 | fi 324 | fi 325 | 326 | _log "Adding openmediavault repo and key..." 327 | echo "deb [signed-by=${omvKey}] ${omvRepo} ${omvCodename} main" | tee ${omvSources} 328 | wget --quiet --output-document=- "${omvKeyUrl}" | gpg --dearmor --yes --output "${omvKey}" 329 | 330 | _log "Updating repos..." 331 | apt-get update 2>&1 | tee -a ${logfile} 332 | if [ $? -gt 0 ]; then 333 | _log "failed to update apt repos." 334 | exit 2 335 | fi 336 | 337 | _log "Install openmediavault-keyring..." 338 | apt-get --yes install openmediavault-keyring 2>&1 | tee -a ${logfile} 339 | if [ $? -gt 0 ]; then 340 | _log "failed to install openmediavault-keyring package." 341 | exit 2 342 | fi 343 | 344 | monitInstall=$(dpkg -l | awk '$2 == "monit" { print $1 }') 345 | if [[ ! "${monitInstall}" == "ii" ]]; then 346 | apt-get --yes --no-install-recommends install monit 2>&1 | tee -a ${logfile} 347 | if [ $? -gt 0 ]; then 348 | _log "failed installing monit" 349 | exit 2 350 | fi 351 | fi 352 | 353 | _log "Installing openmediavault..." 354 | aptFlags="--yes --auto-remove --show-upgraded --allow-downgrades --allow-change-held-packages --no-install-recommends" 355 | apt-get ${aptFlags} install openmediavault 2>&1 | tee -a ${logfile} 356 | if [ $? -gt 0 ]; then 357 | _log "failed to install openmediavault package." 358 | exit 2 359 | fi 360 | 361 | omv-confdbadm populate 2>&1 | tee -a ${logfile} 362 | omv-salt deploy run hosts 2>&1 | tee -a ${logfile} 363 | fi 364 | _log "Testing DNS..." 365 | if ! ping -4 -q -c2 omv-extras.org 2>/dev/null; then 366 | _log "DNS failing to resolve. Fixing ..." 367 | if [ -f "${resolvTmp}" ]; then 368 | _log "Reverting /etc/resolv.conf to saved copy ..." 369 | rm -fv /etc/resolv.conf 370 | cp -v "${resolvTmp}" /etc/resolv.conf 371 | fi 372 | fi 373 | 374 | # check if openmediavault is install properly 375 | omvInstall=$(dpkg -l | awk '$2 == "openmediavault" { print $1 }') 376 | if [[ ! "${omvInstall}" == "ii" ]]; then 377 | _log "openmediavault package failed to install or is in a bad state." 378 | exit 3 379 | fi 380 | 381 | . /etc/default/openmediavault 382 | . /usr/share/openmediavault/scripts/helper-functions 383 | 384 | # remove backports from sources.list to avoid duplicate sources warning 385 | sed -i "/\(stretch\|buster\|bullseye\)-backports/d" /etc/apt/sources.list 386 | 387 | if [ ${rpi} -eq 1 ]; then 388 | if [ ! "${arch}" = "arm64" ]; then 389 | omv_set_default "OMV_APT_USE_OS_SECURITY" false true 390 | fi 391 | omv_set_default "OMV_APT_USE_KERNEL_BACKPORTS" false true 392 | fi 393 | 394 | # change repos if useMirror is specified 395 | if [ ${useMirror} -eq 1 ]; then 396 | _log "Changing repos to mirror from ${mirror} ..." 397 | omv_set_default OMV_APT_REPOSITORY_URL "${mirror}/OpenMediaVault/public" true 398 | omv_set_default OMV_APT_ALT_REPOSITORY_URL "${mirror}/OpenMediaVault/packages" true 399 | omv_set_default OMV_APT_KERNEL_BACKPORTS_REPOSITORY_URL "${mirror}/debian" true 400 | omv_set_default OMV_APT_SECURITY_REPOSITORY_URL "${mirror}/debian-security" true 401 | omv_set_default OMV_EXTRAS_APT_REPOSITORY_URL "${mirror}/OpenMediaVault/openmediavault-plugin-developers" true 402 | omv_set_default OMV_DOCKER_APT_REPOSITORY_URL "${mirror}/docker-ce/linux/debian" true 403 | omv_set_default OMV_PROXMOX_APT_REPOSITORY_URL "${mirror}/proxmox/debian" true 404 | 405 | # update pillar default list - /srv/pillar/omv/default.sls 406 | omv-salt stage run prepare 2>&1 | tee -a ${logfile} 407 | 408 | # update config files 409 | ${confCmd} apt 2>&1 | tee -a ${logfile} 410 | fi 411 | 412 | # install omv-extras 413 | _log "Downloading omv-extras.org plugin for openmediavault ${version}.x ..." 414 | file="openmediavault-omvextrasorg_latest_all${version}.deb" 415 | 416 | if [ -f "${file}" ]; then 417 | rm ${file} 418 | fi 419 | wget ${url}/${file} 420 | if [ -f "${file}" ]; then 421 | if ! dpkg --install ${file}; then 422 | _log "Installing other dependencies ..." 423 | apt-get --yes --fix-broken install 2>&1 | tee -a ${logfile} 424 | omvextrasInstall=$(dpkg -l | awk '$2 == "openmediavault-omvextrasorg" { print $1 }') 425 | if [[ ! "${omvextrasInstall}" == "ii" ]]; then 426 | _log "omv-extras failed to install correctly. Trying to fix apt ..." 427 | apt-get --yes --fix-broken install 2>&1 | tee -a ${logfile} 428 | if [ $? -gt 0 ]; then 429 | _log "Fix failed and openmediavault-omvextrasorg is in a bad state." 430 | exit 3 431 | fi 432 | fi 433 | omvextrasInstall=$(dpkg -l | awk '$2 == "openmediavault-omvextrasorg" { print $1 }') 434 | if [[ ! "${omvextrasInstall}" == "ii" ]]; then 435 | _log "openmediavault-omvextrasorg package failed to install or is in a bad state." 436 | exit 3 437 | fi 438 | fi 439 | 440 | _log "Updating repos ..." 441 | ${aptclean} repos 2>&1 | tee -a ${logfile} 442 | else 443 | _log "There was a problem downloading the package." 444 | fi 445 | 446 | # disable armbian log services if found 447 | for service in log2ram armbian-ramlog armbian-zram-config; do 448 | if systemctl list-units --full -all | grep ${service}; then 449 | systemctl stop ${service} 2>&1 | tee -a ${logfile} 450 | systemctl disable ${service} 2>&1 | tee -a ${logfile} 451 | fi 452 | done 453 | rm -f /etc/cron.daily/armbian-ram-logging 454 | if [ -f "/etc/default/armbian-ramlog" ]; then 455 | sed -i "s/ENABLED=.*/ENABLED=false/g" /etc/default/armbian-ramlog 456 | fi 457 | if [ -f "/etc/default/armbian-zram-config" ]; then 458 | sed -i "s/ENABLED=.*/ENABLED=false/g" /etc/default/armbian-zram-config 459 | fi 460 | if [ -f "/etc/systemd/system/logrotate.service" ]; then 461 | rm -f /etc/systemd/system/logrotate.service 462 | systemctl daemon-reload 463 | fi 464 | 465 | # install flashmemory plugin unless disabled 466 | if [ ${skipFlash} -eq 1 ]; then 467 | _log "Skipping installation of the flashmemory plugin." 468 | else 469 | _log "Install folder2ram..." 470 | apt-get --yes --fix-missing --no-install-recommends install folder2ram 2>&1 | tee -a ${logfile} 471 | if [ $? -gt 0 ]; then 472 | _log "Installed folder2ram." 473 | else 474 | _log "Failed to install folder2ram." 475 | fi 476 | _log "Install flashmemory plugin..." 477 | apt-get --yes install openmediavault-flashmemory 2>&1 | tee -a ${logfile} 478 | if [ $? -gt 0 ]; then 479 | _log "Installed flashmemory plugin." 480 | else 481 | _log "Failed to install flashmemory plugin." 482 | ${confCmd} flashmemory 2>&1 | tee -a ${logfile} 483 | apt-get --yes --fix-broken install 2>&1 | tee -a ${logfile} 484 | fi 485 | fi 486 | 487 | # change default OMV settings 488 | if [ -n "${smbOptions}" ]; then 489 | omv_config_update "/config/services/smb/extraoptions" "$(echo -e "${smbOptions}")" 490 | fi 491 | omv_config_update "/config/services/ssh/enable" "1" 492 | omv_config_update "/config/services/ssh/permitrootlogin" "1" 493 | omv_config_update "/config/system/time/ntp/enable" "1" 494 | omv_config_update "/config/system/time/timezone" "${tz}" 495 | omv_config_update "/config/system/network/dns/hostname" "${hostname}" 496 | if [ -n "${domainname}" ]; then 497 | omv_config_update "/config/system/network/dns/domainname" "${domainname}" 498 | fi 499 | 500 | # disable monitoring and apply changes 501 | _log "Disabling data collection ..." 502 | /usr/sbin/omv-rpc -u admin "perfstats" "set" '{"enable":false}' 2>&1 | tee -a ${logfile} 503 | /usr/sbin/omv-rpc -u admin "config" "applyChanges" '{ "modules": ["monit","rrdcached","collectd"],"force": true }' 2>&1 | tee -a ${logfile} 504 | 505 | # set min/max frequency and watchdog for RPi boards 506 | rpi_model="/proc/device-tree/model" 507 | if [ -f "${rpi_model}" ] && [[ $(awk '{ print $1 }' ${rpi_model}) = "Raspberry" ]]; then 508 | if [ ${version} -lt 6 ]; then 509 | omv_set_default "OMV_WATCHDOG_DEFAULT_MODULE" "bcm2835_wdt" 510 | omv_set_default "OMV_WATCHDOG_CONF_WATCHDOG_TIMEOUT" "14" 511 | fi 512 | omv_set_default "OMV_WATCHDOG_SYSTEMD_RUNTIMEWATCHDOGSEC" "14s" true 513 | 514 | MIN_SPEED="$( ${cpuFreqDef} 521 | GOVERNOR="schedutil" 522 | MIN_SPEED="${MIN_SPEED}" 523 | MAX_SPEED="${MAX_SPEED}" 524 | EOF 525 | fi 526 | 527 | # get default governor for kernel 528 | if [ -f "/proc/config.gz" ]; then 529 | defaultGov="$(zgrep "${defaultGovSearch}" /proc/config.gz | sed -e "s/${defaultGovSearch}\(.*\)=y/\1/")" 530 | elif [ -f "/boot/config-$(uname -r)" ]; then 531 | defaultGov="$(grep "${defaultGovSearch}" /boot/config-$(uname -r) | sed -e "s/${defaultGovSearch}\(.*\)=y/\1/")" 532 | fi 533 | 534 | # governor and speed variables 535 | if [ ${armbian} -eq 1 ]; then 536 | if [ -n "${defaultGov}" ]; then 537 | GOVERNOR="${defaultGov,,}" 538 | elif [ -n "${gov}" ]; then 539 | GOVERNOR="${gov}" 540 | fi 541 | if [ -n "${minspd}" ]; then 542 | MIN_SPEED="${minspd}" 543 | fi 544 | if [ -n "${maxspd}" ]; then 545 | MAX_SPEED="${maxspd}" 546 | fi 547 | elif [ -f "${cpuFreqDef}" ]; then 548 | . ${cpuFreqDef} 549 | else 550 | if [ -z "${DEFAULT_GOV}" ]; then 551 | defaultGov="ondemand" 552 | fi 553 | GOVERNOR=${defaultGov,,} 554 | MIN_SPEED="0" 555 | MAX_SPEED="0" 556 | fi 557 | 558 | # set defaults in /etc/default/openmediavault 559 | omv_set_default "OMV_CPUFREQUTILS_GOVERNOR" "${GOVERNOR}" 560 | omv_set_default "OMV_CPUFREQUTILS_MINSPEED" "${MIN_SPEED}" 561 | omv_set_default "OMV_CPUFREQUTILS_MAXSPEED" "${MAX_SPEED}" 562 | 563 | # update pillar default list - /srv/pillar/omv/default.sls 564 | omv-salt stage run prepare 2>&1 | tee -a ${logfile} 565 | 566 | # update config files 567 | ${confCmd} nginx phpfpm samba flashmemory ssh chrony timezone monit rrdcached collectd cpufrequtils apt watchdog 2>&1 | tee -a ${logfile} 568 | 569 | # create php directories if they don't exist 570 | modDir="/var/lib/php/modules" 571 | if [ ! -d "${modDir}" ]; then 572 | mkdir --parents --mode=0755 ${modDir} 573 | fi 574 | sessDir="/var/lib/php/sessions" 575 | if [ ! -d "${sessDir}" ]; then 576 | mkdir --parents --mode=1733 ${sessDir} 577 | fi 578 | 579 | if [ -f "${forceIpv4}" ]; then 580 | rm ${forceIpv4} 581 | fi 582 | 583 | if [ -f "/etc/init.d/proftpd" ]; then 584 | systemctl disable proftpd.service 585 | systemctl stop proftpd.service 586 | fi 587 | 588 | # add admin user to openmediavault-admin group if it exists 589 | if getent passwd admin > /dev/null; then 590 | usermod -a -G openmediavault-admin admin 2>&1 | tee -a ${logfile} 591 | fi 592 | 593 | if [[ "${arch}" == "amd64" ]] || [[ "${arch}" == "i386" ]]; then 594 | # skip ionice on x86 boards 595 | _log "Done." 596 | exit 0 597 | fi 598 | 599 | if [ ! "${GOVERNOR,,}" = "schedutil" ]; then 600 | _log "Add a cron job to make NAS processes more snappy and silence rsyslog" 601 | cat << EOF > /etc/rsyslog.d/omv-armbian.conf 602 | :msg, contains, "omv-ionice" ~ 603 | :msg, contains, "action " ~ 604 | :msg, contains, "netsnmp_assert" ~ 605 | :msg, contains, "Failed to initiate sched scan" ~ 606 | EOF 607 | systemctl restart rsyslog 2>&1 | tee -a ${logfile} 608 | 609 | # add taskset to ionice cronjob for biglittle boards 610 | case ${BOARD} in 611 | odroidxu4|bananapim3|nanopifire3|nanopct3plus|nanopim3|nanopi-r6s) 612 | taskset='; taskset -c -p 4-7 ${srv}' 613 | ;; 614 | *rk3399*|*edge*|nanopct4|nanopim4|nanopineo4|renegade-elite|rockpi-4*|rockpro64|helios64) 615 | taskset='; taskset -c -p 4-5 ${srv}' 616 | ;; 617 | odroidn2) 618 | taskset='; taskset -c -p 2-5 ${srv}' 619 | ;; 620 | esac 621 | 622 | # create ionice script 623 | cat << EOF > ${ioniceScript} 624 | #!/bin/sh 625 | 626 | for srv in \$(pgrep "ftpd|nfsiod|smbd"); do 627 | ionice -c1 -p \${srv} ${taskset}; 628 | done 629 | EOF 630 | chmod 755 ${ioniceScript} 631 | 632 | # create ionice cronjob 633 | cat << EOF > ${ioniceCron} 634 | * * * * * root ${ioniceScript} >/dev/null 2>&1 635 | EOF 636 | chmod 600 ${ioniceCron} 637 | fi 638 | 639 | # add pi user to ssh group if it exists 640 | if getent passwd pi > /dev/null; then 641 | _log "Adding pi user to ssh group ..." 642 | usermod -a -G ${sshGrp} pi 643 | fi 644 | 645 | # add user running the script to ssh group if not pi or root 646 | if [ -n "${SUDO_USER}" ] && [ ! "${SUDO_USER}" = "root" ] && [ ! "${SUDO_USER}" = "pi" ]; then 647 | if getent passwd ${SUDO_USER} > /dev/null; then 648 | _log "Adding ${SUDO_USER} to the ssh group ..." 649 | usermod -a -G ssh ${SUDO_USER} 650 | fi 651 | fi 652 | 653 | # remove networkmanager and dhcpcd5 then configure networkd 654 | if [ ${skipNet} -ne 1 ]; then 655 | 656 | if [ "${BOARD}" = "helios64" ]; then 657 | echo -e '#!/bin/sh\n/usr/sbin/ethtool --offload eth1 rx off tx off' > /usr/lib/networkd-dispatcher/routable.d/10-disable-offloading 658 | fi 659 | 660 | defLink="/etc/systemd/network/99-default.link" 661 | if [ -e "${defLink}" ]; then 662 | rm -fv "${defLink}" 663 | fi 664 | 665 | _log "Removing network-manager and dhcpcd5 ..." 666 | apt-get -y --autoremove purge network-manager dhcpcd5 2>&1 | tee -a ${logfile} 667 | 668 | _log "Enable and start systemd-resolved ..." 669 | systemctl enable systemd-resolved 2>&1 | tee -a ${logfile} 670 | systemctl start systemd-resolved 2>&1 | tee -a ${logfile} 671 | rm /etc/resolv.conf 672 | ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf 673 | 674 | if [ -f "${rfkill}" ]; then 675 | _log "Unblocking wifi with rfkill ..." 676 | ${rfkill} unblock all 677 | fi 678 | 679 | for nic in $(ls /sys/class/net | grep -vE "br-|docker|dummy|ip6|lo|sit|tun|veth|virbr|wg"); do 680 | if grep -q "${nic}" ${OMV_CONFIG_FILE}; then 681 | _log "${nic} already found in database. Skipping..." 682 | continue 683 | fi 684 | if udevadm info /sys/class/net/${nic} | grep -q wlan; then 685 | if [ -f "${wpaConf}" ]; then 686 | country=$(awk -F'=' '/country=/{gsub(/["\r]/,""); print $NF}' ${wpaConf}) 687 | wifiName=$(awk -F'=' '/ssid="/{st=index($0,"="); ssid=substr($0,st+1); gsub(/["\r]/,"",ssid); print ssid; exit}' ${wpaConf}) 688 | wifiPass=$(awk -F'=' '/psk="/{st=index($0,"="); pass=substr($0,st+1); gsub(/["\r]/,"",pass); print pass; exit}' ${wpaConf}) 689 | 690 | if [ -n "${country}" ] && [ -n "${wifiName}" ] && [ -n "${wifiPass}" ]; then 691 | if [ -f "${crda}" ]; then 692 | awk -i inplace -F'=' -v country="$country" '/REGDOMAIN=/{$0=$1"="country} {print $0}' ${crda} 693 | fi 694 | _log "Adding ${nic} to openmedivault database ..." 695 | jq --null-input --compact-output \ 696 | "{uuid: \"${OMV_CONFIGOBJECT_NEW_UUID}\", devicename: \"${nic}\", type: \"wifi\", method: \"dhcp\", method6: \"dhcp\", wpassid: \"${wifiName}\", wpapsk: \"${wifiPass}\"}" | \ 697 | omv-confdbadm update "conf.system.network.interface" - 698 | if grep -q "${nic}" ${OMV_CONFIG_FILE}; then 699 | cfg=1 700 | fi 701 | fi 702 | fi 703 | else 704 | _log "Adding ${nic} to openmedivault database ..." 705 | if [ -n "$(ip -j -o -4 addr show ${nic} | jq --raw-output '.[] | select(.addr_info[0].dev) | .addr_info[0].local')" ] && \ 706 | [ "$(ip -j -o -4 addr show ${nic} | jq --raw-output '.[] | select(.addr_info[0].dev) | .addr_info[0].dynamic')" == "null" ]; then 707 | ipv4Addr=$(ip -j -o -4 addr show ${nic} | jq --raw-output '.[] | select(.addr_info[0].dev) | .addr_info[0].local') 708 | ipv4CIDR=$(ip -j -o -4 addr show ${nic} | jq --raw-output '.[] | select(.addr_info[0].dev) | .addr_info[0].prefixlen') 709 | bitmaskValue=$(( 0xffffffff ^ ((1 << (32 - ipv4CIDR)) - 1) )) 710 | ipv4Netmask=$(( (bitmaskValue >> 24) & 0xff )).$(( (bitmaskValue >> 16) & 0xff )).$(( (bitmaskValue >> 8) & 0xff )).$(( bitmaskValue & 0xff )) 711 | ipv4GW=$(ip -j -o -4 route show | jq --raw-output '.[] | select(.dst=="default") | .gateway') 712 | jq --null-input --compact-output \ 713 | "{uuid: \"${OMV_CONFIGOBJECT_NEW_UUID}\", devicename: \"${nic}\", method: \"static\", address: \"${ipv4Addr}\", netmask: \"${ipv4Netmask}\", gateway: \"${ipv4GW}\", dnsnameservers: \"8.8.8.8 ${ipv4GW}\"}" | \ 714 | omv-confdbadm update "conf.system.network.interface" - 715 | else 716 | jq --null-input --compact-output \ 717 | "{uuid: \"${OMV_CONFIGOBJECT_NEW_UUID}\", devicename: \"${nic}\", method: \"dhcp\", method6: \"dhcp\"}" | \ 718 | omv-confdbadm update "conf.system.network.interface" - 719 | fi 720 | 721 | if grep -q "${nic}" ${OMV_CONFIG_FILE}; then 722 | cfg=1 723 | fi 724 | fi 725 | done 726 | 727 | if [ ${cfg} -eq 1 ]; then 728 | _log "IP address may change and you could lose connection if running this script via ssh." 729 | 730 | # create config files 731 | ${confCmd} systemd-networkd 2>&1 | tee -a ${logfile} 732 | if [ $? -gt 0 ]; then 733 | _log "Error applying network changes. Skipping reboot!" 734 | skipReboot=1 735 | fi 736 | 737 | if [ ${skipReboot} -ne 1 ]; then 738 | _log "Network setup. Rebooting..." 739 | reboot 740 | fi 741 | else 742 | _log "It is recommended to reboot and then setup the network adapter in the openmediavault web interface." 743 | fi 744 | 745 | fi 746 | 747 | _log "done." 748 | 749 | exit 0 750 | -------------------------------------------------------------------------------- /md5sum: -------------------------------------------------------------------------------- 1 | eee7109cb36d983bcb6a96afd2772e2a install 2 | -------------------------------------------------------------------------------- /preinstall: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # this script should be run when instructed to. 4 | 5 | export DEBIAN_FRONTEND=noninteractive 6 | export APT_LISTCHANGES_FRONTEND=none 7 | export LANG=C.UTF-8 8 | export LANGUAGE=C 9 | export LC_ALL=C.UTF-8 10 | 11 | apt-get --yes --no-install-recommends install jq 12 | mac="$(ip -j a show dev eth0 | jq -r .[].address | head -n1)" 13 | if [ -z "${mac}" ]; then 14 | mac="$(ip -j a show dev end0 | jq -r .[].address | head -n1)" 15 | fi 16 | if [ -n "${mac}" ]; then 17 | echo "mac - ${mac}" 18 | echo -e "[Match]\nMACAddress=${mac}\n[Link]\nName=eth0" > /etc/systemd/network/10-persistent-eth0.link 19 | echo "Please reboot the system now." 20 | fi 21 | 22 | exit 0 23 | -------------------------------------------------------------------------------- /upgrade4to5: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # shellcheck disable=SC1090,SC1091,SC1117,SC2016,SC2046,SC2086 4 | # 5 | # Copyright (c) 2019-2020 OpenMediaVault Plugin Developers 6 | # 7 | # This file is licensed under the terms of the GNU General Public 8 | # License version 2. This program is licensed "as is" without any 9 | # warranty of any kind, whether express or implied. 10 | # 11 | # version: 1.1.0 12 | # 13 | 14 | if [[ $(id -u) -ne 0 ]]; then 15 | echo "This script must be executed as root or using sudo." 16 | exit 99 17 | fi 18 | 19 | export DEBIAN_FRONTEND=noninteractive 20 | export APT_LISTCHANGES_FRONTEND=none 21 | export LANG=C.UTF-8 22 | 23 | declare -i failed=0 24 | 25 | mkconf="/usr/sbin/omv-mkconf" 26 | plugins="cups dnsmasq docker-gui domoticz duplicati eyefi ldap letsencrypt mysql nginx openvpn pxe remotedesktop route shellinabox syncthing transmissionbt urbackup-server vdo virtualbox webdav netatalk route mumble vdr vdr-extras vdr-vnsiserver" 27 | 28 | if [ ! -f "${mkconf}" ]; then 29 | echo "Creating omv-mkconf to help remove plugins" 30 | echo "exit 0" > ${mkconf} 31 | chmod +x ${mkconf} 32 | fi 33 | 34 | echo "Purging incompatible plugins ..." 35 | for plugin in ${plugins}; do 36 | pkg="openmediavault-${plugin}" 37 | if dpkg --list | grep --quiet "${pkg}"; then 38 | if apt-get --yes purge ${pkg}; then 39 | echo "Successfully removed '${pkg}'." 40 | else 41 | echo "Failed to remove '${pkg}'." 42 | failed=1 43 | fi 44 | fi 45 | done 46 | 47 | if [ -f "${mkconf}" ]; then 48 | rm ${mkconf} 49 | fi 50 | 51 | if [ ${failed} -eq 1 ]; then 52 | echo "Failed to remove a plugin. Exiting..." 53 | exit 1 54 | fi 55 | 56 | echo "Changing sources ..." 57 | sed -i "s/stretch/buster/g" /etc/apt/sources.list 58 | sed -i "s/stretch/buster/g" /etc/apt/sources.list.d/* 59 | sed -i "s/arrakis/usul/g" /etc/apt/sources.list.d/* 60 | for list in /etc/apt/sources.list.d/omvextras.list /etc/apt/sources.list.d/omv-extras-org.list; do 61 | if [ -f "${list}" ]; then 62 | sed -i "/[Dd]ocker/d" ${list} 63 | fi 64 | done 65 | 66 | echo "Applying mtu fix ..." 67 | sed -i "s/<\/mtu>/0<\/mtu>/g" /etc/openmediavault/config.xml 68 | 69 | if [ -f /etc/apt/apt.conf ]; then 70 | echo "Changing apt.conf ..." 71 | sed -i "s/stretch/buster/g" /etc/apt/apt.conf 72 | fi 73 | 74 | echo "Removing Packages archive file ..." 75 | rm -f /var/cache/openmediavault/archives/Packages 76 | 77 | armbian="/etc/apt/sources.list.d/armbian.list" 78 | if [ -f "${armbian}" ]; then 79 | echo "Fixing Armbian repo ..." 80 | echo "deb http://apt.armbian.com buster main buster-utils" | sudo tee ${armbian} 81 | fi 82 | 83 | echo 'Debian GNU/Linux 10 \n \l' > /etc/issue 84 | 85 | echo "Running apt-get update ..." 86 | apt-get update 87 | 88 | echo "Updating base-files ..." 89 | apt-get --option DPkg::Options::="--force-confnew" install base-files 90 | 91 | echo "Running apt-get dist-upgrade ..." 92 | apt-get --yes \ 93 | --option DPkg::Options::="--force-confdef" \ 94 | --option DPkg::Options::="--force-confold" \ 95 | dist-upgrade 96 | 97 | arch="$(dpkg --print-architecture)" 98 | rule="/etc/udev/rules.d/80-net-setup-link.rules" 99 | 100 | if [ ! "${arch}" = "amd64" ] && [ ! "${arch}" = "i386" ]; then 101 | echo "Disable predictive network device naming ..." 102 | rm -fv ${rule} 103 | ln -s /dev/null ${rule} 104 | fi 105 | 106 | echo "Reboot now." 107 | echo "" 108 | echo "Then run:" 109 | echo " apt-get purge openmediavault-omvextrasorg resolvconf" 110 | echo " wget -O - https://github.com/OpenMediaVault-Plugin-Developers/packages/raw/master/install | bash" 111 | echo " apt-get update" 112 | echo " apt-get dist-upgrade" 113 | echo "" 114 | echo " omv-salt deploy run nginx" 115 | echo " omv-salt deploy run phpfpm" 116 | echo "" 117 | echo "https://forum.openmediavault.org/index.php?thread/27909-omv-5-0-finally-out/&postID=219830#post219830" 118 | --------------------------------------------------------------------------------