Signed-off-by: enoch85 <github@hanssonit.se>
This commit is contained in:
Daniel Hansson 2019-04-10 22:00:36 +02:00 коммит произвёл GitHub
Родитель 71104d5523
Коммит 5f840d5e8f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
14 изменённых файлов: 94 добавлений и 75 удалений

Просмотреть файл

@ -47,7 +47,7 @@ The script will mount and format the drive. Please select Manually Format & Moun
#### Installation
1. Get the latest install script from master and install it with a sudo user:<br>
`sudo bash -c "$(wget -q -O - https://raw.githubusercontent.com/nextcloud/vm/master/nextcloud_install_production.sh)"`
`sudo bash -c "$(curl -sLO https://raw.githubusercontent.com/nextcloud/vm/master/nextcloud_install_production.sh)"`
2. When the VM is installed it will automatically reboot. Remember to login with the user you created:<br>
`ssh <user>@IP-ADDRESS`<br>
If it automatically runs as root when you reboot the machine, you have to abort it by pressing `CTRL+C` and run the script as the user you just created:<br>
@ -160,7 +160,7 @@ Keep asking questions so that we can add them here.
**Q: How to install apps if not selected during first install?**
<br />
**A:** Go to the apps folder in this repo and download the script in raw format and run them. For installing Talk:
`wget https://raw.githubusercontent.com/nextcloud/vm/master/apps/talk.sh && sudo bash talk.sh`
`curl -sLO https://raw.githubusercontent.com/nextcloud/vm/master/apps/talk.sh && sudo bash talk.sh`
**Q: How to continue from partially installed system? - You got the FQDN wrong/You put in a bad password/ etc...**
<br />

Просмотреть файл

@ -35,8 +35,8 @@ check_distro_version
# Install Adminer
apt update -q4 & spinner_loading
install_if_not adminer
sudo wget -q "http://www.adminer.org/latest.php" -O "$ADMINERDIR"/latest.php
sudo ln -s "$ADMINERDIR"/latest.php "$ADMINERDIR"/adminer.php
curl_to_dir "http://www.adminer.org" "latest.php" "$ADMINERDIR"
ln -s "$ADMINERDIR"/latest.php "$ADMINERDIR"/adminer.php
cat << ADMINER_CREATE > "$ADMINER_CONF"
Alias /adminer.php $ADMINERDIR/adminer.php

Просмотреть файл

@ -44,20 +44,15 @@ on your domain to be able to run this script.
If you use the Nextcloud VM you can use the Let's Encrypt script to get SSL and activate your Nextcloud domain.
When SSL is activated, run these commands from your terminal:
sudo wget $APP/collabora.sh
sudo curl -sLO $APP/collabora.sh
sudo bash collabora.sh"
exit 1
fi
# Check if $SUBDOMAIN exists and is reachable
print_text_in_color "$ICyan" "Checking if $SUBDOMAIN exists and is reachable..."
if wget -q -T 10 -t 2 --spider "$SUBDOMAIN"; then
sleep 0.1
elif wget -q -T 10 -t 2 --spider --no-check-certificate "https://$SUBDOMAIN"; then
sleep 0.1
elif curl -s -k -m 10 "$SUBDOMAIN"; then
sleep 0.1
elif curl -s -k -m 10 "https://$SUBDOMAIN" -o /dev/null; then
if site_200 "$SUBDOMAIN"
then
sleep 0.1
else
msg_box "Nope, it's not there. You have to create $SUBDOMAIN and point

Просмотреть файл

@ -43,20 +43,15 @@ Please install Nextcloud and make sure your domain is reachable, or activate SSL
on your domain to be able to run this script.
If you use the Nextcloud VM you can use the Let's Encrypt script to get SSL and activate your Nextcloud domain.
When SSL is activated, run these commands from your terminal:
sudo wget $APP/onlyoffice.sh
sudo curl -sLO $APP/onlyoffice.sh
sudo bash onlyoffice.sh"
exit 1
fi
# Check if $SUBDOMAIN exists and is reachable
print_text_in_color "$ICyan" "Checking if $SUBDOMAIN exists and is reachable..."
if wget -q -T 10 -t 2 --spider "$SUBDOMAIN"; then
sleep 0.1
elif wget -q -T 10 -t 2 --spider --no-check-certificate "https://$SUBDOMAIN"; then
sleep 0.1
elif curl -s -k -m 10 "$SUBDOMAIN"; then
sleep 0.1
elif curl -s -k -m 10 "https://$SUBDOMAIN" -o /dev/null; then
if site_200 "$SUBDOMAIN"
then
sleep 0.1
else
msg_box "Nope, it's not there. You have to create $SUBDOMAIN and point

