mirror of
https://github.com/YunoHost/install_script.git
synced 2024-09-03 20:06:25 +02:00
Have a function to check install script assertions before anything else
This commit is contained in:
parent
0c89145d31
commit
b0f680e271
1 changed files with 34 additions and 22 deletions
|
@ -79,11 +79,7 @@ function main()
|
|||
{
|
||||
parse_options
|
||||
|
||||
step ensure_root || die "This script must be run as root"
|
||||
|
||||
if is_raspbian ; then
|
||||
step ensure_pi_logout || die "The user pi should be logged out"
|
||||
fi
|
||||
check_assertions
|
||||
|
||||
step upgrade_system || die "Unable to update the system"
|
||||
step installscript_dependencies || die "Unable to install dependencies to install script"
|
||||
|
@ -178,7 +174,7 @@ function ensure_root() {
|
|||
return 0
|
||||
}
|
||||
|
||||
function ensure_pi_logout() {
|
||||
function user_pi_logged_out() {
|
||||
who | grep pi > /dev/null && return 1
|
||||
return 0
|
||||
}
|
||||
|
@ -196,6 +192,31 @@ function is_raspbian() {
|
|||
# Installation steps #
|
||||
###############################################################################
|
||||
|
||||
function check_assertions()
|
||||
{
|
||||
# Assert we're on Debian
|
||||
# Note : we do not rely on lsb_release to avoid installing a dependency
|
||||
# only to check this...
|
||||
[[ -f "/etc/debian_version" ]] || die "This script can only be ran on Debian."
|
||||
|
||||
# Assert we're on Stretch
|
||||
# Note : we do not rely on lsb_release to avoid installing a dependency
|
||||
# only to check this...
|
||||
[[ ! "$(cat /etc/debian_version)" =~ ^9.* ]] || die "This script can only be ran on Debian Stretch."
|
||||
|
||||
# Assert we're root
|
||||
[[ "$(id -u)" != "0" ]] || die "This script must be run as root."
|
||||
|
||||
# Assert systemd is installed
|
||||
command -v systemctl > /dev/null || die "YunoHost requires systemd to be installed."
|
||||
|
||||
# If we're on Raspbian, we want the user 'pi' to be logged out because
|
||||
# it's going to be deleted for security reasons...
|
||||
if is_raspbian ; then
|
||||
user_pi_logged_out || die "The user pi should be logged out."
|
||||
fi
|
||||
}
|
||||
|
||||
function apt_get_wrapper() {
|
||||
if [[ "$AUTOMODE" == "0" ]] ;
|
||||
then
|
||||
|
@ -270,18 +291,9 @@ Are you sure you want to proceed with the installation of Yunohost?
|
|||
}
|
||||
|
||||
function setup_package_source() {
|
||||
|
||||
local CUSTOMAPT=/etc/apt/sources.list.d/yunohost.list
|
||||
|
||||
# Check current system version and dependencies
|
||||
|
||||
if [[ ! $THIS_MACHINE_RELEASE =~ ^jessie|stretch$ ]]; then
|
||||
echo "Current $DISTRIB only works on Debian Jessie or Stretch for the moment."
|
||||
return 1
|
||||
elif ! command -v systemctl > /dev/null ; then
|
||||
echo "Current $DISTRIB only works with systemd for the moment."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Debian repository
|
||||
|
||||
# FIXME : move "vinaigrette." to "repo." at some point...
|
||||
|
|
Loading…
Add table
Reference in a new issue