Initial commit. In a broken state, do not use.
This commit is contained in:
245
files/scripts/ar-SA/update-f123light
Normal file
245
files/scripts/ar-SA/update-f123light
Normal file
@ -0,0 +1,245 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2018, F123 Consulting, <information@f123.org>
|
||||
# Copyright 2018, Kyle, <kyle@free2.ml>
|
||||
# Copyright 2018, Storm Dragon, <storm_dragon@linux-a11y.org>
|
||||
#
|
||||
# This 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 3, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# This software 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 package; see the file COPYING. If not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
#
|
||||
#--code--
|
||||
|
||||
# the gettext essentials
|
||||
export TEXTDOMAIN=update-f123light
|
||||
export TEXTDOMAINDIR=/usr/share/locale
|
||||
|
||||
. gettext.sh
|
||||
|
||||
# Import the standard F123Light functions
|
||||
. /usr/lib/F123-includes/script_functions.sh
|
||||
|
||||
cleanup() {
|
||||
# The temporary files downloaded from the F123Light git repositories are no longer needed.
|
||||
# Kill the clones.
|
||||
sudo -v && sudo rm -Rf /tmp/files-F123Light /tmp/content-F123Light
|
||||
}
|
||||
|
||||
# Log writing function
|
||||
log() {
|
||||
while read -r line ; do
|
||||
echo "$line" | sudo tee -a "$logFile" &> /dev/null
|
||||
done
|
||||
}
|
||||
|
||||
# Incremental update timestamp function
|
||||
# Determine whether to perform the update that calls this function.
|
||||
# Return false if the time in yymmddhhmm format is not later than /etc/build-timestamp
|
||||
# Otherwise write the new timestamp and return 0 so that the update is performed.
|
||||
# on the calling system.
|
||||
update () {
|
||||
local updateTime="$1"
|
||||
local lastUpdated="$(cat /etc/timestamp-f123light | tr -cd '[:digit:]' 2> /dev/null)"
|
||||
lastUpdated=${lastUpdated:-0}
|
||||
if [[ $updateTime -gt $lastUpdated ]]; then
|
||||
echo -n "$updateTime" | sudo tee /etc/timestamp-f123light &> /dev/null
|
||||
echo "Performed incremental update $updateTime" | log
|
||||
else
|
||||
return 100
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
reboot_prompt () {
|
||||
# Prompt the user to reboot just in case something like the kernel that deserves a reboot has been updated.
|
||||
# We will prompt for a keypress. Enter to reboot, escape to exit the script and return to the shell or calling script.
|
||||
local $key
|
||||
clear
|
||||
key=$(yesno "$(gettext "Your system has been updated. We recommend that you restart your computer. Please press 'Enter' to restart or 'Escape' to finish the update without restarting.")")
|
||||
case $key in
|
||||
"Yes")
|
||||
sudo systemctl reboot
|
||||
;;
|
||||
"No")
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Default files-F123Light git branch to be cloned
|
||||
branch=master
|
||||
|
||||
# test to determine whether to prompt for a reboot, initially false
|
||||
reboot=false
|
||||
|
||||
# Get command line options
|
||||
if ! options=$(getopt -o b:h -l branch:,help, -n "update-f123light" -- "$@"); then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
eval set -- "$options"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-b|--branch)
|
||||
branch="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
cat <<-HELP
|
||||
$(gettext "Usage")
|
||||
$(eval_gettext "\$name [options...]")
|
||||
$(gettext "Options")
|
||||
-h, --help: $(gettext "Print this help message and exit")
|
||||
-b <branch>, --branch=<branch>: $(eval_gettext "Get files from the specified git branch, default: \$branch")
|
||||
HELP
|
||||
exit 0
|
||||
;;
|
||||
(--)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo $(basename $0): $1 $(gettext "not recognized") 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
clear
|
||||
set -Eo pipefail
|
||||
trap cleanup EXIT
|
||||
# Log file name
|
||||
logFile="/var/log/${0##*/}"
|
||||
|
||||
# Check if the current user uas sudo privileges.
|
||||
if sudo -v ; then
|
||||
# Initialize logFile.
|
||||
echo "Log for update-f123light. Starting at version $(</etc/timestamp-f123light)" | sudo tee "$logFile" &> /dev/null
|
||||
else
|
||||
infobox "$USER $(gettext "Does not currently have administrator access to this system. Please upgrade with a user that has adminstrator access.")";
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# See if we can update the system.
|
||||
if [[ -f "/var/lib/pacman/db.lck" ]]; then
|
||||
echo "Found /var/lib/pacman/db.lck" | log
|
||||
if [[ "$(yesno "$(gettext "Your system needs to restart before updates can begin. Would you like to do this now?")")" == "Yes" ]]; then
|
||||
sudo rm -f "/var/lib/pacman/db.lck"
|
||||
echo "Removed /var/lib/pacman/db.lck" | log
|
||||
sudo reboot
|
||||
else
|
||||
echo "User chose not to remove /var/lib/pacman/db.lck" | log
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check for internet connectivity.
|
||||
if ! ping -c1 -W5 f123.org &> /dev/null | dialog --progressbox "$(gettext "Checking internet connection...")" 0 0; then
|
||||
echo "Could not connect to internet" | log
|
||||
infobox "$(gettext "No internet connection detected. Please connect to the internet and try again.")"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for free space in /tmp
|
||||
# Get free size on disk
|
||||
freeSpace=$(df -h --output=avail /tmp | tr -Cd '[:digit:]')
|
||||
if [[ $freeSpace -lt 50 ]]; then
|
||||
echo "Not enough free space on the disk to do updates." | log
|
||||
infobox "$(gettext "There is not enough free space on the disk to update the system.")"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make sure update-f123light is up to date.
|
||||
oldVersion="$(pacman -Qi update-f123light | head -2 | tail -1)"
|
||||
sudo pacman -Sy --noconfirm --needed update-f123light &> /dev/null | dialog --progressbox "Checking to make sure you have the latest version of update-f123light" -1 -1
|
||||
newVersion="$(pacman -Qi update-f123light | head -2 | tail -1)"
|
||||
if [[ "$oldVersion" != "$newVersion" ]]; then
|
||||
echo "update-f123light was updated from version $oldVersion to $newVersion" | log
|
||||
msgbox "A new version of update-f123light has been installed. Please run update-f123light again."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Cleanup just in case there is a temporary file or content repository left behind from a previous update.
|
||||
sudo rm -Rf /tmp/files-F123Light /tmp/content-F123Light
|
||||
|
||||
# Clone the files-F123Light and content-F123Light git repositories.
|
||||
if git clone -q -b $branch --depth 1 https://gitlab.com/f123/files-F123Light.git /tmp/files-F123Light ; then
|
||||
echo "Cloned files-F123Light: $branch" | log
|
||||
else
|
||||
echo "Failed to clone files-F123Light: $branch" | log
|
||||
infobox "$(gettext "Failed to download update files. Please try again later.")"
|
||||
exit 1
|
||||
fi
|
||||
if git clone -q --depth 1 https://gitlab.com/f123/content-F123Light.git /tmp/content-F123Light ; then
|
||||
echo "Cloned content-F123Light." | log
|
||||
else
|
||||
echo "Failed to clone content-F123Light: $branch" | log
|
||||
msgbox "$(gettext "Failed to download content and language improvements. The update process will continue, but language improvements and documentation updates will not be added.")"
|
||||
fi
|
||||
|
||||
|
||||
# Due to the nature of system updates, this script may ask for the user's password more than once.
|
||||
# Try to minimize user fears with a friendly message.
|
||||
echo "All preupgrade checks passed." | log
|
||||
msgbox "$(gettext "The software update process for F123Light will now begin. Depending on how many updates there are, your password might be requested more than once. Do not be alarmed, as this is normal. Press the 'Enter' key to continue, or the escape key to exit.")" || exit 0
|
||||
|
||||
# Perform incremental updates
|
||||
# They are found in scripts/updates.sh in the files-F123Light repository
|
||||
# This file explains how to apply incremental updates, usage, formatting, etc.
|
||||
source /tmp/files-F123Light/scripts/updates.sh | dialog --progressbox "$(gettext "Performing incremental updates...")" -1 -1
|
||||
|
||||
# Clean the package cache.
|
||||
sudo pacman -Sc --noconfirm |& log | dialog --progressbox "$(gettext "Cleaning package cache...")" -1 -1
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "There were problems cleaning the package cache." | log
|
||||
fi
|
||||
# Update all ALARM and F123 maintained packages on the system that are not in the ignore list on public.f123.org.
|
||||
# Track kernel version and prompt for a reboot after if it changes
|
||||
oldKernel="$(uname -r)"
|
||||
oldKernel="${oldKernel%-*}"
|
||||
ignorePkgList="$(curl -Ls public.f123.org/update-f123light/ignorepkg.txt)"
|
||||
if [[ -n "${ignorePkgList}" ]]; then
|
||||
ignorePkgList="--ignore ${ignorePkgList//[[:space:]]/,} "
|
||||
fi
|
||||
yes | sudo pacman -Syu --noconfirm --noprogressbar ${ignorePkgList}|& sudo tee -a "$logFile" | grep -v '\? \[Y/n\]' | dialog --progressbox "$(gettext "Updating system software...")" -1 -1
|
||||
newKernel="$(pacman -Qi linux-raspberrypi | head -2 | tail -1)"
|
||||
newKernel="${newKernel##* }"
|
||||
if [[ "$oldKernel" != "$newKernel" ]]; then
|
||||
reboot="true"
|
||||
echo "The kernel was upgraded from version ${oldKernel%%-*} to version ${newKernel%%-*}" | log
|
||||
fi
|
||||
|
||||
infobox "$(gettext "Updating configuration and other files...")"
|
||||
|
||||
# Copy in the files-F123Light and content-F123Light files.
|
||||
# Only the files under files-F123Light/files/usr should be copied to the system to avoid resetting configs modified by the system menu.
|
||||
# Everything in content-F123Light is always copied.
|
||||
|
||||
shopt -s dotglob
|
||||
sudo cp -a /tmp/files-F123Light/files/usr/* /usr
|
||||
# Update F123Light specific configuration directory.
|
||||
sudo cp -a /tmp/files-F123Light/files/etc/F123-Config/* /etc/F123-Config
|
||||
# /boot is a special case on a Raspberry Pi, as it's an oldschool DOS partition.
|
||||
if uname -m | grep -q armv7 ; then
|
||||
sudo cp -R /tmp/files-F123Light/files/boot/* /boot |& log
|
||||
fi
|
||||
sudo cp -R /tmp/content-F123Light/F123/* /usr/share/doc/F123
|
||||
|
||||
|
||||
if [[ "$reboot" == "true" ]]; then
|
||||
reboot_prompt
|
||||
fi
|
||||
|
||||
msgbox "$(gettext "Update complete.")"
|
||||
|
||||
exit 0
|
245
files/scripts/en-US/update-f123light
Normal file
245
files/scripts/en-US/update-f123light
Normal file
@ -0,0 +1,245 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2018, F123 Consulting, <information@f123.org>
|
||||
# Copyright 2018, Kyle, <kyle@free2.ml>
|
||||
# Copyright 2018, Storm Dragon, <storm_dragon@linux-a11y.org>
|
||||
#
|
||||
# This 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 3, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# This software 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 package; see the file COPYING. If not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
#
|
||||
#--code--
|
||||
|
||||
# the gettext essentials
|
||||
export TEXTDOMAIN=update-f123light
|
||||
export TEXTDOMAINDIR=/usr/share/locale
|
||||
|
||||
. gettext.sh
|
||||
|
||||
# Import the standard F123Light functions
|
||||
. /usr/lib/F123-includes/script_functions.sh
|
||||
|
||||
cleanup() {
|
||||
# The temporary files downloaded from the F123Light git repositories are no longer needed.
|
||||
# Kill the clones.
|
||||
sudo -v && sudo rm -Rf /tmp/files-F123Light /tmp/content-F123Light
|
||||
}
|
||||
|
||||
# Log writing function
|
||||
log() {
|
||||
while read -r line ; do
|
||||
echo "$line" | sudo tee -a "$logFile" &> /dev/null
|
||||
done
|
||||
}
|
||||
|
||||
# Incremental update timestamp function
|
||||
# Determine whether to perform the update that calls this function.
|
||||
# Return false if the time in yymmddhhmm format is not later than /etc/build-timestamp
|
||||
# Otherwise write the new timestamp and return 0 so that the update is performed.
|
||||
# on the calling system.
|
||||
update () {
|
||||
local updateTime="$1"
|
||||
local lastUpdated="$(cat /etc/timestamp-f123light | tr -cd '[:digit:]' 2> /dev/null)"
|
||||
lastUpdated=${lastUpdated:-0}
|
||||
if [[ $updateTime -gt $lastUpdated ]]; then
|
||||
echo -n "$updateTime" | sudo tee /etc/timestamp-f123light &> /dev/null
|
||||
echo "Performed incremental update $updateTime" | log
|
||||
else
|
||||
return 100
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
reboot_prompt () {
|
||||
# Prompt the user to reboot just in case something like the kernel that deserves a reboot has been updated.
|
||||
# We will prompt for a keypress. Enter to reboot, escape to exit the script and return to the shell or calling script.
|
||||
local $key
|
||||
clear
|
||||
key=$(yesno "$(gettext "Your system has been updated. We recommend that you restart your computer. Please press 'Enter' to restart or 'Escape' to finish the update without restarting.")")
|
||||
case $key in
|
||||
"Yes")
|
||||
sudo systemctl reboot
|
||||
;;
|
||||
"No")
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Default files-F123Light git branch to be cloned
|
||||
branch=master
|
||||
|
||||
# test to determine whether to prompt for a reboot, initially false
|
||||
reboot=false
|
||||
|
||||
# Get command line options
|
||||
if ! options=$(getopt -o b:h -l branch:,help, -n "update-f123light" -- "$@"); then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
eval set -- "$options"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-b|--branch)
|
||||
branch="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
cat <<-HELP
|
||||
$(gettext "Usage")
|
||||
$(eval_gettext "\$name [options...]")
|
||||
$(gettext "Options")
|
||||
-h, --help: $(gettext "Print this help message and exit")
|
||||
-b <branch>, --branch=<branch>: $(eval_gettext "Get files from the specified git branch, default: \$branch")
|
||||
HELP
|
||||
exit 0
|
||||
;;
|
||||
(--)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo $(basename $0): $1 $(gettext "not recognized") 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
clear
|
||||
set -Eo pipefail
|
||||
trap cleanup EXIT
|
||||
# Log file name
|
||||
logFile="/var/log/${0##*/}"
|
||||
|
||||
# Check if the current user uas sudo privileges.
|
||||
if sudo -v ; then
|
||||
# Initialize logFile.
|
||||
echo "Log for update-f123light. Starting at version $(</etc/timestamp-f123light)" | sudo tee "$logFile" &> /dev/null
|
||||
else
|
||||
infobox "$USER $(gettext "Does not currently have administrator access to this system. Please upgrade with a user that has adminstrator access.")";
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# See if we can update the system.
|
||||
if [[ -f "/var/lib/pacman/db.lck" ]]; then
|
||||
echo "Found /var/lib/pacman/db.lck" | log
|
||||
if [[ "$(yesno "$(gettext "Your system needs to restart before updates can begin. Would you like to do this now?")")" == "Yes" ]]; then
|
||||
sudo rm -f "/var/lib/pacman/db.lck"
|
||||
echo "Removed /var/lib/pacman/db.lck" | log
|
||||
sudo reboot
|
||||
else
|
||||
echo "User chose not to remove /var/lib/pacman/db.lck" | log
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check for internet connectivity.
|
||||
if ! ping -c1 -W5 f123.org &> /dev/null | dialog --progressbox "$(gettext "Checking internet connection...")" 0 0; then
|
||||
echo "Could not connect to internet" | log
|
||||
infobox "$(gettext "No internet connection detected. Please connect to the internet and try again.")"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for free space in /tmp
|
||||
# Get free size on disk
|
||||
freeSpace=$(df -h --output=avail /tmp | tr -Cd '[:digit:]')
|
||||
if [[ $freeSpace -lt 50 ]]; then
|
||||
echo "Not enough free space on the disk to do updates." | log
|
||||
infobox "$(gettext "There is not enough free space on the disk to update the system.")"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make sure update-f123light is up to date.
|
||||
oldVersion="$(pacman -Qi update-f123light | head -2 | tail -1)"
|
||||
sudo pacman -Sy --noconfirm --needed update-f123light &> /dev/null | dialog --progressbox "Checking to make sure you have the latest version of update-f123light" -1 -1
|
||||
newVersion="$(pacman -Qi update-f123light | head -2 | tail -1)"
|
||||
if [[ "$oldVersion" != "$newVersion" ]]; then
|
||||
echo "update-f123light was updated from version $oldVersion to $newVersion" | log
|
||||
msgbox "A new version of update-f123light has been installed. Please run update-f123light again."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Cleanup just in case there is a temporary file or content repository left behind from a previous update.
|
||||
sudo rm -Rf /tmp/files-F123Light /tmp/content-F123Light
|
||||
|
||||
# Clone the files-F123Light and content-F123Light git repositories.
|
||||
if git clone -q -b $branch --depth 1 https://gitlab.com/f123/files-F123Light.git /tmp/files-F123Light ; then
|
||||
echo "Cloned files-F123Light: $branch" | log
|
||||
else
|
||||
echo "Failed to clone files-F123Light: $branch" | log
|
||||
infobox "$(gettext "Failed to download update files. Please try again later.")"
|
||||
exit 1
|
||||
fi
|
||||
if git clone -q --depth 1 https://gitlab.com/f123/content-F123Light.git /tmp/content-F123Light ; then
|
||||
echo "Cloned content-F123Light." | log
|
||||
else
|
||||
echo "Failed to clone content-F123Light: $branch" | log
|
||||
msgbox "$(gettext "Failed to download content and language improvements. The update process will continue, but language improvements and documentation updates will not be added.")"
|
||||
fi
|
||||
|
||||
|
||||
# Due to the nature of system updates, this script may ask for the user's password more than once.
|
||||
# Try to minimize user fears with a friendly message.
|
||||
echo "All preupgrade checks passed." | log
|
||||
msgbox "$(gettext "The software update process for F123Light will now begin. Depending on how many updates there are, your password might be requested more than once. Do not be alarmed, as this is normal. Press the 'Enter' key to continue, or the escape key to exit.")" || exit 0
|
||||
|
||||
# Perform incremental updates
|
||||
# They are found in scripts/updates.sh in the files-F123Light repository
|
||||
# This file explains how to apply incremental updates, usage, formatting, etc.
|
||||
source /tmp/files-F123Light/scripts/updates.sh | dialog --progressbox "$(gettext "Performing incremental updates...")" -1 -1
|
||||
|
||||
# Clean the package cache.
|
||||
sudo pacman -Sc --noconfirm |& log | dialog --progressbox "$(gettext "Cleaning package cache...")" -1 -1
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "There were problems cleaning the package cache." | log
|
||||
fi
|
||||
# Update all ALARM and F123 maintained packages on the system that are not in the ignore list on public.f123.org.
|
||||
# Track kernel version and prompt for a reboot after if it changes
|
||||
oldKernel="$(uname -r)"
|
||||
oldKernel="${oldKernel%-*}"
|
||||
ignorePkgList="$(curl -Ls public.f123.org/update-f123light/ignorepkg.txt)"
|
||||
if [[ -n "${ignorePkgList}" ]]; then
|
||||
ignorePkgList="--ignore ${ignorePkgList//[[:space:]]/,} "
|
||||
fi
|
||||
yes | sudo pacman -Syu --noconfirm --noprogressbar ${ignorePkgList}|& sudo tee -a "$logFile" | grep -v '\? \[Y/n\]' | dialog --progressbox "$(gettext "Updating system software...")" -1 -1
|
||||
newKernel="$(pacman -Qi linux-raspberrypi | head -2 | tail -1)"
|
||||
newKernel="${newKernel##* }"
|
||||
if [[ "$oldKernel" != "$newKernel" ]]; then
|
||||
reboot="true"
|
||||
echo "The kernel was upgraded from version ${oldKernel%%-*} to version ${newKernel%%-*}" | log
|
||||
fi
|
||||
|
||||
infobox "$(gettext "Updating configuration and other files...")"
|
||||
|
||||
# Copy in the files-F123Light and content-F123Light files.
|
||||
# Only the files under files-F123Light/files/usr should be copied to the system to avoid resetting configs modified by the system menu.
|
||||
# Everything in content-F123Light is always copied.
|
||||
|
||||
shopt -s dotglob
|
||||
sudo cp -a /tmp/files-F123Light/files/usr/* /usr
|
||||
# Update F123Light specific configuration directory.
|
||||
sudo cp -a /tmp/files-F123Light/files/etc/F123-Config/* /etc/F123-Config
|
||||
# /boot is a special case on a Raspberry Pi, as it's an oldschool DOS partition.
|
||||
if uname -m | grep -q armv7 ; then
|
||||
sudo cp -R /tmp/files-F123Light/files/boot/* /boot |& log
|
||||
fi
|
||||
sudo cp -R /tmp/content-F123Light/F123/* /usr/share/doc/F123
|
||||
|
||||
|
||||
if [[ "$reboot" == "true" ]]; then
|
||||
reboot_prompt
|
||||
fi
|
||||
|
||||
msgbox "$(gettext "Update complete.")"
|
||||
|
||||
exit 0
|
245
files/scripts/es-ES/update-f123light
Normal file
245
files/scripts/es-ES/update-f123light
Normal file
@ -0,0 +1,245 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2018, F123 Consulting, <information@f123.org>
|
||||
# Copyright 2018, Kyle, <kyle@free2.ml>
|
||||
# Copyright 2018, Storm Dragon, <storm_dragon@linux-a11y.org>
|
||||
#
|
||||
# This 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 3, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# This software 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 package; see the file COPYING. If not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
#
|
||||
#--code--
|
||||
|
||||
# the gettext essentials
|
||||
export TEXTDOMAIN=update-f123light
|
||||
export TEXTDOMAINDIR=/usr/share/locale
|
||||
|
||||
. gettext.sh
|
||||
|
||||
# Import the standard F123Light functions
|
||||
. /usr/lib/F123-includes/script_functions.sh
|
||||
|
||||
cleanup() {
|
||||
# The temporary files downloaded from the F123Light git repositories are no longer needed.
|
||||
# Kill the clones.
|
||||
sudo -v && sudo rm -Rf /tmp/files-F123Light /tmp/content-F123Light
|
||||
}
|
||||
|
||||
# Log writing function
|
||||
log() {
|
||||
while read -r line ; do
|
||||
echo "$line" | sudo tee -a "$logFile" &> /dev/null
|
||||
done
|
||||
}
|
||||
|
||||
# Incremental update timestamp function
|
||||
# Determine whether to perform the update that calls this function.
|
||||
# Return false if the time in yymmddhhmm format is not later than /etc/build-timestamp
|
||||
# Otherwise write the new timestamp and return 0 so that the update is performed.
|
||||
# on the calling system.
|
||||
update () {
|
||||
local updateTime="$1"
|
||||
local lastUpdated="$(cat /etc/timestamp-f123light | tr -cd '[:digit:]' 2> /dev/null)"
|
||||
lastUpdated=${lastUpdated:-0}
|
||||
if [[ $updateTime -gt $lastUpdated ]]; then
|
||||
echo -n "$updateTime" | sudo tee /etc/timestamp-f123light &> /dev/null
|
||||
echo "Performed incremental update $updateTime" | log
|
||||
else
|
||||
return 100
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
reboot_prompt () {
|
||||
# Prompt the user to reboot just in case something like the kernel that deserves a reboot has been updated.
|
||||
# We will prompt for a keypress. Enter to reboot, escape to exit the script and return to the shell or calling script.
|
||||
local $key
|
||||
clear
|
||||
key=$(yesno "$(gettext "Your system has been updated. We recommend that you restart your computer. Please press 'Enter' to restart or 'Escape' to finish the update without restarting.")")
|
||||
case $key in
|
||||
"Yes")
|
||||
sudo systemctl reboot
|
||||
;;
|
||||
"No")
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Default files-F123Light git branch to be cloned
|
||||
branch=master
|
||||
|
||||
# test to determine whether to prompt for a reboot, initially false
|
||||
reboot=false
|
||||
|
||||
# Get command line options
|
||||
if ! options=$(getopt -o b:h -l branch:,help, -n "update-f123light" -- "$@"); then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
eval set -- "$options"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-b|--branch)
|
||||
branch="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
cat <<-HELP
|
||||
$(gettext "Usage")
|
||||
$(eval_gettext "\$name [options...]")
|
||||
$(gettext "Options")
|
||||
-h, --help: $(gettext "Print this help message and exit")
|
||||
-b <branch>, --branch=<branch>: $(eval_gettext "Get files from the specified git branch, default: \$branch")
|
||||
HELP
|
||||
exit 0
|
||||
;;
|
||||
(--)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo $(basename $0): $1 $(gettext "not recognized") 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
clear
|
||||
set -Eo pipefail
|
||||
trap cleanup EXIT
|
||||
# Log file name
|
||||
logFile="/var/log/${0##*/}"
|
||||
|
||||
# Check if the current user uas sudo privileges.
|
||||
if sudo -v ; then
|
||||
# Initialize logFile.
|
||||
echo "Log for update-f123light. Starting at version $(</etc/timestamp-f123light)" | sudo tee "$logFile" &> /dev/null
|
||||
else
|
||||
infobox "$USER $(gettext "Does not currently have administrator access to this system. Please upgrade with a user that has adminstrator access.")";
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# See if we can update the system.
|
||||
if [[ -f "/var/lib/pacman/db.lck" ]]; then
|
||||
echo "Found /var/lib/pacman/db.lck" | log
|
||||
if [[ "$(yesno "$(gettext "Your system needs to restart before updates can begin. Would you like to do this now?")")" == "Yes" ]]; then
|
||||
sudo rm -f "/var/lib/pacman/db.lck"
|
||||
echo "Removed /var/lib/pacman/db.lck" | log
|
||||
sudo reboot
|
||||
else
|
||||
echo "User chose not to remove /var/lib/pacman/db.lck" | log
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check for internet connectivity.
|
||||
if ! ping -c1 -W5 f123.org &> /dev/null | dialog --progressbox "$(gettext "Checking internet connection...")" 0 0; then
|
||||
echo "Could not connect to internet" | log
|
||||
infobox "$(gettext "No internet connection detected. Please connect to the internet and try again.")"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for free space in /tmp
|
||||
# Get free size on disk
|
||||
freeSpace=$(df -h --output=avail /tmp | tr -Cd '[:digit:]')
|
||||
if [[ $freeSpace -lt 50 ]]; then
|
||||
echo "Not enough free space on the disk to do updates." | log
|
||||
infobox "$(gettext "There is not enough free space on the disk to update the system.")"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make sure update-f123light is up to date.
|
||||
oldVersion="$(pacman -Qi update-f123light | head -2 | tail -1)"
|
||||
sudo pacman -Sy --noconfirm --needed update-f123light &> /dev/null | dialog --progressbox "Checking to make sure you have the latest version of update-f123light" -1 -1
|
||||
newVersion="$(pacman -Qi update-f123light | head -2 | tail -1)"
|
||||
if [[ "$oldVersion" != "$newVersion" ]]; then
|
||||
echo "update-f123light was updated from version $oldVersion to $newVersion" | log
|
||||
msgbox "A new version of update-f123light has been installed. Please run update-f123light again."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Cleanup just in case there is a temporary file or content repository left behind from a previous update.
|
||||
sudo rm -Rf /tmp/files-F123Light /tmp/content-F123Light
|
||||
|
||||
# Clone the files-F123Light and content-F123Light git repositories.
|
||||
if git clone -q -b $branch --depth 1 https://gitlab.com/f123/files-F123Light.git /tmp/files-F123Light ; then
|
||||
echo "Cloned files-F123Light: $branch" | log
|
||||
else
|
||||
echo "Failed to clone files-F123Light: $branch" | log
|
||||
infobox "$(gettext "Failed to download update files. Please try again later.")"
|
||||
exit 1
|
||||
fi
|
||||
if git clone -q --depth 1 https://gitlab.com/f123/content-F123Light.git /tmp/content-F123Light ; then
|
||||
echo "Cloned content-F123Light." | log
|
||||
else
|
||||
echo "Failed to clone content-F123Light: $branch" | log
|
||||
msgbox "$(gettext "Failed to download content and language improvements. The update process will continue, but language improvements and documentation updates will not be added.")"
|
||||
fi
|
||||
|
||||
|
||||
# Due to the nature of system updates, this script may ask for the user's password more than once.
|
||||
# Try to minimize user fears with a friendly message.
|
||||
echo "All preupgrade checks passed." | log
|
||||
msgbox "$(gettext "The software update process for F123Light will now begin. Depending on how many updates there are, your password might be requested more than once. Do not be alarmed, as this is normal. Press the 'Enter' key to continue, or the escape key to exit.")" || exit 0
|
||||
|
||||
# Perform incremental updates
|
||||
# They are found in scripts/updates.sh in the files-F123Light repository
|
||||
# This file explains how to apply incremental updates, usage, formatting, etc.
|
||||
source /tmp/files-F123Light/scripts/updates.sh | dialog --progressbox "$(gettext "Performing incremental updates...")" -1 -1
|
||||
|
||||
# Clean the package cache.
|
||||
sudo pacman -Sc --noconfirm |& log | dialog --progressbox "$(gettext "Cleaning package cache...")" -1 -1
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "There were problems cleaning the package cache." | log
|
||||
fi
|
||||
# Update all ALARM and F123 maintained packages on the system that are not in the ignore list on public.f123.org.
|
||||
# Track kernel version and prompt for a reboot after if it changes
|
||||
oldKernel="$(uname -r)"
|
||||
oldKernel="${oldKernel%-*}"
|
||||
ignorePkgList="$(curl -Ls public.f123.org/update-f123light/ignorepkg.txt)"
|
||||
if [[ -n "${ignorePkgList}" ]]; then
|
||||
ignorePkgList="--ignore ${ignorePkgList//[[:space:]]/,} "
|
||||
fi
|
||||
yes | sudo pacman -Syu --noconfirm --noprogressbar ${ignorePkgList}|& sudo tee -a "$logFile" | grep -v '\? \[Y/n\]' | dialog --progressbox "$(gettext "Updating system software...")" -1 -1
|
||||
newKernel="$(pacman -Qi linux-raspberrypi | head -2 | tail -1)"
|
||||
newKernel="${newKernel##* }"
|
||||
if [[ "$oldKernel" != "$newKernel" ]]; then
|
||||
reboot="true"
|
||||
echo "The kernel was upgraded from version ${oldKernel%%-*} to version ${newKernel%%-*}" | log
|
||||
fi
|
||||
|
||||
infobox "$(gettext "Updating configuration and other files...")"
|
||||
|
||||
# Copy in the files-F123Light and content-F123Light files.
|
||||
# Only the files under files-F123Light/files/usr should be copied to the system to avoid resetting configs modified by the system menu.
|
||||
# Everything in content-F123Light is always copied.
|
||||
|
||||
shopt -s dotglob
|
||||
sudo cp -a /tmp/files-F123Light/files/usr/* /usr
|
||||
# Update F123Light specific configuration directory.
|
||||
sudo cp -a /tmp/files-F123Light/files/etc/F123-Config/* /etc/F123-Config
|
||||
# /boot is a special case on a Raspberry Pi, as it's an oldschool DOS partition.
|
||||
if uname -m | grep -q armv7 ; then
|
||||
sudo cp -R /tmp/files-F123Light/files/boot/* /boot |& log
|
||||
fi
|
||||
sudo cp -R /tmp/content-F123Light/F123/* /usr/share/doc/F123
|
||||
|
||||
|
||||
if [[ "$reboot" == "true" ]]; then
|
||||
reboot_prompt
|
||||
fi
|
||||
|
||||
msgbox "$(gettext "Update complete.")"
|
||||
|
||||
exit 0
|
50
files/scripts/generate_translations.sh
Executable file
50
files/scripts/generate_translations.sh
Executable file
@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
# generate_translations.sh
|
||||
# Description: A small script to create gettext translation files .pot, .po
|
||||
#
|
||||
# Copyright 2019, F123 Consulting, <information@f123.org>
|
||||
# Copyright 2019, Storm Dragon, <storm_dragon@linux-a11y.org>
|
||||
#
|
||||
# This 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 3, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# This software 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 package; see the file COPYING. If not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
#
|
||||
#--code--
|
||||
|
||||
# Set project name here.
|
||||
projectName=""
|
||||
|
||||
if [[ -z "$projectName" ]]; then
|
||||
echo "Please set project name in the projectName variable. Hint, edit $0"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -f "${projectName}.pot" ]]; then
|
||||
echo "${projectName}.pot already exists, remove it to regenerate it."
|
||||
else
|
||||
xgettext -o ${projectName}.pot -d ${projectName} -L python $(find ../src -iname "*.py")
|
||||
fi
|
||||
|
||||
if [[ $# -eq 1 ]]; then
|
||||
if grep -qw "$1" /etc/locale.gen ; then
|
||||
echo "Generating .po file for $1."
|
||||
msginit -i "${projectName}.pot" -l $1
|
||||
sed -i -e "s/PACKAGE package.$/PACKAGE $projectName./g" \
|
||||
-e 's/THE PACKAGE.S COPYRIGHT HOLDER$/F123 Consulting <info@f123.org>/' "${1%.*}.po"
|
||||
else
|
||||
echo "No locale $1 found, skipping."
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
391
files/scripts/install-f123light
Executable file
391
files/scripts/install-f123light
Executable file
@ -0,0 +1,391 @@
|
||||
#!/bin/bash
|
||||
# install-f123light.sh
|
||||
# Description: Installer script for F123Light on x86_64 machines
|
||||
#
|
||||
# Copyright 2019, F123 Consulting, <information@f123.org>
|
||||
# Copyright 2019, Storm Dragon, <storm_dragon@linux-a11y.org>
|
||||
#
|
||||
# This 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 3, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# This software 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 package; see the file COPYING. If not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
#
|
||||
# This script is based off vm.sh located at https://stormdragon.tk/scripts/vm.sh
|
||||
#
|
||||
#--code--
|
||||
|
||||
# the gettext essentials
|
||||
export TEXTDOMAIN=install-f123light.sh
|
||||
export TEXTDOMAINDIR=/usr/share/locale
|
||||
source gettext.sh
|
||||
|
||||
# Log writing function
|
||||
log() {
|
||||
# Usage: command | log for just stdout.
|
||||
# Or command |& log for stderr and stdout.
|
||||
while read -r line ; do
|
||||
echo "$line" | sudo tee -a "$logFile"
|
||||
done
|
||||
}
|
||||
|
||||
# Log file name is /var/log/scriptname
|
||||
logFile="/var/log/${0##*/}"
|
||||
# Clear previous logs
|
||||
echo -n | sudo tee "$logFile" &> /dev/null
|
||||
|
||||
# Check if this script is already running
|
||||
if [ $(ps ux | grep "$(basename $0)" |grep -v grep | wc -l) -gt 2 ] ; then
|
||||
[ "$1" = "-a" ] || echo "This script already appears to be running... Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find out if we are efi or not.
|
||||
if [[ -d /sys/firmware/efi ]]; then
|
||||
efi="yes"
|
||||
else
|
||||
efi="no"
|
||||
fi
|
||||
|
||||
gpgkeys=('1E14FA260F577600704793200DD7721ADC85709B' '8E322618C859858A0A11205F5BEA237143DDC193')
|
||||
disk=sda
|
||||
# Disk will be chosen by user once implemented
|
||||
diskSize=$(lsblk -b -n -o size /dev/${disk} |head -n1)
|
||||
bootSize=468
|
||||
rootSize=30000
|
||||
if [ $diskSize -le 36000000000 ];then
|
||||
rootSize=15000
|
||||
fi
|
||||
homeSize=-1 # from last partitian to end of disk leaving enough space for gpt.
|
||||
diskPrefix=$disk
|
||||
if [[ $diskPrefix =~ (mmcblk|nvme).+ ]];then
|
||||
diskPrefix=${diskPrefix}p
|
||||
fi
|
||||
|
||||
# check internet and connect wifi if not connected
|
||||
if ! ping -c4 1.1.1.1 &> /dev/null ; then
|
||||
read -p "You don't seem to be connected to the internet. Would you like to connect via wifi? (y/n)" wifi
|
||||
if [ "$wifi" = "y" ] ; then
|
||||
echo "Once you press enter, a menu will open with all available wifi networks listed. Arrow to the one you want to use and press enter twice. Once you do this, if a password is required for your wifi network you must enter it, then press enter. Once wifi is connected you may continue with the installation."
|
||||
read -p "Press enter to continue or control+c to quit." continue
|
||||
while : ; do
|
||||
wifi-menu
|
||||
if [ $? -ne 0 ] ; then
|
||||
read -p "Wifi didn't seem to connect properly. Would you like to try again? (y/n)" wifi
|
||||
if [ "$wifi" != "y" ] ; then
|
||||
echo "Wifi couldn't connect. This installer cannot continue. If you wish to connect manually, do so and run $0 again."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "This installer requires internet to run. Please connect manually and run $0 again."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Load files
|
||||
echo "Loading, please wait..."
|
||||
# Make sure we have git installed
|
||||
pacman -Syy --needed --noconfirm git |& log &> /dev/null
|
||||
for i in content-F123Light files-F123Light F123Light ; do
|
||||
case "$i" in
|
||||
"files-F123Light") branch="x86";;
|
||||
*) branch="master";;
|
||||
esac
|
||||
if [[ -d "/tmp/${i}" ]]; then
|
||||
git -C "/tmp/${i}" pull -q
|
||||
git -C "/tmp/${i}" checkout -b ${branch} |& log &> /dev/null
|
||||
else
|
||||
if git clone -q --depth 1 -b $branch https://gitlab.com/f123/${i}.git /tmp/${i} ; then
|
||||
echo "Cloned ${i}" | log &> /dev/null
|
||||
else
|
||||
echo "$(gettext "Failed to download required files. Please make sure you are connected to the internet.")" | log
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
#get information
|
||||
echo
|
||||
echo "Welcome! Before I create your F123Light installation, I need to ask you a couple questions."
|
||||
# Find out if we are installing to a vm?
|
||||
read -p "Are you installing a virtual machine? (y/n) " vm
|
||||
if [ "${vm^}" = "Y" ]; then
|
||||
vm="yes"
|
||||
else
|
||||
vm="no"
|
||||
fi
|
||||
if [ "$vm" = "no" ]; then
|
||||
echo "Do you want this script to partition your drive for you? If yes, the whole drive will be used for F123Light, and all data that existed on the drive before will be erased."
|
||||
read -p "If no, you will need to create partitions and file systems and mount them to /mnt. (y/n) " format
|
||||
if [ "${format^}" = "Y" ]; then
|
||||
format="yes"
|
||||
else
|
||||
format="no"
|
||||
fi
|
||||
if [[ -z "$format" ]]; then
|
||||
echo "Format was not set to yes nor no." | log
|
||||
fi
|
||||
fi
|
||||
|
||||
#Verify information
|
||||
echo | log
|
||||
echo "----------------------------------------------------------------------" | log
|
||||
msg="You are"
|
||||
if [[ "$vm" == "no" ]]; then
|
||||
msg+=" not"
|
||||
fi
|
||||
echo "${msg} installing to a virtual machine." | log
|
||||
echo "This computer will be called: f123light" | log
|
||||
echo "Your root password will be: root" | log
|
||||
echo | log
|
||||
echo "Your user account is: f123" | log
|
||||
echo "Your user account password is: f123" | log
|
||||
echo | log
|
||||
if [[ "$vm" == "no" ]]; then
|
||||
echo "You are installing to disk, not virtual machine." | log
|
||||
if [[ "$format" = "yes" ]]; then
|
||||
echo "this script will automatically partition the disk for you. All previous data will be erased." | log
|
||||
else
|
||||
echo "You chose to manually handle partitions and file systems. Please make sure your desired directory structure is mounted to /mnt/" | log
|
||||
fi
|
||||
echo | log
|
||||
fi
|
||||
read -p "Press enter to continue: " continue
|
||||
echo
|
||||
echo "Note: When you press enter a lot of things will happen and you may wish to turn off speech during this process."
|
||||
echo "To do so, if you have a numeric keypad, press numpad insert pluss numpad enter."
|
||||
echo "If you are using a laptop, press and hold control, then press and hold capslock, finally press enter."
|
||||
echo "This is a toggle, so to reenable speech, simply press the same keyboard shortcut again."
|
||||
echo "Also note: when pacman installs the reflector package, it will rate the speed of arch linux package servers. This may take several minutes, so be patient."
|
||||
unset continue
|
||||
read -p "Continue with the installation? (y/n): " continue
|
||||
if [ "${continue^}" != "Y" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Add F123Light version of pacman.conf
|
||||
if ! grep -q '\[f123light\]' /etc/pacman.conf ; then
|
||||
sed -i -e 's/\[core\]/[f123light]\nServer = https:\/\/packages.f123.org\/$arch\n\n[core]/' /etc/pacman.conf
|
||||
fi
|
||||
|
||||
# Make sure system time is correct, and pacman-key is correct
|
||||
ntpd -g |& log
|
||||
pacman-key --populate archlinux |& log
|
||||
|
||||
# add f123 keys to the keyring.
|
||||
pacman-key --recv-keys ${gpgkeys[@]}
|
||||
pacman-key --lsign ${gpgkeys[@]}
|
||||
|
||||
# Synchronize repositories and install reflector if needed.
|
||||
pacman -Syy --needed --noconfirm reflector |& log
|
||||
|
||||
# Now that we have reflector, run it to get best mirrors.
|
||||
/usr/bin/reflector -f 10 -a 6 > /tmp/mirrorlist
|
||||
F="$(< /tmp/mirrorlist)"
|
||||
[ -n "$F" ] && mv /tmp/mirrorlist /etc/pacman.d/mirrorlist
|
||||
|
||||
# make partitions
|
||||
if [[ "$format" == "yes" || "$vm" == "yes" ]]; then
|
||||
wipefs --all /dev/$disk |& log
|
||||
dd if=/dev/zero of=/dev/$disk bs=1M count=8 |& log
|
||||
if [[ "$efi" = "yes" ]]; then
|
||||
boot=1
|
||||
parted -s -a optimal -- /dev/$disk mklabel gpt \
|
||||
mkpart primary 3MiB ${bootSize}MiB set 1 esp on \
|
||||
mkpart primary $(( 3 + $bootSize ))MiB ${rootSize}MiB \
|
||||
mkpart primary $(( 3 + $bootSize + $rootSize ))MiB ${homeSize}MiB |& log
|
||||
else
|
||||
if [[ $diskSize -gt 2000000000000 ]]; then
|
||||
boot=2
|
||||
parted -s -a optimal -- /dev/$disk mklabel gpt \
|
||||
mkpart primary 1MiB 2MiB set 1 bios_grub on \
|
||||
mkpart primary 3MiB ${bootSize}MiB set 2 boot on \
|
||||
mkpart primary $(( 3 + $bootSize ))MiB ${rootSize}MiB \
|
||||
mkpart primary $(( 3 + $bootSize + $rootSize ))MiB ${homeSize}MiB \
|
||||
disk_toggle pmbr_boot |& log
|
||||
else
|
||||
boot=1
|
||||
parted -s -a optimal -- /dev/$disk mklabel msdos \
|
||||
mkpart primary 3MiB ${bootSize}MiB set 1 boot on \
|
||||
mkpart primary $(( 3 + $bootSize ))MiB ${rootSize}MiB \
|
||||
mkpart primary $(( 3 + $bootSize + $rootSize ))MiB ${homeSize}MiB \
|
||||
disk_toggle pmbr_boot |& log
|
||||
fi
|
||||
fi
|
||||
# make filesystems
|
||||
mkfs.vfat -F 32 /dev/${diskPrefix}${boot} |& log
|
||||
mkfs.ext4 /dev/${diskPrefix}$(( $boot + 1 )) |& log
|
||||
mkfs.ext4 /dev/${diskPrefix}$(( $boot + 2 )) |& log
|
||||
|
||||
# set up /mnt
|
||||
# Root
|
||||
mount /dev/${diskPrefix}$(( $boot + 1 )) /mnt |& log
|
||||
# Create directory structure
|
||||
mkdir -pv /mnt/boot |& log
|
||||
mkdir -pv /mnt/home |& log
|
||||
# Boot
|
||||
mount /dev/${diskPrefix}${boot} /mnt/boot |& log
|
||||
# Home
|
||||
mount /dev/${diskPrefix}$(( $boot + 2 )) /mnt/home |& log
|
||||
fi
|
||||
|
||||
# install packages
|
||||
|
||||
# Packages are in an array to make it easier to add/remove them.
|
||||
mapfile -t packageList < <(sed -e 's/\([[:space:]a-zA-Z0-9_.\+-]*\).*/\1/g' -e 's/^ *//' -e 's/ .*//' -e '/\(^\s*[[:punct:]]\|^$\)/d' "/tmp/F123Light/build/package_lists/packages.list")
|
||||
# Remove unneeded packages
|
||||
for i in ${!packageList[@]} ; do
|
||||
if echo "${packageList[$i]}" | grep -q "fake-hwclock" ; then
|
||||
unset packageList[$i]
|
||||
fi
|
||||
if echo "${packageList[$i]}" | grep -q "pi-bluetooth" ; then
|
||||
unset packageList[$i]
|
||||
fi
|
||||
if echo "${packageList[$i]}" | grep -q "raspberry" ; then
|
||||
unset packageList[$i]
|
||||
fi
|
||||
done
|
||||
# Add the boot loader and needed packages.
|
||||
packageList+=("grub" "dosfstools")
|
||||
if [[ "$efi" == "yes" ]]; then
|
||||
packageList+=("efibootmgr")
|
||||
fi
|
||||
if [ "$vm" = "no" ]; then
|
||||
packageList+=("grub" "os-prober")
|
||||
fi
|
||||
|
||||
# Install packages.
|
||||
pacstrap /mnt ${packageList[@]} |& log
|
||||
|
||||
# generate fstab
|
||||
genfstab -U -p /mnt > /mnt/etc/fstab
|
||||
|
||||
#copy sound state
|
||||
alsactl store
|
||||
cp /var/lib/alsa/asound.state /mnt/var/lib/alsa/asound.state |& log
|
||||
|
||||
# Copy over F123Light configuration files
|
||||
cp -arv /tmp/files-F123Light/files/* /mnt/ |& log
|
||||
# Update F123Light specific configuration directory.
|
||||
cp -arv /tmp/files-F123Light/files/etc/F123-Config/ /mnt/etc/F123-Config |& log
|
||||
mkdir -p /mnt/usr/share/doc/F123
|
||||
cp -Rv /tmp/content-F123Light/F123/* /mnt/usr/share/doc/F123 |& log
|
||||
|
||||
# Initialize the timestamp file
|
||||
date '+%y%m%d%H%M' > /mnt/etc/timestamp-f123light
|
||||
|
||||
# Get list of services to be enabled once inside the chroot
|
||||
echo -n "systemctl enable " > /mnt/f123light-services
|
||||
tail -1 /tmp/F123Light/build/F123Light.conf | cut -d '"' -f2 | sed 's/ /\nsystemctl enable /g' >> /mnt/f123light-services
|
||||
|
||||
# chroot
|
||||
arch-chroot /mnt /bin/bash << EOF |& log
|
||||
|
||||
# Source the services variable.
|
||||
source f123light-services
|
||||
|
||||
# Configure pulse stuff
|
||||
groupadd --system pulse
|
||||
groupadd --system pulse-access
|
||||
useradd --system -g pulse -G audio -d /var/run/pulse -m -s /bin/nologin pulse
|
||||
gpasswd -a pulse lp
|
||||
gpasswd -a root pulse-access
|
||||
|
||||
# set hostname
|
||||
echo "f123light" > /etc/hostname
|
||||
|
||||
# Set hwclock for install to disc.
|
||||
if [ "$vm" = "no" ]; then
|
||||
hwclock --systohc --utc
|
||||
fi
|
||||
|
||||
# set locale
|
||||
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
|
||||
locale-gen
|
||||
echo 'LANG=en_US.UTF-8' > /etc/locale.conf
|
||||
|
||||
# Install internet packages for install to disc.
|
||||
if [ "$vm" = "no" ]; then
|
||||
pacman -S --noconfirm --needed dialog iw wpa_supplicant
|
||||
fi
|
||||
|
||||
# Enable internet for the vm
|
||||
if [ "$vm" = "yes" ]; then
|
||||
systemctl enable dhcpcd
|
||||
fi
|
||||
|
||||
# enable service files.
|
||||
bash /f123light-services
|
||||
|
||||
# install and configure grub or systemd boot bootloader
|
||||
if [[ "$efi" == "no" ]]; then
|
||||
grub-install --target=i386-pc --recheck /dev/${disk}
|
||||
sed -i 's/#\s*GRUB_INIT_TUNE=/GRUB_INIT_TUNE=/' /etc/default/grub
|
||||
grub-mkconfig -o /boot/grub/grub.cfg
|
||||
else
|
||||
if [[ "$(cat /sys/firmware/efi/fw_platform_size)" = "64" ]]; then
|
||||
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
|
||||
sed -i 's/#\s*GRUB_INIT_TUNE=/GRUB_INIT_TUNE=/' /etc/default/grub
|
||||
grub-mkconfig -o /boot/grub/grub.cfg
|
||||
#bootctl install --esp-path=/boot
|
||||
#mkdir -p /boot/loader/entries
|
||||
#cp /usr/share/systemd/bootctl/arch.conf /boot/loader/entries
|
||||
#cp /usr/share/systemd/bootctl/loader.conf /boot/loader
|
||||
#sed -i -e "s/PARTUUID=XXXX/PARTUUID=$(lsblk -n -o uuid /dev/${diskPrefix}2)/" -e "s/rootfstype=XXXX/rootfstype=ext4/" /boot/loader/entries/arch.conf
|
||||
else
|
||||
# This is highly likely not to work, I'm leaving it here until we confirm if it does or doesn't. //Michael
|
||||
grub-install --target=i386-efi --efi-directory=/boot --bootloader-id=GRUB
|
||||
sed -i 's/#\s*GRUB_INIT_TUNE=/GRUB_INIT_TUNE=/' /etc/default/grub
|
||||
grub-mkconfig -o /boot/grub/grub.cfg
|
||||
fi
|
||||
fi
|
||||
|
||||
# set root password
|
||||
echo "root:root" | chpasswd
|
||||
|
||||
# Enable multilib for 64 bit systems.
|
||||
sed -i '/^#\[multilib\]$/{{N;s/^#\[multilib\]\n#Include = \/etc\/pacman.d\/mirrorlist$/[multilib]\nInclude = \/etc\/pacman.d\/mirrorlist/;t;P;D}}' /etc/pacman.conf
|
||||
pacman -Sy
|
||||
|
||||
#Create user account
|
||||
useradd -m -g users -G wheel,storage,power,uucp,audio,games,lp,scanner,pulse-access -s /bin/bash f123
|
||||
|
||||
# set user password
|
||||
echo "f123:f123" | chpasswd
|
||||
|
||||
#allow users of group wheel to use sudo without password for next section
|
||||
sed -i 's/# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/' /etc/sudoers
|
||||
|
||||
sudo -u f123 touch /home/f123/.firstboot
|
||||
|
||||
# end section sent to chroot
|
||||
EOF
|
||||
|
||||
# Copy over the log of the installation
|
||||
cp $logFile /mnt/var/log
|
||||
|
||||
# sync for good measure
|
||||
sync
|
||||
|
||||
# unmount
|
||||
umount -R /mnt
|
||||
|
||||
espeak -v en-us -a 150 "Installation complete!" &> /dev/null
|
||||
|
||||
echo "Installation complete! Type poweroff to shut down this live invironment."
|
||||
echo "Then power on to boot into your newly installed F123Light operating system!"
|
||||
echo "Thank you for choosing F123Light."
|
||||
exit 0
|
245
files/scripts/pt-BR/update-f123light
Normal file
245
files/scripts/pt-BR/update-f123light
Normal file
@ -0,0 +1,245 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2018, F123 Consulting, <information@f123.org>
|
||||
# Copyright 2018, Kyle, <kyle@free2.ml>
|
||||
# Copyright 2018, Storm Dragon, <storm_dragon@linux-a11y.org>
|
||||
#
|
||||
# This 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 3, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# This software 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 package; see the file COPYING. If not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
#
|
||||
#--code--
|
||||
|
||||
# the gettext essentials
|
||||
export TEXTDOMAIN=update-f123light
|
||||
export TEXTDOMAINDIR=/usr/share/locale
|
||||
|
||||
. gettext.sh
|
||||
|
||||
# Import the standard F123Light functions
|
||||
. /usr/lib/F123-includes/script_functions.sh
|
||||
|
||||
cleanup() {
|
||||
# The temporary files downloaded from the F123Light git repositories are no longer needed.
|
||||
# Kill the clones.
|
||||
sudo -v && sudo rm -Rf /tmp/files-F123Light /tmp/content-F123Light
|
||||
}
|
||||
|
||||
# Log writing function
|
||||
log() {
|
||||
while read -r line ; do
|
||||
echo "$line" | sudo tee -a "$logFile" &> /dev/null
|
||||
done
|
||||
}
|
||||
|
||||
# Incremental update timestamp function
|
||||
# Determine whether to perform the update that calls this function.
|
||||
# Return false if the time in yymmddhhmm format is not later than /etc/build-timestamp
|
||||
# Otherwise write the new timestamp and return 0 so that the update is performed.
|
||||
# on the calling system.
|
||||
update () {
|
||||
local updateTime="$1"
|
||||
local lastUpdated="$(cat /etc/timestamp-f123light | tr -cd '[:digit:]' 2> /dev/null)"
|
||||
lastUpdated=${lastUpdated:-0}
|
||||
if [[ $updateTime -gt $lastUpdated ]]; then
|
||||
echo -n "$updateTime" | sudo tee /etc/timestamp-f123light &> /dev/null
|
||||
echo "Performed incremental update $updateTime" | log
|
||||
else
|
||||
return 100
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
reboot_prompt () {
|
||||
# Prompt the user to reboot just in case something like the kernel that deserves a reboot has been updated.
|
||||
# We will prompt for a keypress. Enter to reboot, escape to exit the script and return to the shell or calling script.
|
||||
local $key
|
||||
clear
|
||||
key=$(yesno "$(gettext "Your system has been updated. We recommend that you restart your computer. Please press 'Enter' to restart or 'Escape' to finish the update without restarting.")")
|
||||
case $key in
|
||||
"Yes")
|
||||
sudo systemctl reboot
|
||||
;;
|
||||
"No")
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Default files-F123Light git branch to be cloned
|
||||
branch=master
|
||||
|
||||
# test to determine whether to prompt for a reboot, initially false
|
||||
reboot=false
|
||||
|
||||
# Get command line options
|
||||
if ! options=$(getopt -o b:h -l branch:,help, -n "update-f123light" -- "$@"); then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
eval set -- "$options"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-b|--branch)
|
||||
branch="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
cat <<-HELP
|
||||
$(gettext "Usage")
|
||||
$(eval_gettext "\$name [options...]")
|
||||
$(gettext "Options")
|
||||
-h, --help: $(gettext "Print this help message and exit")
|
||||
-b <branch>, --branch=<branch>: $(eval_gettext "Get files from the specified git branch, default: \$branch")
|
||||
HELP
|
||||
exit 0
|
||||
;;
|
||||
(--)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo $(basename $0): $1 $(gettext "not recognized") 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
clear
|
||||
set -Eo pipefail
|
||||
trap cleanup EXIT
|
||||
# Log file name
|
||||
logFile="/var/log/${0##*/}"
|
||||
|
||||
# Check if the current user uas sudo privileges.
|
||||
if sudo -v ; then
|
||||
# Initialize logFile.
|
||||
echo "Log for update-f123light. Starting at version $(</etc/timestamp-f123light)" | sudo tee "$logFile" &> /dev/null
|
||||
else
|
||||
infobox "$USER $(gettext "Does not currently have administrator access to this system. Please upgrade with a user that has adminstrator access.")";
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# See if we can update the system.
|
||||
if [[ -f "/var/lib/pacman/db.lck" ]]; then
|
||||
echo "Found /var/lib/pacman/db.lck" | log
|
||||
if [[ "$(yesno "$(gettext "Your system needs to restart before updates can begin. Would you like to do this now?")")" == "Yes" ]]; then
|
||||
sudo rm -f "/var/lib/pacman/db.lck"
|
||||
echo "Removed /var/lib/pacman/db.lck" | log
|
||||
sudo reboot
|
||||
else
|
||||
echo "User chose not to remove /var/lib/pacman/db.lck" | log
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check for internet connectivity.
|
||||
if ! ping -c1 -W5 f123.org &> /dev/null | dialog --progressbox "$(gettext "Checking internet connection...")" 0 0; then
|
||||
echo "Could not connect to internet" | log
|
||||
infobox "$(gettext "No internet connection detected. Please connect to the internet and try again.")"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for free space in /tmp
|
||||
# Get free size on disk
|
||||
freeSpace=$(df -h --output=avail /tmp | tr -Cd '[:digit:]')
|
||||
if [[ $freeSpace -lt 50 ]]; then
|
||||
echo "Not enough free space on the disk to do updates." | log
|
||||
infobox "$(gettext "There is not enough free space on the disk to update the system.")"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make sure update-f123light is up to date.
|
||||
oldVersion="$(pacman -Qi update-f123light | head -2 | tail -1)"
|
||||
sudo pacman -Sy --noconfirm --needed update-f123light &> /dev/null | dialog --progressbox "Checking to make sure you have the latest version of update-f123light" -1 -1
|
||||
newVersion="$(pacman -Qi update-f123light | head -2 | tail -1)"
|
||||
if [[ "$oldVersion" != "$newVersion" ]]; then
|
||||
echo "update-f123light was updated from version $oldVersion to $newVersion" | log
|
||||
msgbox "A new version of update-f123light has been installed. Please run update-f123light again."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Cleanup just in case there is a temporary file or content repository left behind from a previous update.
|
||||
sudo rm -Rf /tmp/files-F123Light /tmp/content-F123Light
|
||||
|
||||
# Clone the files-F123Light and content-F123Light git repositories.
|
||||
if git clone -q -b $branch --depth 1 https://gitlab.com/f123/files-F123Light.git /tmp/files-F123Light ; then
|
||||
echo "Cloned files-F123Light: $branch" | log
|
||||
else
|
||||
echo "Failed to clone files-F123Light: $branch" | log
|
||||
infobox "$(gettext "Failed to download update files. Please try again later.")"
|
||||
exit 1
|
||||
fi
|
||||
if git clone -q --depth 1 https://gitlab.com/f123/content-F123Light.git /tmp/content-F123Light ; then
|
||||
echo "Cloned content-F123Light." | log
|
||||
else
|
||||
echo "Failed to clone content-F123Light: $branch" | log
|
||||
msgbox "$(gettext "Failed to download content and language improvements. The update process will continue, but language improvements and documentation updates will not be added.")"
|
||||
fi
|
||||
|
||||
|
||||
# Due to the nature of system updates, this script may ask for the user's password more than once.
|
||||
# Try to minimize user fears with a friendly message.
|
||||
echo "All preupgrade checks passed." | log
|
||||
msgbox "$(gettext "The software update process for F123Light will now begin. Depending on how many updates there are, your password might be requested more than once. Do not be alarmed, as this is normal. Press the 'Enter' key to continue, or the escape key to exit.")" || exit 0
|
||||
|
||||
# Perform incremental updates
|
||||
# They are found in scripts/updates.sh in the files-F123Light repository
|
||||
# This file explains how to apply incremental updates, usage, formatting, etc.
|
||||
source /tmp/files-F123Light/scripts/updates.sh | dialog --progressbox "$(gettext "Performing incremental updates...")" -1 -1
|
||||
|
||||
# Clean the package cache.
|
||||
sudo pacman -Sc --noconfirm |& log | dialog --progressbox "$(gettext "Cleaning package cache...")" -1 -1
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "There were problems cleaning the package cache." | log
|
||||
fi
|
||||
# Update all ALARM and F123 maintained packages on the system that are not in the ignore list on public.f123.org.
|
||||
# Track kernel version and prompt for a reboot after if it changes
|
||||
oldKernel="$(uname -r)"
|
||||
oldKernel="${oldKernel%-*}"
|
||||
ignorePkgList="$(curl -Ls public.f123.org/update-f123light/ignorepkg.txt)"
|
||||
if [[ -n "${ignorePkgList}" ]]; then
|
||||
ignorePkgList="--ignore ${ignorePkgList//[[:space:]]/,} "
|
||||
fi
|
||||
yes | sudo pacman -Syu --noconfirm --noprogressbar ${ignorePkgList}|& sudo tee -a "$logFile" | grep -v '\? \[Y/n\]' | dialog --progressbox "$(gettext "Updating system software...")" -1 -1
|
||||
newKernel="$(pacman -Qi linux-raspberrypi | head -2 | tail -1)"
|
||||
newKernel="${newKernel##* }"
|
||||
if [[ "$oldKernel" != "$newKernel" ]]; then
|
||||
reboot="true"
|
||||
echo "The kernel was upgraded from version ${oldKernel%%-*} to version ${newKernel%%-*}" | log
|
||||
fi
|
||||
|
||||
infobox "$(gettext "Updating configuration and other files...")"
|
||||
|
||||
# Copy in the files-F123Light and content-F123Light files.
|
||||
# Only the files under files-F123Light/files/usr should be copied to the system to avoid resetting configs modified by the system menu.
|
||||
# Everything in content-F123Light is always copied.
|
||||
|
||||
shopt -s dotglob
|
||||
sudo cp -a /tmp/files-F123Light/files/usr/* /usr
|
||||
# Update F123Light specific configuration directory.
|
||||
sudo cp -a /tmp/files-F123Light/files/etc/F123-Config/* /etc/F123-Config
|
||||
# /boot is a special case on a Raspberry Pi, as it's an oldschool DOS partition.
|
||||
if uname -m | grep -q armv7 ; then
|
||||
sudo cp -R /tmp/files-F123Light/files/boot/* /boot |& log
|
||||
fi
|
||||
sudo cp -R /tmp/content-F123Light/F123/* /usr/share/doc/F123
|
||||
|
||||
|
||||
if [[ "$reboot" == "true" ]]; then
|
||||
reboot_prompt
|
||||
fi
|
||||
|
||||
msgbox "$(gettext "Update complete.")"
|
||||
|
||||
exit 0
|
249
files/scripts/update-f123light
Executable file
249
files/scripts/update-f123light
Executable file
@ -0,0 +1,249 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2018, F123 Consulting, <information@f123.org>
|
||||
# Copyright 2018, Kyle, <kyle@free2.ml>
|
||||
# Copyright 2018, Storm Dragon, <storm_dragon@linux-a11y.org>
|
||||
#
|
||||
# This 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 3, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# This software 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 package; see the file COPYING. If not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
#
|
||||
#--code--
|
||||
|
||||
# the gettext essentials
|
||||
export TEXTDOMAIN=update-f123light
|
||||
export TEXTDOMAINDIR=/usr/share/locale
|
||||
|
||||
. gettext.sh
|
||||
|
||||
# Import the standard F123Light functions
|
||||
. /usr/lib/F123-includes/script_functions.sh
|
||||
|
||||
# Log writing function
|
||||
log() {
|
||||
while read -r line ; do
|
||||
echo "$line" | sudo tee -a "$logFile" &> /dev/null
|
||||
done
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
# The temporary files downloaded from the F123Light git repositories are no longer needed.
|
||||
# Kill the clones.
|
||||
sudo rm -rfv /var/tmp/files-F123Light /var/tmp/content-F123Light |& log | dialog --clear --progressbox "$(gettext "Cleaning up")" 0 0
|
||||
}
|
||||
|
||||
# Incremental update timestamp function
|
||||
# Determine whether to perform the update that calls this function.
|
||||
# Return false if the time in yymmddhhmm format is not later than /etc/build-timestamp
|
||||
# Otherwise write the new timestamp and return 0 so that the update is performed.
|
||||
# on the calling system.
|
||||
update () {
|
||||
local updateTime="$1"
|
||||
local lastUpdated="$(cat /etc/timestamp-f123light | tr -cd '[:digit:]' 2> /dev/null)"
|
||||
lastUpdated=${lastUpdated:-0}
|
||||
if [[ $updateTime -gt $lastUpdated ]]; then
|
||||
echo -n "$updateTime" | sudo tee /etc/timestamp-f123light &> /dev/null
|
||||
echo "Performed incremental update $updateTime" | log
|
||||
else
|
||||
return 100
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
reboot_prompt () {
|
||||
# Prompt the user to reboot just in case something like the kernel that deserves a reboot has been updated.
|
||||
# We will prompt for a keypress. Enter to reboot, escape to exit the script and return to the shell or calling script.
|
||||
local $key
|
||||
clear
|
||||
key=$(yesno "$(gettext "Your system has been updated. We recommend that you restart your computer. Please press 'Enter' to restart or 'Escape' to finish the update without restarting.")")
|
||||
case $key in
|
||||
"Yes")
|
||||
sudo systemctl reboot
|
||||
;;
|
||||
"No")
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Default files-F123Light git branch to be cloned
|
||||
branch=master
|
||||
|
||||
# test to determine whether to prompt for a reboot, initially false
|
||||
reboot=false
|
||||
|
||||
# Get command line options
|
||||
if ! options=$(getopt -o b:h -l branch:,help, -n "update-f123light" -- "$@"); then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
eval set -- "$options"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-b|--branch)
|
||||
branch="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
cat <<-HELP
|
||||
$(gettext "Usage")
|
||||
$(eval_gettext "\$name [options...]")
|
||||
$(gettext "Options")
|
||||
-h, --help: $(gettext "Print this help message and exit")
|
||||
-b <branch>, --branch=<branch>: $(eval_gettext "Get files from the specified git branch, default: \$branch")
|
||||
HELP
|
||||
exit 0
|
||||
;;
|
||||
(--)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo $(basename $0): $1 $(gettext "not recognized") 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
clear
|
||||
set -Eo pipefail
|
||||
trap cleanup EXIT
|
||||
# Log file name
|
||||
logFile="/var/log/${0##*/}"
|
||||
|
||||
echo "Using branch: $branch" | log
|
||||
# Check if the current user uas sudo privileges.
|
||||
if sudo -v ; then
|
||||
# Initialize logFile.
|
||||
echo "Log for update-f123light. Starting at version $(</etc/timestamp-f123light)" | sudo tee "$logFile" &> /dev/null
|
||||
else
|
||||
infobox "$USER $(gettext "Does not currently have administrator access to this system. Please upgrade with a user that has adminstrator access.")";
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
if [[ "$(whoami)" == "root" ]]; then
|
||||
msgbox "$(gettext "Please do not use root to run updates. If you typed sudo, just type the command instead, e.g. update-f123light, not sudo update-f123light.")"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# See if we can update the system.
|
||||
if [[ -f "/var/lib/pacman/db.lck" ]]; then
|
||||
echo "Found /var/lib/pacman/db.lck" | log
|
||||
if [[ "$(yesno "$(gettext "Your system needs to restart before updates can begin. Would you like to do this now?")")" == "Yes" ]]; then
|
||||
sudo rm -f "/var/lib/pacman/db.lck"
|
||||
echo "Removed /var/lib/pacman/db.lck" | log
|
||||
sudo reboot
|
||||
else
|
||||
echo "User chose not to remove /var/lib/pacman/db.lck" | log
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check for internet connectivity.
|
||||
if ! ping -c1 -W5 f123.org &> /dev/null | dialog --progressbox "$(gettext "Checking internet connection...")" 0 0; then
|
||||
echo "Could not connect to internet" | log
|
||||
infobox "$(gettext "No internet connection detected. Please connect to the internet and try again.")"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for free space in /var/tmp
|
||||
# Get free size on disk
|
||||
freeSpace=$(df --output=avail /var/tmp | tr -Cd '[:digit:]')
|
||||
if [[ $freeSpace -lt 500000 ]]; then
|
||||
echo "Not enough free space on the disk to do updates." | log
|
||||
infobox "$(gettext "There is not enough free space on the disk to update the system.")"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make sure update-f123light is up to date.
|
||||
oldVersion="$(pacman -Qi update-f123light | head -2 | tail -1)"
|
||||
sudo pacman -Sy --noconfirm --needed update-f123light &> /dev/null | dialog --progressbox "Checking to make sure you have the latest version of update-f123light" -1 -1
|
||||
newVersion="$(pacman -Qi update-f123light | head -2 | tail -1)"
|
||||
if [[ "$oldVersion" != "$newVersion" ]]; then
|
||||
echo "update-f123light was updated from version $oldVersion to $newVersion" | log
|
||||
msgbox "A new version of update-f123light has been installed. Please run update-f123light again."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Cleanup just in case there is a temporary file or content repository left behind from a previous update.
|
||||
sudo rm -Rf /var/tmp/files-F123Light /var/tmp/content-F123Light
|
||||
|
||||
# Clone the files-F123Light and content-F123Light git repositories.
|
||||
if git clone -q -b $branch --depth 1 https://gitlab.com/f123/files-F123Light.git /var/tmp/files-F123Light ; then
|
||||
echo "Cloned files-F123Light: $branch" | log
|
||||
else
|
||||
echo "Failed to clone files-F123Light: $branch" | log
|
||||
infobox "$(gettext "Failed to download update files. Please try again later.")"
|
||||
exit 1
|
||||
fi
|
||||
if git clone -q --depth 1 https://gitlab.com/f123/content-F123Light.git /var/tmp/content-F123Light ; then
|
||||
echo "Cloned content-F123Light." | log
|
||||
else
|
||||
echo "Failed to clone content-F123Light: $branch" | log
|
||||
msgbox "$(gettext "Failed to download content and language improvements. The update process will continue, but language improvements and documentation updates will not be added.")"
|
||||
fi
|
||||
|
||||
|
||||
# Due to the nature of system updates, this script may ask for the user's password more than once.
|
||||
# Try to minimize user fears with a friendly message.
|
||||
echo "All preupgrade checks passed." | log
|
||||
msgbox "$(gettext "The software update process for F123Light will now begin. Depending on how many updates there are, your password might be requested more than once. Do not be alarmed, as this is normal. Press the 'Enter' key to continue, or the escape key to exit.")" || exit 0
|
||||
|
||||
# Perform incremental updates
|
||||
# They are found in scripts/updates.sh in the files-F123Light repository
|
||||
# This file explains how to apply incremental updates, usage, formatting, etc.
|
||||
source /var/tmp/files-F123Light/scripts/updates.sh | dialog --progressbox "$(gettext "Performing incremental updates...")" -1 -1
|
||||
|
||||
|
||||
# Copy in the files-F123Light and content-F123Light files.
|
||||
# Only the files under files-F123Light/files/usr should be copied to the system to avoid resetting configs modified by the system menu.
|
||||
# Everything in content-F123Light is always copied.
|
||||
|
||||
shopt -s dotglob
|
||||
(sudo cp -av /var/tmp/files-F123Light/files/usr/* /usr |& log;
|
||||
# Update F123Light specific configuration directory.;
|
||||
sudo cp -av /var/tmp/files-F123Light/files/etc/F123-Config/* /etc/F123-Config |& log;
|
||||
# Update graphical menus.
|
||||
sudo cp -av /var/tmp/files-F123Light/files/etc/mygtkmenu/* /etc/mygtkmenu |& log;
|
||||
# Update skel
|
||||
sudo cp -av /var/tmp/files-F123Light/files/etc/skel/ /etc/ |& log;
|
||||
# update .ratpoisonrc;
|
||||
for i in /home/*/.ratpoisonrc ; do cp -v /var/tmp/files-F123Light/files/etc/skel/.ratpoisonrc $i |& sudo tee -a "$logFile" &> /dev/null; done;
|
||||
# update user orca scripts;
|
||||
for i in /home/*/.local/share/orca/ ; do cp -rv /var/tmp/files-F123Light/files/etc/skel/.local/share/orca/orca-scripts/ $i |& sudo tee -a "$logFile" &> /dev/null; done;
|
||||
# /boot is a special case on a Raspberry Pi, as it's an oldschool DOS partition.;
|
||||
if uname -m | grep -q armv7 ; then
|
||||
sudo cp -R /var/tmp/files-F123Light/files/boot/* /boot |& log;
|
||||
fi;
|
||||
sudo cp -Rv /var/tmp/content-F123Light/F123/* /usr/share/doc/F123 |& log;
|
||||
# Update translations;
|
||||
find /var/tmp/files-F123Light/locales -type f -iname '*.po' -exec bash -c '
|
||||
for i ; do
|
||||
# i is in file, o is outfile.
|
||||
language="$(grep "^\"Language: .*\\n" "${i}" | cut -d " " -f2 | cut -d "\\" -f1)"
|
||||
# Handle exceptions for languages.
|
||||
case "$language" in
|
||||
*) language="${language::2}";;
|
||||
esac
|
||||
o="${i##*/}"
|
||||
o="${o%.po}.mo"
|
||||
msgfmt "$i" -o /usr/share/locale/${language}/LC_MESSAGES/${o}"
|
||||
done' _ {} +;) | dialog --clear --progressbox "$(gettext "Updating configuration and other files...")" 0 0
|
||||
|
||||
if [[ "$reboot" == "true" ]]; then
|
||||
reboot_prompt
|
||||
fi
|
||||
|
||||
infobox "$(gettext "Update complete.")"
|
||||
|
||||
exit 0
|
215
files/scripts/updates.sh
Normal file
215
files/scripts/updates.sh
Normal file
@ -0,0 +1,215 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2018, F123 Consulting, <information@f123.org>
|
||||
# Copyright 2018, Kyle, <kyle@free2.ml>
|
||||
# Copyright 2018, Storm Dragon <storm_dragon@linux-a11y.org>
|
||||
#
|
||||
# This 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 3, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# This software 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 package; see the file COPYING. If not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
#
|
||||
#--code--
|
||||
|
||||
# This is a helper script for update-f123light to perform incremental updates based on a timestamp
|
||||
# It will not be installed to a running system
|
||||
#
|
||||
# Incremental updates are only to be performed if their timestamp is later than
|
||||
# /etc/timestamp-f123light on the system being updated.
|
||||
# Each update should be formatted as
|
||||
#
|
||||
# update yymmddhhmm && {
|
||||
# do-something here;
|
||||
# do-something-else here;
|
||||
# }
|
||||
# If an update requires a reboot, add
|
||||
# reboot=true
|
||||
# anywhere in the update to prompt the user to reboot afterward
|
||||
#
|
||||
# Any new updates should be placed at the end of this file for best readability
|
||||
# It is recommended to skip a line between updates, also for readability
|
||||
# To get the current date and time in the format, use the command
|
||||
# \date '+%y%m%d%H%M'
|
||||
# Remember to add a ; after each line of the update group.
|
||||
|
||||
# Log writing function
|
||||
log() {
|
||||
while read -r line ; do
|
||||
echo "$line" | sudo tee -a "$logFile" &> /dev/null
|
||||
done
|
||||
}
|
||||
|
||||
logFile="/var/log/incremental-updates"
|
||||
# Clear previous logs
|
||||
echo -n | sudo tee "$logFile" &> /dev/null
|
||||
|
||||
|
||||
update 1811072200 && {
|
||||
# Install Pianobar Pandora client on builds last updated before 7 November 2018
|
||||
sudo pacman -S pianobar-git --noconfirm --needed &> /dev/null;
|
||||
}
|
||||
|
||||
update 1811142036 && {
|
||||
sudo pacman -S --noconfirm --needed python-magic-wormhole &> /dev/null;
|
||||
}
|
||||
|
||||
update 1811150406 && {
|
||||
# There has been a change to the pacman repository URL.
|
||||
# Copy the new pacman.conf file to all systems built earlier than 11 November 2018;
|
||||
sudo cp /tmp/files-F123Light/files/etc/pacman.conf /etc;
|
||||
}
|
||||
|
||||
update 1811161939 && {
|
||||
# Install the update-f123light package;
|
||||
sudo pacman -Sy --noconfirm --needed --overwrite /usr/bin/update-f123light update-f123light &> /dev/null;
|
||||
}
|
||||
|
||||
update 1811191827 && {
|
||||
# Blacklist non-working bluetooth module;
|
||||
echo "blacklist btsdio" | sudo tee -a /etc/modules-load.d/bluetooth &> /dev/null;
|
||||
# Disable bluetooth service;
|
||||
sudo systemctl -q disable bluetooth;
|
||||
# Enable new bluetooth service;
|
||||
sudo systemctl -q enable brcm43438.service;
|
||||
# Add RHVoice module to speech-dispatcher;
|
||||
grep -q 'rhvoice.conf' /etc/speech-dispatcher/speechd.conf || sudo sed -i 's/"espeak-mbrola-generic\.conf"/"espeak-mbrola-generic.conf"\n AddModule "rhvoice" "sd_rhvoice" "rhvoice.conf"/' /etc/speech-dispatcher/speechd.conf;
|
||||
# Create placeholder file for RHVoice;
|
||||
echo '# Placeholder for the rhvoice module.' | sudo tee /etc/speech-dispatcher/modules/rhvoice.conf &> /dev/null;
|
||||
}
|
||||
|
||||
update 1811281732 && {
|
||||
# Re-enable the bluetooth service;
|
||||
sudo systemctl -q enable --now bluetooth;
|
||||
# Power on the bluetooth adapter;
|
||||
bluetoothctl power on &> /dev/null;
|
||||
# Put the bluetooth settings file in place;
|
||||
sudo cp /tmp/files-F123Light/files/etc/bluetooth/main.conf /etc/bluetooth/main.conf;
|
||||
# configure speech-dispatcher to use pulseaudio.;
|
||||
sudo sed -i 's/^\s*AudioOutputMethod.*/ AudioOutputMethod pulse/' /etc/speech-dispatcher/speechd.conf;
|
||||
}
|
||||
|
||||
update 1901151236 && {
|
||||
# We will need to reboot after this completes for all the groups and users stuff to take affect, and to get pulse started.;
|
||||
reboot=true;
|
||||
# Create users and groups;
|
||||
sudo groupadd --system pulse &> /dev/null;
|
||||
sudo groupadd --system pulse-access &> /dev/null;
|
||||
sudo useradd --system -g pulse -G audio -d /var/run/pulse -m -s /bin/nologin pulse &> /dev/null;
|
||||
sudo gpasswd -a pulse lp &> /dev/null;
|
||||
sudo gpasswd -a root pulse-access &> /dev/null;
|
||||
for u in $(awk -v OFS=' ' -F':' '{ if ( $3 >= 1000 && $3 <= 60000 && $7 != "/sbin/nologin" && $7 != "/bin/false" ) print $1 ; }' /etc/passwd) ; do sudo gpasswd -a $u pulse-access &> /dev/null;done;
|
||||
# Install new packages;
|
||||
sudo pacman -Sy --noconfirm --needed pulseaudio-bluetooth pulseaudio-alsa &> /dev/null;
|
||||
# move configuration files into place;
|
||||
sudo cp -r /tmp/files-F123Light/files/etc/pulse/ /etc;
|
||||
sudo cp -ru /tmp/files-F123Light/files/etc/dbus-1/ /etc;
|
||||
sudo systemctl -q enable pulseaudio;
|
||||
echo "default_driver=pulse" | sudo tee /etc/libao.conf &> /dev/null
|
||||
}
|
||||
|
||||
|
||||
update 1902200926 && {
|
||||
# Update nano configuration file;
|
||||
sudo cp /tmp/files-F123Light/files/etc/nanorc /etc;
|
||||
# Update Fenrir keyboard layouts;
|
||||
sudo cp -r /tmp/files-F123Light/files/etc/fenrirscreenreader/keyboard /etc/fenrirscreenreader;
|
||||
# Switch from speech-dispatcher-git to the newer stable version 0.9.0;
|
||||
# Remove old unneeded packages.;
|
||||
# To prevent errors, only remove one package per statement;
|
||||
sudo pacman -Rdd --noconfirm brltty &> /dev/null;
|
||||
sudo pacman -Rdd --noconfirm lios-git &> /dev/null;
|
||||
sudo pacman -Rdd --noconfirm python-espeak &> /dev/null;
|
||||
sudo pacman -Rdd --noconfirm speech-dispatcher-git &> /dev/null;
|
||||
# Install new packages.;
|
||||
sudo pacman -Sy --noconfirm --needed brltty-minimal cfh-client irssi speech-dispatcher &> /dev/null;
|
||||
# Copy .pacsave for speech-dispatcher into place.;
|
||||
sudo cp /etc/speech-dispatcher/speechd.conf.pacsave /etc/speech-dispatcher/speechd.conf &> /dev/null;
|
||||
}
|
||||
|
||||
|
||||
update 1903140649 && {
|
||||
# Install the horseshoes package.;
|
||||
sudo pacman -Sy --needed --noconfirm horseshoes-git |& log;
|
||||
# Install tesseract data packages.;
|
||||
sudo pacman -S --needed --noconfirm tesseract-data-{ara,eng,fra,por,spa} |& log;
|
||||
# Update Fenrir keyboard layouts;
|
||||
sudo cp -rv /tmp/files-F123Light/files/etc/fenrirscreenreader/keyboard /etc/fenrirscreenreader |& log;
|
||||
}
|
||||
|
||||
|
||||
update 1903300948 && {
|
||||
# Update nanorc;
|
||||
sudo cp /tmp/files-F123Light/files/etc/nanorc /etc;
|
||||
}
|
||||
|
||||
|
||||
update 1903311817 && {
|
||||
# uninstall python-ipaddress and python-magic-wormhole;
|
||||
sudo pacman -Rdd --noconfirm python-ipaddress python-magic-wormhole |& log;
|
||||
# Install magic-wormhole;
|
||||
sudo pacman -Sy --noconfirm --needed magic-wormhole |& log;
|
||||
}
|
||||
|
||||
|
||||
update 1904030652 && {
|
||||
# uninstall mumble-snapshot, youtube-viewer-git and youtube-dl-git;
|
||||
sudo pacman -Rdd --noconfirm mumble-snapshot |& log;
|
||||
sudo pacman -Rdd --noconfirm youtube-dl-git |& log;
|
||||
sudo pacman -Rdd --noconfirm youtube-viewer-git |& log;
|
||||
# Install barnard;
|
||||
sudo pacman -Sy --noconfirm --needed barnard-git |& log;
|
||||
# Install youtube-dl;
|
||||
sudo pacman -Sy --noconfirm --needed youtube-dl |& log;
|
||||
# Install youtube-viewer;
|
||||
sudo pacman -Sy --noconfirm --needed youtube-viewer |& log;
|
||||
# Fix commented out bookmark 8 in fenrir keyboard layouts.;
|
||||
sudo sed -i 's/^#KEY_FENRIR,KEY_8=bookmark_8/KEY_FENRIR,KEY_8=bookmark_8/' /etc/fenrirscreenreader/keyboard/*.conf;
|
||||
}
|
||||
|
||||
|
||||
update 1904151249 && {
|
||||
# Install nice editor (ne);
|
||||
sudo pacman -Sy --noconfirm --needed ne |& log;
|
||||
# Install dbus-broker;
|
||||
sudo pacman -Sy --noconfirm --needed dbus-broker |& log;
|
||||
# configure dbus-broker for all users;
|
||||
sudo systemctl enable --now dbus-broker.service |& log;
|
||||
sudo systemctl --global enable dbus-broker.service |& log;
|
||||
}
|
||||
|
||||
|
||||
update 1905021427 && {
|
||||
# Keep track of the date so we can set it after systemd breaks it;
|
||||
currentDate="$(date)";
|
||||
# Install systemd packages;
|
||||
sudo pacman -Sy --noconfirm systemd systemd-libs systemd-sysvcompat |& log;
|
||||
# Fix the date so DNS doesn't break.;
|
||||
sudo date -s "$currentDate";
|
||||
}
|
||||
|
||||
|
||||
update 1905061331 && {
|
||||
# Install Dragonfm-git;
|
||||
sudo pacman -Sy --noconfirm --needed dragonfm-git |& log;
|
||||
}
|
||||
|
||||
update 1906122152 && {
|
||||
# Make sure timedatectl is sett to sync time.;
|
||||
sudo timedatectl set-ntp ttrue;
|
||||
}
|
||||
|
||||
update 1907211627 && {
|
||||
# Create dnssec override.;
|
||||
sudo cp -rv /tmp/files-F123Light/files/etc/systemd/resolved.conf.d /etc/systemd/ |& log
|
||||
}
|
||||
|
Reference in New Issue
Block a user