Просмотреть файл

@ -34,7 +34,7 @@ on your domain to be able to run this script.
If you use the Nextcloud VM you can use the Let's Encrypt script to get SSL and activate your Nextcloud domain.
When SSL is activated, run these commands from your terminal:
sudo wget $APP/talk.sh
sudo curl -sLO $APP/talk.sh
sudo bash talk.sh"
exit 1
fi
@ -125,7 +125,7 @@ msg_box "You have to open $TURN_PORT TCP/UDP in your firewall or your TURN/STUN
After you hit OK the script will check for the firewall and eventually exit on failure.
To run again the setup, after fixing your firewall:
sudo wget $APP/talk.sh
sudo -sLO $APP/talk.sh
sudo bash talk.sh"
# Check if the port is open

Просмотреть файл

@ -23,7 +23,7 @@ apt install -y zip perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-run
# Install Webmin
sed -i '$a deb http://download.webmin.com/download/repository sarge contrib' /etc/apt/sources.list
if wget -q http://www.webmin.com/jcameron-key.asc -O- | sudo apt-key add -
if curl -fsSL http://www.webmin.com/jcameron-key.asc | sudo apt-key add -
then
apt update -q4 & spinner_loading
apt install webmin -y

Просмотреть файл

@ -91,14 +91,9 @@ check_command download_le_script test-new-config
# Check if $domain exists and is reachable
echo
print_text_in_color "$ICyan" "Checking if $domain exists and is reachable..."
if wget -q -T 10 -t 2 --spider "$domain"; then
sleep 1
elif wget -q -T 10 -t 2 --spider --no-check-certificate "https://$domain"; then
sleep 1
elif curl -s -k -m 10 "$domain"; then
sleep 1
elif curl -s -k -m 10 "https://$domain" -o /dev/null ; then
sleep 1
if site_200 "$domain"
then
sleep 0.1
else
msg_box "Nope, it's not there. You have to create $domain and point
it to this server before you can run this script."

65
lib.sh
Просмотреть файл

