Simplify exception handling for steps

This commit is contained in:
Alexandre Aubin 2018-02-12 23:29:58 +01:00
parent d3055fbf03
commit 370a12e544

View file

@ -456,78 +456,31 @@ while getopts ":aid:h" option; do
esac esac
done done
if ! step ensure_root ; then step ensure_root || die "This script must be run as root"
die "This script must be run as root" 1
fi
if is_raspbian ; then if is_raspbian ; then
if ! step ensure_pi_logout ; then step ensure_pi_logout || die "The user pi should be logged out"
die "The user pi should be logged out" 14
fi
fi fi
if ! step upgrade_system ; then step upgrade_system || die "Unable to update the system"
die "Unable to update the system" 2 step installscript_dependencies || die "Unable to install dependencies to install script"
fi step create_custom_config || die "Creating custom configuration file /etc/yunohost/yunohost.conf failed"
step confirm_installation || die "Installation cancelled at your request"
if ! step installscript_dependencies ; then step setup_package_source || die "Setting up deb package sources failed"
die "Unable to install dependencies to install script" 3 step apt_update || die "Error caught during 'apt-get update'"
fi step register_debconf || die "Unable to insert new values into debconf database"
step workaround_avahi_installation || die "Unable to install workaround for avahi installation"
if ! step create_custom_config ; then step install_yunohost_packages || die "Installation of Yunohost packages failed"
die "Creating custom configuration file /etc/yunohost/yunohost.conf failed" 4 step restart_services || die "Error caught during services restart"
fi
# if ! step set_domain ; then
# die "Setting hostname failed" 5
# fi
if ! step confirm_installation ; then
die "Installation cancelled at your request" 6
fi
if ! step setup_package_source ; then
die "Setting up deb package sources failed" 7
fi
if ! step apt_update ; then
die "Error caught during 'apt-get update'" 8
fi
if ! step register_debconf ; then
die "Unable to insert new values into debconf database" 9
fi
if ! step workaround_avahi_installation ; then
die "Unable to install workaround for avahi installation" 10
fi
if ! step install_yunohost_packages ; then
die "Installation of Yunohost packages failed" 11
fi
if ! step restart_services ; then
die "Error caught during services restart" 12
fi
if is_raspbian ; then if is_raspbian ; then
if ! step del_user_pi ; then step del_user_pi || die "Unable to delete user pi"
die "Unable to delete user pi" 15 step change_hostname || die "Unable to change hostname"
fi step setup_firstboot || die "Unable to setup firstboot"
if ! step change_hostname ; then
die "Unable to change hostname" 16
fi
if ! step setup_firstboot ; then
die "Unable to setup firstboot" 17
fi
fi fi
if [[ "$BUILD_IMAGE" == "1" ]] ; then if [[ "$BUILD_IMAGE" == "1" ]] ; then
if ! step clean_image ; then step clean_image || die "Unable to clean image"
die "Unable to clean image" 18
fi
fi fi
if is_raspbian ; then if is_raspbian ; then
@ -535,10 +488,7 @@ if is_raspbian ; then
reboot reboot
fi fi
if ! step post_install ; then step post_install || die "Post-installation failed"
die "Post-installation failed" 13
fi
# Success ! # Success !
success success