Skip to content

Commit

Permalink
more robust unzip, use strip-components
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Sep 17, 2024
1 parent d056446 commit 2639c48
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions pioreactor/cli/pio.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ def update_app(
commands_and_priority.extend(
[
(f"sudo rm -rf {tmp_rls_dir}", -99),
(f"unzip {source} -d {tmp_rls_dir}", 0),
(f"unzip {tmp_rls_dir}/wheels_{version_installed}.zip -d {tmp_rls_dir}/wheels", 1),
(f"unzip -o {source} -d {tmp_rls_dir}", 0),
(f"unzip -o {tmp_rls_dir}/wheels_{version_installed}.zip -d {tmp_rls_dir}/wheels", 1),
(f"sudo bash {tmp_rls_dir}/pre_update.sh", 2),
(f"sudo bash {tmp_rls_dir}/update.sh", 4),
(f"sudo bash {tmp_rls_dir}/post_update.sh", 20),
Expand Down
6 changes: 4 additions & 2 deletions pioreactor/cli/pios.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,14 @@ def cp(
units: tuple[str, ...],
y: bool,
) -> None:
units = remove_leader(universal_identifier_to_all_workers(units))

if not y:
confirm = input(f"Confirm copying {filepath} onto {units}? Y/n: ").strip()
if confirm != "Y":
raise click.Abort()

logger = create_logger("cp", unit=get_unit_name(), experiment=UNIVERSAL_EXPERIMENT)
units = remove_leader(universal_identifier_to_all_workers(units))

def _thread_function(unit: str) -> bool:
logger.debug(f"Copying {filepath} to {unit}:{filepath}...")
Expand All @@ -219,14 +220,15 @@ def rm(
units: tuple[str, ...],
y: bool,
) -> None:
logger = create_logger("rm", unit=get_unit_name(), experiment=UNIVERSAL_EXPERIMENT)
units = remove_leader(universal_identifier_to_all_workers(units))

if not y:
confirm = input(f"Confirm deleting {filepath} on {units}? Y/n: ").strip()
if confirm != "Y":
raise click.Abort()

logger = create_logger("rm", unit=get_unit_name(), experiment=UNIVERSAL_EXPERIMENT)

def _thread_function(unit: str) -> bool:
try:
logger.debug(f"deleting {unit}:{filepath}...")
Expand Down
2 changes: 1 addition & 1 deletion update_scripts/upcoming/scripts/update_ui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ trap finish EXIT

# unpack source provided
tar -xzf "$SRC_TAR" -C $TEMP_DIR
WORK_DIR=$(find "$TEMP_DIR" -mindepth 1 -maxdepth 1 -type d) # get the directory inside the archive, name is not predictable.
WORK_DIR=$(find "$TEMP_DIR" -mindepth 1 -maxdepth 1 -type d) # get the directory inside the archive, name is not predictable. TODO: I think I can use --strip-components for this...

echo $WORK_DIR
# Verify that WORK_DIR is valid
Expand Down
1 change: 0 additions & 1 deletion update_scripts/upcoming/services/create_diskcache.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ After=network.target firstboot.service
Before=lighttpd.service huey.service

[Service]
User=pioreactor
ExecStart=/bin/bash /usr/local/bin/create_diskcache.sh
ExecStartPost=pio log -m "%n successful" -n systemd --local-only
Type=oneshot
Expand Down
22 changes: 10 additions & 12 deletions update_scripts/upcoming/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export LC_ALL=C
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

UI_FOLDER=/var/www/pioreactorui
SYSTEMD_DIR=/lib/systemd/system/
UI_TAG="24.9.16" # TODO
SYSTEMD_DIR=/etc/systemd/system/
UI_TAG="24.9.17" # TODO
PIO_DIR="/home/pioreactor/.pioreactor"

HOSTNAME=$(hostname)
Expand All @@ -20,14 +20,14 @@ LEADER_HOSTNAME=$(crudini --get "$PIO_DIR"/config.ini cluster.topology leader_ho
if [ "$HOSTNAME" != "$LEADER_HOSTNAME" ]; then
# worker updates

# install pioreactorui
rm -rf $UI_FOLDER
mkdir -p /var/www
# clean up from previous
rm -rf $UI_FOLDER/*
rm -rf /tmp/pioreactorui_cache/


tar -xzf "$SCRIPT_DIR"/pioreactorui_"$UI_TAG".tar.gz
mv pioreactorui-"$UI_TAG" /var/www
mv /var/www/pioreactorui-"$UI_TAG" $UI_FOLDER
# install pioreactorui
mkdir -p "$UI_FOLDER"
tar -xzf "$SCRIPT_DIR"/pioreactorui_"$UI_TAG".tar.gz -C "$UI_FOLDER" --strip-components=1

# init .env
mv $UI_FOLDER/.env.example $UI_FOLDER/.env
Expand All @@ -47,7 +47,7 @@ if [ "$HOSTNAME" != "$LEADER_HOSTNAME" ]; then
chmod +x $UI_FOLDER/main.fcgi

# install lighttp and set up mods
unzip "$SCRIPT_DIR"/lighttpd_packages.zip -d "$SCRIPT_DIR"/lighttpd_packages
unzip -o "$SCRIPT_DIR"/lighttpd_packages.zip -d "$SCRIPT_DIR"/lighttpd_packages
sudo chown -R pioreactor:pioreactor "$SCRIPT_DIR"/lighttpd_packages # required so this can be deleted by pioreactor user if needed to run again.
dpkg -i "$SCRIPT_DIR"/lighttpd_packages/*.deb

Expand Down Expand Up @@ -77,8 +77,6 @@ if [ "$HOSTNAME" != "$LEADER_HOSTNAME" ]; then
lighttpd -h
flask --help



# we need to restart the monitor jobs on the worker so that the new table (pio_job_metadata) and db exist first
systemctl restart [email protected]
sleep 5
Expand All @@ -91,7 +89,7 @@ if [ "$HOSTNAME" != "$LEADER_HOSTNAME" ]; then
systemctl start lighttpd.service
systemctl start huey.service

sleep 1
sleep 2

# test:
curl -LI localhost/unit_api/jobs/running
Expand Down

0 comments on commit 2639c48

Please sign in to comment.