More fixes for update
This commit is contained in:
+5
-5
@@ -48,16 +48,16 @@ else
|
|||||||
git clone https://gitea.federated.computer/david/coredesktop.git ~/.local/share/coredesktop
|
git clone https://gitea.federated.computer/david/coredesktop.git ~/.local/share/coredesktop
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install the refresh and update management scripts to the user's bin
|
|
||||||
mkdir -p ~/.local/bin
|
|
||||||
sudo cp ~/.local/share/coredesktop/refresh ~/.local/bin/refresh
|
|
||||||
sudo cp ~/.local/share/coredesktop/update ~/.local/bin/update
|
|
||||||
|
|
||||||
cd ~/.local/share/coredesktop
|
cd ~/.local/share/coredesktop
|
||||||
|
|
||||||
# Source utility functions (provides install_packages and other helpers)
|
# Source utility functions (provides install_packages and other helpers)
|
||||||
source utils.sh
|
source utils.sh
|
||||||
|
|
||||||
|
# Install the refresh and update management scripts to the user's bin
|
||||||
|
mkdir -p ~/.local/bin
|
||||||
|
install_script ~/.local/share/coredesktop/refresh ~/.local/bin/refresh
|
||||||
|
install_script ~/.local/share/coredesktop/update ~/.local/bin/update
|
||||||
|
|
||||||
# Source the package list (defines SYSTEM_UTILS, DEV_TOOLS, DESKTOP, etc. arrays)
|
# Source the package list (defines SYSTEM_UTILS, DEV_TOOLS, DESKTOP, etc. arrays)
|
||||||
if [ ! -f "packages.conf" ]; then
|
if [ ! -f "packages.conf" ]; then
|
||||||
echo "Error: packages.conf not found!"
|
echo "Error: packages.conf not found!"
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Wrapped in { ...; exit; } so bash reads the whole script up front; install.sh
|
||||||
|
# replaces this file while it runs.
|
||||||
|
{
|
||||||
|
|
||||||
# Print the logo
|
# Print the logo
|
||||||
print_logo() {
|
print_logo() {
|
||||||
cat << "EOF"
|
cat << "EOF"
|
||||||
@@ -21,3 +25,5 @@ clear
|
|||||||
print_logo
|
print_logo
|
||||||
|
|
||||||
bash ~/.local/share/coredesktop/install.sh
|
bash ~/.local/share/coredesktop/install.sh
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,16 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# The whole script is wrapped in { ...; exit; } so bash parses all of it before
|
||||||
|
# running anything. That way, replacing this file mid-run (e.g. by git pull and
|
||||||
|
# the copy below) can't make the running copy read a mix of old and new text.
|
||||||
|
{
|
||||||
|
|
||||||
|
# Install a script atomically (copy to a temp file, then rename over the target)
|
||||||
|
install_script() {
|
||||||
|
local tmp
|
||||||
|
tmp="$(mktemp "$2.XXXXXX")" && cp "$1" "$tmp" && chmod 755 "$tmp" && mv -f "$tmp" "$2"
|
||||||
|
}
|
||||||
|
|
||||||
# Print the logo
|
# Print the logo
|
||||||
print_logo() {
|
print_logo() {
|
||||||
cat << "EOF"
|
cat << "EOF"
|
||||||
@@ -28,9 +39,8 @@ if [[ -z "$UPDATE_REEXECED" ]] && ! git -C "$COREDESKTOP" pull; then
|
|||||||
export UPDATE_PULL_FAILED=1
|
export UPDATE_PULL_FAILED=1
|
||||||
fi
|
fi
|
||||||
mkdir -p "$COREDESKTOP/updates.d"
|
mkdir -p "$COREDESKTOP/updates.d"
|
||||||
# --remove-destination replaces copies left root-owned by older versions of this script
|
install_script "$COREDESKTOP/update" ~/.local/bin/update
|
||||||
cp --remove-destination "$COREDESKTOP/update" ~/.local/bin/update
|
install_script "$COREDESKTOP/refresh" ~/.local/bin/refresh
|
||||||
cp --remove-destination "$COREDESKTOP/refresh" ~/.local/bin/refresh
|
|
||||||
|
|
||||||
if [[ -z "$UPDATE_REEXECED" ]]; then
|
if [[ -z "$UPDATE_REEXECED" ]]; then
|
||||||
export UPDATE_REEXECED=1
|
export UPDATE_REEXECED=1
|
||||||
@@ -63,3 +73,5 @@ if (( ${#FAILED[@]} > 0 )); then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Done."
|
echo "Done."
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,14 +2,16 @@
|
|||||||
|
|
||||||
COREDESKTOP="$HOME/.local/share/coredesktop"
|
COREDESKTOP="$HOME/.local/share/coredesktop"
|
||||||
|
|
||||||
|
source "$COREDESKTOP/utils.sh"
|
||||||
|
|
||||||
if [ -f ~/.local/bin/coreupdate ]; then
|
if [ -f ~/.local/bin/coreupdate ]; then
|
||||||
echo "Migrating coreupdate -> update..."
|
echo "Migrating coreupdate -> update..."
|
||||||
cp --remove-destination "$COREDESKTOP/update" ~/.local/bin/update
|
install_script "$COREDESKTOP/update" ~/.local/bin/update
|
||||||
sudo rm -f ~/.local/bin/coreupdate
|
sudo rm -f ~/.local/bin/coreupdate
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f ~/.local/bin/corerefresh ]; then
|
if [ -f ~/.local/bin/corerefresh ]; then
|
||||||
echo "Migrating corerefresh -> refresh..."
|
echo "Migrating corerefresh -> refresh..."
|
||||||
cp --remove-destination "$COREDESKTOP/refresh" ~/.local/bin/refresh
|
install_script "$COREDESKTOP/refresh" ~/.local/bin/refresh
|
||||||
sudo rm -f ~/.local/bin/corerefresh
|
sudo rm -f ~/.local/bin/corerefresh
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -72,3 +72,10 @@ enable_services() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Install a script atomically (copy to a temp file, then rename over the target)
|
||||||
|
# so a copy of it that is running right now keeps reading the old file
|
||||||
|
install_script() {
|
||||||
|
local tmp
|
||||||
|
tmp="$(mktemp "$2.XXXXXX")" && cp "$1" "$tmp" && chmod 755 "$tmp" && mv -f "$tmp" "$2"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user