mirror of
https://github.com/YunoHost/install_script.git
synced 2024-09-03 20:06:25 +02:00
Give time for Internet connection ; ensure curl is installed
This commit is contained in:
parent
76b412610c
commit
ec9029daf3
2 changed files with 48 additions and 0 deletions
24
bookworm
24
bookworm
|
@ -15,6 +15,8 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# RUN INSTALL SCRIPT WITH -a FOR NON-INTERACTIVE MODE.
|
||||||
|
|
||||||
set -u
|
set -u
|
||||||
|
|
||||||
# Globals
|
# Globals
|
||||||
|
@ -26,6 +28,18 @@ export DEBIAN_FRONTEND=noninteractive
|
||||||
# Main functions #
|
# Main functions #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
function check_connection() {
|
||||||
|
TIMEOUT=$1
|
||||||
|
|
||||||
|
while [ $TIMEOUT -gt 0 ]; do
|
||||||
|
ping -c 1 -W 2 yunohost.org 2>&1 >/dev/null && return 0
|
||||||
|
sleep 1
|
||||||
|
TIMEOUT=$((TIMEOUT-1))
|
||||||
|
done
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
function usage() {
|
function usage() {
|
||||||
cat << EOF
|
cat << EOF
|
||||||
Usage :
|
Usage :
|
||||||
|
@ -252,6 +266,16 @@ function check_assertions()
|
||||||
# Assert we're root
|
# Assert we're root
|
||||||
[[ "$(id -u)" == "0" ]] || { error "This script must be run as root. On most setups, the command 'sudo -i' can be run first to become root."; return 1; }
|
[[ "$(id -u)" == "0" ]] || { error "This script must be run as root. On most setups, the command 'sudo -i' can be run first to become root."; return 1; }
|
||||||
|
|
||||||
|
# Assert Internet is reachable
|
||||||
|
if ! check_connection 30; then
|
||||||
|
die "You need internet to use this script! yunohost.org did not respond to ping after more than 30s."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Assert curl is setup
|
||||||
|
if ! command -v curl 2>&1 >/dev/null; then
|
||||||
|
apt_get_wrapper --yes install curl
|
||||||
|
fi
|
||||||
|
|
||||||
# Check PATH var
|
# Check PATH var
|
||||||
[[ "$PATH" == *"/sbin"* ]] || { error "Your environment PATH variable must contains /sbin directory. Maybe try running 'PATH=/sbin:\$PATH' to fix this."; return 1; }
|
[[ "$PATH" == *"/sbin"* ]] || { error "Your environment PATH variable must contains /sbin directory. Maybe try running 'PATH=/sbin:\$PATH' to fix this."; return 1; }
|
||||||
|
|
||||||
|
|
24
bullseye
24
bullseye
|
@ -15,6 +15,8 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# RUN INSTALL SCRIPT WITH -a FOR NON-INTERACTIVE MODE.
|
||||||
|
|
||||||
set -u
|
set -u
|
||||||
|
|
||||||
# Globals
|
# Globals
|
||||||
|
@ -37,6 +39,18 @@ compactbutton=white,black
|
||||||
# Main functions #
|
# Main functions #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
function check_connection() {
|
||||||
|
TIMEOUT=$1
|
||||||
|
|
||||||
|
while [ $TIMEOUT -gt 0 ]; do
|
||||||
|
ping -c 1 -W 2 yunohost.org 2>&1 >/dev/null && return 0
|
||||||
|
sleep 1
|
||||||
|
TIMEOUT=$((TIMEOUT-1))
|
||||||
|
done
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
function usage() {
|
function usage() {
|
||||||
echo "
|
echo "
|
||||||
Usage :
|
Usage :
|
||||||
|
@ -237,6 +251,16 @@ function check_assertions()
|
||||||
# Assert we're root
|
# Assert we're root
|
||||||
[[ "$(id -u)" == "0" ]] || die "This script must be run as root. On most setups, the command 'sudo -i' can be run first to become root."
|
[[ "$(id -u)" == "0" ]] || die "This script must be run as root. On most setups, the command 'sudo -i' can be run first to become root."
|
||||||
|
|
||||||
|
# Assert Internet is reachable
|
||||||
|
if ! check_connection 30; then
|
||||||
|
die "You need internet to use this script! yunohost.org did not respond to ping after more than 30s."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Assert curl is setup
|
||||||
|
if ! command -v curl 2>&1 >/dev/null; then
|
||||||
|
apt_get_wrapper --yes install curl
|
||||||
|
fi
|
||||||
|
|
||||||
# Check PATH var
|
# Check PATH var
|
||||||
[[ "$PATH" == *"/sbin"* ]] || die "Your environment PATH variable must contains /sbin directory. Maybe try running 'PATH=/sbin:\$PATH' to fix this."
|
[[ "$PATH" == *"/sbin"* ]] || die "Your environment PATH variable must contains /sbin directory. Maybe try running 'PATH=/sbin:\$PATH' to fix this."
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue