24 lines
802 B
Bash
Executable file
24 lines
802 B
Bash
Executable file
#!/usr/bin/env bash
|
|
set -e;
|
|
|
|
source="/home/ci/sftp-root/apt-packages";
|
|
destination="/srv/aptosaurus/sources";
|
|
aptosaurus="/srv/aptosaurus/aptosaurus.sh";
|
|
|
|
HOME="$(dirname "${aptosaurus}")";
|
|
export HOME;
|
|
|
|
# The user account to chown to & run aptosaurus under
|
|
# FUTURE: Use own account? Is it worth it for a cron job?
|
|
user_account="daemon";
|
|
|
|
# Locate & move the .deb files into place
|
|
find "${source}" -type f -name "*.deb" -print0 | xargs -I{} --null mv "{}" "${destination}";
|
|
|
|
# chown them to the right user account
|
|
chown -R "${user_account}:${user_account}" "${destination}";
|
|
|
|
# Re-run aptosaurus
|
|
aptosaurus_dir="$(dirname "${aptosaurus}")";
|
|
cd "${aptosaurus_dir}" || { echo "Failed to cd into aptosaurus directory"; exit 1; };
|
|
sudo -u "${user_account}" bash "$(basename "${aptosaurus}")" update-cron;
|