Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix errors in moved venvs #138

Merged
merged 2 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/modules/postrename/config
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
####
# shellcheck disable=all

# Intentionaly left blank
# Intentionally left blank
12 changes: 12 additions & 0 deletions src/modules/postrename/filesystem/root/postrename
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,20 @@ function relocate_venv {
venvs=(klippy-env moonraker-env)

for venv in "${venvs[@]}"; do
# Move venv
sudo -u "${DEFAULT_USER}" \
virtualenv --relocatable -p /usr/bin/python3 "/home/${DEFAULT_USER}/${venv}"

# delete pycache (*.pyc files)
find "/home/${DEFAULT_USER}/${venv}" -name "__pycache__" -type d -exec rm -rf {} +

# repair shebangs
while IFS= read -r file ; do

sed -i 's|pi/'"${venv}"'|'"${DEFAULT_USER}"'/'"${venv}"'|g' "${file}"

done < <(grep -iR "pi/${venv}" "/home/${DEFAULT_USER}/${venv}"/* | cut -d":" -f1)

done
}

Expand Down