guix-install.sh: Add ‘--uninstall’ flag.
* etc/guix-install.sh (REQUIRE): Add groupdel and userdel. (chk_term): Handle ‘WAR’. (sys_delete_store, sys_delete_build_user, sys_delete_guix_daemon) (sys_delete_init_profile, sys_delete_user_profiles): New functions. (main): Rename to… (main_install): … this. (main_uninstall): New function. (main): Dispatch between these two. * doc/guix.texi (Installation): Refer to “Binary Installation” instead of repeating it. (Binary Installation): Document uninstallation. Co-authored-by: Ludovic Courtès <ludo@gnu.org> Change-Id: I55b7c10823773bced2e268273e8ce828cb3bd98dmaster
parent
74517806f8
commit
dd476cfb76
|
@ -696,12 +696,11 @@ to join! @xref{Contributing}, for information about how you can help.
|
||||||
We recommend the use of this
|
We recommend the use of this
|
||||||
@uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
|
@uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
|
||||||
shell installer script} to install Guix on top of a running GNU/Linux system,
|
shell installer script} to install Guix on top of a running GNU/Linux system,
|
||||||
thereafter called a @dfn{foreign distro}.@footnote{This section is concerned
|
thereafter called a @dfn{foreign distro}@footnote{This section is concerned
|
||||||
with the installation of the package manager, which can be done on top of a
|
with the installation of the package manager, which can be done on top of a
|
||||||
running GNU/Linux system. If, instead, you want to install the complete GNU
|
running GNU/Linux system. If, instead, you want to install the complete GNU
|
||||||
operating system, @pxref{System Installation}.} The script automates the
|
operating system, @pxref{System Installation}.}. @xref{Binary
|
||||||
download, installation, and initial configuration of Guix. It should be run
|
Installation}, for more information.
|
||||||
as the root user.
|
|
||||||
@end quotation
|
@end quotation
|
||||||
|
|
||||||
@cindex foreign distro
|
@cindex foreign distro
|
||||||
|
@ -758,6 +757,22 @@ chmod +x guix-install.sh
|
||||||
./guix-install.sh
|
./guix-install.sh
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
|
The script automates the download, installation, and initial
|
||||||
|
configuration of Guix, interactively offering various configuration
|
||||||
|
options.
|
||||||
|
|
||||||
|
@cindex uninstalling Guix
|
||||||
|
@cindex uninstallation, of Guix
|
||||||
|
Should you eventually want to uninstall Guix, run the same script with
|
||||||
|
the @option{--uninstall} flag:
|
||||||
|
|
||||||
|
@example
|
||||||
|
./guix-install.sh --uninstall
|
||||||
|
@end example
|
||||||
|
|
||||||
|
With @option{--uninstall}, the script irreversibly deletes all the Guix
|
||||||
|
files, configuration, and services.
|
||||||
|
|
||||||
If you're running Debian or a derivative such as Ubuntu, you can instead
|
If you're running Debian or a derivative such as Ubuntu, you can instead
|
||||||
install the package (it might be a version older than @value{VERSION}
|
install the package (it might be a version older than @value{VERSION}
|
||||||
but you can update it afterwards by running @samp{guix pull}):
|
but you can update it afterwards by running @samp{guix pull}):
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
# Copyright © 2021, 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
|
# Copyright © 2021, 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
|
||||||
# Copyright © 2022 Prafulla Giri <prafulla.giri@protonmail.com>
|
# Copyright © 2022 Prafulla Giri <prafulla.giri@protonmail.com>
|
||||||
# Copyright © 2023 Andrew Tropin <andrew@trop.in>
|
# Copyright © 2023 Andrew Tropin <andrew@trop.in>
|
||||||
|
# Copyright © 2020 David A. Redick <david.a.redick@gmail.com>
|
||||||
#
|
#
|
||||||
# This file is part of GNU Guix.
|
# This file is part of GNU Guix.
|
||||||
#
|
#
|
||||||
|
@ -70,7 +71,9 @@ REQUIRE=(
|
||||||
"chmod"
|
"chmod"
|
||||||
"uname"
|
"uname"
|
||||||
"groupadd"
|
"groupadd"
|
||||||
|
"groupdel"
|
||||||
"useradd"
|
"useradd"
|
||||||
|
"userdel"
|
||||||
"tail"
|
"tail"
|
||||||
"tr"
|
"tr"
|
||||||
"xz"
|
"xz"
|
||||||
|
@ -191,6 +194,7 @@ chk_term()
|
||||||
*)
|
*)
|
||||||
ERR="[ FAIL ] "
|
ERR="[ FAIL ] "
|
||||||
PAS="[ PASS ] "
|
PAS="[ PASS ] "
|
||||||
|
WAR="[ WARN ] "
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
@ -377,6 +381,18 @@ sys_create_store()
|
||||||
_msg "${PAS}activated root profile at ${GUIX_PROFILE}"
|
_msg "${PAS}activated root profile at ${GUIX_PROFILE}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sys_delete_store()
|
||||||
|
{
|
||||||
|
_msg "${INF}removing /var/guix"
|
||||||
|
rm -rf /var/guix
|
||||||
|
|
||||||
|
_msg "${INF}removing /gnu"
|
||||||
|
rm -rf /gnu
|
||||||
|
|
||||||
|
_msg "${INF}removing ${ROOT_HOME}/.config/guix"
|
||||||
|
rm -rf ${ROOT_HOME}/.config/guix
|
||||||
|
}
|
||||||
|
|
||||||
sys_create_build_user()
|
sys_create_build_user()
|
||||||
{ # Create the group and user accounts for build users.
|
{ # Create the group and user accounts for build users.
|
||||||
|
|
||||||
|
@ -411,6 +427,16 @@ sys_create_build_user()
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sys_delete_build_user()
|
||||||
|
{
|
||||||
|
for i in $(seq -w 1 10); do
|
||||||
|
userdel -f guixbuilder${i}
|
||||||
|
done
|
||||||
|
|
||||||
|
_msg "${INF}delete group guixbuild"
|
||||||
|
groupdel -f guixbuild
|
||||||
|
}
|
||||||
|
|
||||||
sys_enable_guix_daemon()
|
sys_enable_guix_daemon()
|
||||||
{ # Run the daemon, and set it to automatically start on boot.
|
{ # Run the daemon, and set it to automatically start on boot.
|
||||||
|
|
||||||
|
@ -500,6 +526,65 @@ sys_enable_guix_daemon()
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sys_delete_guix_daemon()
|
||||||
|
{ # Disabled, stop and remove the various guix daemons.
|
||||||
|
|
||||||
|
local info_path
|
||||||
|
local local_bin
|
||||||
|
local var_guix
|
||||||
|
|
||||||
|
_debug "--- [ $FUNCNAME ] ---"
|
||||||
|
|
||||||
|
info_path="/usr/local/share/info"
|
||||||
|
local_bin="/usr/local/bin"
|
||||||
|
|
||||||
|
|
||||||
|
case "$INIT_SYS" in
|
||||||
|
upstart)
|
||||||
|
_msg "${INF}stopping guix-daemon"
|
||||||
|
stop guix-daemon
|
||||||
|
_msg "${INF}removing guix-daemon"
|
||||||
|
rm /etc/init/guix-daemon.conf
|
||||||
|
;;
|
||||||
|
|
||||||
|
systemd)
|
||||||
|
_msg "${INF}disabling guix-daemon"
|
||||||
|
systemctl disable guix-daemon
|
||||||
|
_msg "${INF}stopping guix-daemon"
|
||||||
|
systemctl stop guix-daemon
|
||||||
|
_msg "${INF}removing guix-daemon"
|
||||||
|
rm -f /etc/systemd/system/guix-daemon.service
|
||||||
|
|
||||||
|
if [ -x /etc/systemd/system/gnu-store.mount ]; then
|
||||||
|
_msg "${INF}disabling gnu-store.mount"
|
||||||
|
systemctl disable gnu-store.mount
|
||||||
|
_msg "${INF}stopping gnu-store.mount"
|
||||||
|
systemctl stop gnu-store.mount
|
||||||
|
_msg "${INF}removing gnu-store.mount"
|
||||||
|
rm -f /etc/systemd/system/gnu-store.mount
|
||||||
|
fi
|
||||||
|
systemctl daemon-reload
|
||||||
|
;;
|
||||||
|
|
||||||
|
sysv-init)
|
||||||
|
update-rc.d guix-daemon disable
|
||||||
|
service guix-daemon stop
|
||||||
|
rm -rf /etc/init.d/guix-daemon
|
||||||
|
;;
|
||||||
|
NA|*)
|
||||||
|
_msg "${ERR}unsupported init system; disable, stop and remove the daemon manually:"
|
||||||
|
echo " ${ROOT_HOME}/.config/guix/current/bin/guix-daemon --build-users-group=guixbuild"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
_msg "${INF}removing $local_bin/guix"
|
||||||
|
rm -f "$local_bin"/guix
|
||||||
|
|
||||||
|
_msg "${INF}removing $info_path/guix*"
|
||||||
|
rm -f "$info_path"/guix*
|
||||||
|
}
|
||||||
|
|
||||||
sys_authorize_build_farms()
|
sys_authorize_build_farms()
|
||||||
{ # authorize the public key(s) of the build farm(s)
|
{ # authorize the public key(s) of the build farm(s)
|
||||||
local hosts=(
|
local hosts=(
|
||||||
|
@ -623,8 +708,29 @@ sys_maybe_setup_selinux()
|
||||||
restorecon -R /gnu /var/guix
|
restorecon -R /gnu /var/guix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sys_delete_init_profile()
|
||||||
|
{
|
||||||
|
_msg "${INF}removing /etc/profile.d/guix.sh"
|
||||||
|
rm -f /etc/profile.d/guix.sh
|
||||||
|
}
|
||||||
|
|
||||||
|
sys_delete_user_profiles()
|
||||||
|
{
|
||||||
|
_msg "${INF}removing ${ROOT_HOME}/.guix-profile"
|
||||||
|
rm -f ${ROOT_HOME}/.guix-profile
|
||||||
|
rm -rf ${ROOT_HOME}/.cache/guix
|
||||||
|
|
||||||
|
_msg "${INF}removing .guix-profile, .cache/guix and .config/guix of all /home users"
|
||||||
|
for user in `ls -1 /home`; do
|
||||||
|
rm -f /home/$user/.guix-profile
|
||||||
|
rm -rf /home/$user/.cache/guix
|
||||||
|
rm -rf /home/$user/.config/guix
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
welcome()
|
welcome()
|
||||||
{
|
{
|
||||||
|
local uninstall_flag="$1"
|
||||||
local char
|
local char
|
||||||
cat<<"EOF"
|
cat<<"EOF"
|
||||||
░░░ ░░░
|
░░░ ░░░
|
||||||
|
@ -647,10 +753,17 @@ welcome()
|
||||||
| |__| | |\ | |__| | | |__| | |_| | |> <
|
| |__| | |\ | |__| | | |__| | |_| | |> <
|
||||||
\_____|_| \_|\____/ \_____|\__,_|_/_/\_\
|
\_____|_| \_|\____/ \_____|\__,_|_/_/\_\
|
||||||
|
|
||||||
This script installs GNU Guix on your system
|
|
||||||
|
|
||||||
https://www.gnu.org/software/guix/
|
https://www.gnu.org/software/guix/
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
if [ '--uninstall' = "$uninstall_flag" ]; then
|
||||||
|
echo "${WARN}This script will uninstall GNU Guix from your system"
|
||||||
|
echo "To install, run this script with no parameters."
|
||||||
|
else
|
||||||
|
echo "This script installs GNU Guix on your system"
|
||||||
|
echo "To uninstall, pass in the '--uninstall' parameter."
|
||||||
|
fi
|
||||||
|
|
||||||
# Don't use ‘read -p’ here! It won't display when run non-interactively.
|
# Don't use ‘read -p’ here! It won't display when run non-interactively.
|
||||||
echo -n "Press return to continue..."$'\r'
|
echo -n "Press return to continue..."$'\r'
|
||||||
if ! read -r char; then
|
if ! read -r char; then
|
||||||
|
@ -665,7 +778,7 @@ EOF
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main_install()
|
||||||
{
|
{
|
||||||
local tmp_path
|
local tmp_path
|
||||||
welcome
|
welcome
|
||||||
|
@ -715,4 +828,53 @@ main()
|
||||||
_msg "${INF}Please log out and back in to complete the installation."
|
_msg "${INF}Please log out and back in to complete the installation."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main_uninstall()
|
||||||
|
{
|
||||||
|
welcome --uninstall
|
||||||
|
_msg "Starting uninstall process ($(date))"
|
||||||
|
|
||||||
|
chk_term
|
||||||
|
chk_require "${REQUIRE[@]}"
|
||||||
|
# it's ok to leave the gpg key
|
||||||
|
chk_init_sys
|
||||||
|
chk_sys_arch
|
||||||
|
|
||||||
|
_msg "${INF}system is ${ARCH_OS}"
|
||||||
|
|
||||||
|
# stop the build, package system.
|
||||||
|
sys_delete_guix_daemon
|
||||||
|
# stop people from accessing their profiles.
|
||||||
|
sys_delete_user_profiles
|
||||||
|
# kill guix off all the guts of guix
|
||||||
|
sys_delete_store
|
||||||
|
# clean up the system
|
||||||
|
sys_delete_init_profile
|
||||||
|
sys_delete_build_user
|
||||||
|
|
||||||
|
# these directories are created on the fly during usage.
|
||||||
|
_msg "${INF}removing /etc/guix"
|
||||||
|
rm -rf /etc/guix
|
||||||
|
_msg "${INF}removing /var/log/guix"
|
||||||
|
rm -rf /var/log/guix
|
||||||
|
|
||||||
|
_msg "${PAS}Guix has successfully been uninstalled!"
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
# expect no parameters
|
||||||
|
# or '--uninstall'
|
||||||
|
if [ 0 -eq $# ]; then
|
||||||
|
main_install
|
||||||
|
else
|
||||||
|
local uninstall_flag="$1"
|
||||||
|
if [ '--uninstall' = "${uninstall_flag}" ]; then
|
||||||
|
main_uninstall
|
||||||
|
else
|
||||||
|
echo "unsupported parameters: $@"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|
Reference in New Issue