Skip to content
system-upgrade 1.16 KiB
Newer Older
Seblu's avatar
Seblu committed
#!/bin/bash

# Copyright © Sébastien Luttringer
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

# Smart way to update your archlinux system

# We need to be root
if (( $UID != 0 )); then
	if type -P sudo >/dev/null; then
		exec sudo -- "$0" "$@"
Seblu's avatar
Seblu committed
	elif type -P su >/dev/null; then
		exec su -l -c "$0" "$@"
Seblu's avatar
Seblu committed
	fi
	printf '\e[7;31;40mYou need to be root\e[m\n'
Seblu's avatar
Seblu committed
	exit 1
fi

if pacman --sync --refresh --sysupgrade "$@"; then
	checkservices
else
	printf '\e[7;33;40mcheckservices not run because pacman did not exit zero\e[m\n'
fi