@ -23,7 +23,6 @@ DISTRO=$(lsb_release -sd | cut -d ' ' -f 2)
IFACE2=$(ip -o link show | awk '{print $2,$9}' | grep 'UP' | cut -d ':' -f 1)
[ ! -z "$CHECK_CURRENT_REPO" ] && REPO=$(apt-get update | grep -m 1 Hit | awk '{ print $2}')
ADDRESS=$(hostname -I | cut -d ' ' -f 1)
WGET="/usr/bin/wget"
# WANIP4=$(dig +short myip.opendns.com @resolver1.opendns.com) # as an alternative
WANIP4=$(curl -s -k -m 5 https://ipv4bot.whatismyipaddress.com)
[ ! -z "$LOAD_IP6" ] && WANIP6=$(curl -s -k -m 5 https://ipv6bot.whatismyipaddress.com)
@ -197,6 +196,24 @@ do
done
}
# Checks if site is reachable with a HTTP 200 status
site_200() {
if [[ "$(curl -sfIL --retry 3 "$1" | grep Status: | awk '{print$2}')" -eq 200 ]]
then
return 0
else
return 1
fi
}
# A function to fetch a file with curl to a directory
# 1 = https://example.com
# 2 = name of file
# 3 = directory that the file should end up in
curl_to_dir() {
check_command curl -sSL "$1"/"$2" -o "$3"/"$2"
}
start_if_stopped() {
if ! pgrep "$1"
then
@ -619,13 +636,7 @@ network_ok() {
then
service networking restart > /dev/null
fi
sleep 2
if wget -q -T 20 -t 2 http://github.com -O /dev/null & spinner_loading
then
return 0
else
return 1
fi
sleep 5 && site_200 github.com
}
# Whiptail auto-size
@ -672,9 +683,9 @@ fi
download_verify_nextcloud_stable() {
rm -f "$HTML/$STABLEVERSION.tar.bz2"
wget -q -T 10 -t 2 "$NCREPO/$STABLEVERSION.tar.bz2" -P "$HTML"
curl_to_dir "$NCREPO" "$STABLEVERSION.tar.bz2" "$HTML"
mkdir -p "$GPGDIR"
wget -q "$NCREPO/$STABLEVERSION.tar.bz2.asc" -P "$GPGDIR"
curl_to_dir "$NCREPO" "$STABLEVERSION.tar.bz2.asc" "$GPGDIR"
chmod -R 600 "$GPGDIR"
gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$OpenPGP_fingerprint"
gpg --verify "$GPGDIR/$STABLEVERSION.tar.bz2.asc" "$HTML/$STABLEVERSION.tar.bz2"
@ -687,9 +698,9 @@ rm -f releases
download_static_script() {
# Get ${1} script
rm -f "${SCRIPTS}/${1}.sh" "${SCRIPTS}/${1}.php" "${SCRIPTS}/${1}.py"
if ! { wget -q "${STATIC}/${1}.sh" -P "$SCRIPTS" || wget -q "${STATIC}/${1}.php" -P "$SCRIPTS" || wget -q "${STATIC}/${1}.py" -P "$SCRIPTS"; }
if ! { curl_to_dir "${STATIC}" "${1}.sh" "$SCRIPTS" || curl_to_dir "${STATIC}" "${1}.php" "$SCRIPTS" || curl_to_dir "${STATIC}" "${1}.py" "$SCRIPTS"; }
then
print_text_in_color "$Red" "{$1} failed to download. Please run: 'sudo wget ${STATIC}/${1}.sh|.php|.py' again."
print_text_in_color "$Red" "{$1} failed to download. Please run: 'sudo curl -sLO ${STATIC}/${1}.sh|.php|.py' again."
print_text_in_color "$ICyan" "If you get this error when running the nextcloud-startup-script then just re-run it with:"
print_text_in_color "$ICyan" "'sudo bash $SCRIPTS/nextcloud-startup-script.sh' and all the scripts will be downloaded again"
exit 1
@ -701,9 +712,9 @@ download_static_script() {
download_le_script() {
# Get ${1} script
rm -f "${SCRIPTS}/${1}.sh" "${SCRIPTS}/${1}.php" "${SCRIPTS}/${1}.py"
if ! { wget -q "${LETS_ENC}/${1}.sh" -P "$SCRIPTS" || wget -q "${LETS_ENC}/${1}.php" -P "$SCRIPTS" || wget -q "${LETS_ENC}/${1}.py" -P "$SCRIPTS"; }
if ! { curl_to_dir "${LETS_ENC}" "${1}.sh" "$SCRIPTS" || curl_to_dir "${LETS_ENC}" "${1}.php" "$SCRIPTS" || curl_to_dir "${LETS_ENC}" "${1}.py" "$SCRIPTS"; }
then
print_text_in_color "$Red" "{$1} failed to download. Please run: 'sudo wget ${STATIC}/${1}.sh|.php|.py' again."
print_text_in_color "$Red" "{$1} failed to download. Please run: 'sudo curl -sLO ${STATIC}/${1}.sh|.php|.py' again."
print_text_in_color "$ICyan" "If you get this error when running the nextcloud-startup-script then just re-run it with:"
print_text_in_color "$ICyan" "'sudo bash $SCRIPTS/nextcloud-startup-script.sh' and all the scripts will be downloaded again"
exit 1
@ -714,21 +725,21 @@ download_le_script() {
# call like: run_main_script name_of_script
run_main_script() {
rm -f "${SCRIPTS}/${1}.sh" "${SCRIPTS}/${1}.php" "${SCRIPTS}/${1}.py"
if wget -q "${GITHUB_REPO}/${1}.sh" -P "$SCRIPTS"
if curl_to_dir "${GITHUB_REPO}" "${1}.sh" "$SCRIPTS"
then
bash "${SCRIPTS}/${1}.sh"
rm -f "${SCRIPTS}/${1}.sh"
elif wget -q "${GITHUB_REPO}/${1}.php" -P "$SCRIPTS"
elif curl_to_dir "${GITHUB_REPO}" "${1}.php" "$SCRIPTS"
then
php "${SCRIPTS}/${1}.php"
rm -f "${SCRIPTS}/${1}.php"
elif wget -q "${GITHUB_REPO}/${1}.py" -P "$SCRIPTS"
elif curl_to_dir "${GITHUB_REPO}" "${1}.py" "$SCRIPTS"
then
python "${SCRIPTS}/${1}.py"
rm -f "${SCRIPTS}/${1}.py"
else
print_text_in_color "$Red" "Downloading ${1} failed"
print_text_in_color "$ICyan" "Script failed to download. Please run: 'sudo wget ${GITHUB_REPO}/${1}.sh|php|py' again."
print_text_in_color "$ICyan" "Script failed to download. Please run: 'sudo curl -sLO ${GITHUB_REPO}/${1}.sh|php|py' again."
exit 1
fi
}
@ -738,21 +749,21 @@ run_main_script() {
run_static_script() {
# Get ${1} script
rm -f "${SCRIPTS}/${1}.sh" "${SCRIPTS}/${1}.php" "${SCRIPTS}/${1}.py"
if wget -q "${STATIC}/${1}.sh" -P "$SCRIPTS"
if curl_to_dir "${STATIC}" "${1}.sh" "$SCRIPTS"
then
bash "${SCRIPTS}/${1}.sh"
rm -f "${SCRIPTS}/${1}.sh"
elif wget -q "${STATIC}/${1}.php" -P "$SCRIPTS"
elif curl_to_dir "${STATIC}" "${1}.php" "$SCRIPTS"
then
php "${SCRIPTS}/${1}.php"
rm -f "${SCRIPTS}/${1}.php"
elif wget -q "${STATIC}/${1}.py" -P "$SCRIPTS"
elif curl_to_dir "${STATIC}" "${1}.py" "$SCRIPTS"
then
python "${SCRIPTS}/${1}.py"
rm -f "${SCRIPTS}/${1}.py"
else
print_text_in_color "$Red" "Downloading ${1} failed"
print_text_in_color "$ICyan" "Script failed to download. Please run: 'sudo wget ${STATIC}/${1}.sh|php|py' again."
print_text_in_color "$ICyan" "Script failed to download. Please run: 'sudo curl -sLO ${STATIC}/${1}.sh|php|py' again."
exit 1
fi
}
@ -761,21 +772,21 @@ run_static_script() {
# call like: run_app_script collabora|nextant|passman|spreedme|contacts|calendar|webmin|previewgenerator
run_app_script() {
rm -f "${SCRIPTS}/${1}.sh" "${SCRIPTS}/${1}.php" "${SCRIPTS}/${1}.py"
if wget -q "${APP}/${1}.sh" -P "$SCRIPTS"
if curl_to_dir "${APP}" "${1}.sh" "$SCRIPTS"
then
bash "${SCRIPTS}/${1}.sh"
rm -f "${SCRIPTS}/${1}.sh"
elif wget -q "${APP}/${1}.php" -P "$SCRIPTS"
elif curl_to_dir "${APP}" "${1}.php" "$SCRIPTS"
then
php "${SCRIPTS}/${1}.php"
rm -f "${SCRIPTS}/${1}.php"
elif wget -q "${APP}/${1}.py" -P "$SCRIPTS"
elif curl_to_dir "${APP}" "${1}.py" "$SCRIPTS"
then
python "${SCRIPTS}/${1}.py"
rm -f "${SCRIPTS}/${1}.py"
else
print_text_in_color "$Red" "Downloading ${1} failed"
print_text_in_color "$ICyan" "Script failed to download. Please run: 'sudo wget ${APP}/${1}.sh|php|py' again."
print_text_in_color "$ICyan" "Script failed to download. Please run: 'sudo curl -sLO ${APP}/${1}.sh|php|py' again."
exit
fi
}
@ -832,7 +843,7 @@ or experience other issues then please report this to $ISSUES"
# Download the latest updater
# cd $NCPATH
# wget -q https://github.com/nextcloud/updater/archive/master.zip
# curl sLO https://github.com/nextcloud/updater/archive/master.zip
# install_if_not unzip
# unzip -q master.zip
# rm master.zip*

Просмотреть файл

@ -45,10 +45,9 @@ More information can be found here: https://unix.stackexchange.com/a/3064"
fi
}
network_ok() {
print_text_in_color "$ICyan" "Testing if network is OK..."
service network-manager restart
if wget -q -T 20 -t 2 http://github.com -O /dev/null
# Checks if site is reachable with a HTTP 200 status
site_200() {
if [[ "$(curl -sfIL --retry 3 "$1" | grep Status: | awk '{print$2}')" -eq 200 ]]
then
return 0
else
@ -56,6 +55,16 @@ network_ok() {
fi
}
network_ok() {
print_text_in_color "$ICyan" "Testing if network is OK..."
install_if_not network-manager
if ! service network-manager restart > /dev/null
then
service networking restart > /dev/null
fi
sleep 5 && site_200 github.com
}
check_command() {
if ! "$@";
then
@ -116,7 +125,7 @@ You will now be provided with the option to set a static IP manually instead."
# Copy old interfaces files
msg_box "Copying old netplan.io config files file to:
/tmp/netplan_io_backup/"
if [ -d /etc/netplan/ ]
if [ -d /etc/netplan/ ]
then
mkdir -p /tmp/netplan_io_backup
check_command cp -vR /etc/netplan/* /tmp/netplan_io_backup/

Просмотреть файл

@ -76,7 +76,7 @@ check_universe
check_multiverse
# Check if key is available
if ! wget -q -T 10 -t 2 "$NCREPO" > /dev/null
if ! site_200 "$NCREPO"
then
msg_box "Nextcloud repo is not available, exiting..."
exit 1
@ -157,7 +157,7 @@ fi
# Install PostgreSQL
# sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main"
# wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
# curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
apt update -q4 & spinner_loading
apt install postgresql-10 -y
@ -521,7 +521,7 @@ rm -f results
# Get needed scripts for first bootup
if [ ! -f "$SCRIPTS"/nextcloud-startup-script.sh ]
then
check_command wget -q "$GITHUB_REPO"/nextcloud-startup-script.sh -P "$SCRIPTS"
curl_to_dir "$GITHUB_REPO" nextcloud-startup-script.sh "$SCRIPTS"
fi
download_static_script instruction
download_static_script history

Просмотреть файл

@ -126,7 +126,7 @@ if [ -d $ADMINERDIR ]
then
print_text_in_color "$ICyan" "Updating Adminer..."
rm -f "$ADMINERDIR"/latest.php "$ADMINERDIR"/adminer.php
wget -q "http://www.adminer.org/latest.php" -O "$ADMINERDIR"/latest.php
curl_to_dir "http://www.adminer.org" "latest.php" "$ADMINERDIR"
ln -s "$ADMINERDIR"/latest.php "$ADMINERDIR"/adminer.php
fi
@ -227,7 +227,7 @@ fi
# Upgrade Nextcloud
print_text_in_color "$ICyan" "Checking latest released version on the Nextcloud download server and if it's possible to download..."
if ! wget -q --show-progress -T 10 -t 2 "$NCREPO/$STABLEVERSION.tar.bz2"
if ! curl -fSLO --retry 3 "$NCREPO/$STABLEVERSION.tar.bz2"
then
msg_box "Nextcloud does not exist. You were looking for: $NCVERSION
Please check available versions here: $NCREPO"

Просмотреть файл

@ -13,7 +13,7 @@ true
DEBUG=0
debug_mode
if wget -q -T 10 -t 2 http://google.com > /dev/null
if site_200 google.com
then
ntpdate -s 1.se.pool.ntp.org
fi

Просмотреть файл

@ -69,7 +69,7 @@ eDROP_ARCHIVE_FILE="/usr/local/src/eDROP_{$EXEC_DATE}"
echo "Start time: $(date)"
echo " "
echo "Download daily DROP file:"
wget -q -O - "$URL" > $SPAMHAUS_DROP
curl -fsSL "$URL" > $SPAMHAUS_DROP
grep -v '^;' $SPAMHAUS_DROP | cut -d ' ' -f 1 > $DROP_ADD_TO_UFW
echo " "
echo "Extract DROP IP addresses and add to UFW:"
@ -81,7 +81,7 @@ echo " "
echo "Downloading eDROP list and import to UFW"
echo " "
echo "Download daily eDROP file:"
wget -q -O - "$eURL" > $SPAMHAUS_eDROP
curl -fsSL "$eURL" > $SPAMHAUS_eDROP
grep -v '^;' $SPAMHAUS_eDROP | cut -d ' ' -f 1 > $eDROP_ADD_TO_UFW
echo " "
echo "Extract eDROP IP addresses and add to UFW:"

Просмотреть файл

@ -12,10 +12,24 @@ true
DEBUG=0
debug_mode
$WGET -q --tries=20 --timeout=10 http://www.github.com -O /tmp/github.idx &> /dev/null
if [ ! -s /tmp/github.idx ]
curl_to_dir() {
check_command curl -sSL "$1"/"$2" -o "$3"/"$2"
}
# Colors
Color_Off='\e[0m'
IRed='\e[0;91m'
IGreen='\e[0;92m'
ICyan='\e[0;96m'
print_text_in_color() {
printf "%b%s%b\n" "$1" "$2" "$Color_Off"
}
curl_to_dir google.com google.connectiontest /tmp
if [ ! -s /tmp/google.connectiontest ]
then
printf "${Red}Not Connected!${Color_Off}\n"
print_text_in_color "$IRed" "Not connected!"
else
printf "Connected!\n"
print_text_in_color "$IGreen" "Connected!"
fi