Skip to content

Instantly share code, notes, and snippets.

@paperclip
Last active August 12, 2020 06:47
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save paperclip/7892031 to your computer and use it in GitHub Desktop.
Save paperclip/7892031 to your computer and use it in GitHub Desktop.
Talpa autodeploy script
#!/bin/bash
set -o pipefail
[[ -n "$WORKING_DIR" ]] || WORKING_DIR="$1"
[[ -n "$WORKING_DIR" ]] || WORKING_DIR=$(pwd)
function failure()
{
echo "$@"
exit 2
}
mkdir -p "$WORKING_DIR" || failure "Unable to create working directory $WORKING_DIR: $?"
cd "$WORKING_DIR"
function gitupdate()
{
git pull 2>&1 | tee git.log || failure "Unable to pull with git"
grep "Already up-to-date." git.log >/dev/null
}
function p4update()
{
P4=p4
[[ -x /opt/perforce/bin/p4 ]] && P4=/opt/perforce/bin/p4
"$P4" sync 2>&1 | tee perforce.log || failure "Unable to sync to perforce"
grep 'File(s) up-to-date' perforce.log >/dev/null
}
[[ -f configure ]] || FORCE=1
[[ -f .p4options ]] && P4CONFIG=.p4options
[[ -f P4CONFIG ]] && P4CONFIG=P4CONFIG
[[ -f .p4config ]] && P4CONFIG=.p4config
if [[ -d .git ]]
then
gitupdate && { [[ $FORCE -eq 1 ]] || exit 77 ; }
elif [[ -n "${P4CONFIG}" ]]
then
export P4CONFIG
p4update && { [[ $FORCE -eq 1 ]] || exit 77 ; }
else
git clone https://github.com/sophos/talpa.git . -b perforce --depth 20 || failure "Unable to clone git repository"
fi
## Got an update
[[ -f configure ]] || ./bootstrap || failure "Unable to bootstrap"
[[ -f makefile ]] || ./configure --disable-talpa-build --enable-maintainer-mode || failure "Unable to configure"
make talpa-srcpack.tar.gz || failure "Unable to build Talpa srcpack"
[[ -n "$INST" ]] || INST=/opt/sophos-av
if [[ -d "$INST" ]]
then
cp -v talpa-srcpack.tar.gz $INST/talpa/override/ || failure "Unable to copy talpa-srcpack.tar.gz to $INST/talpa/override/"
$INST/engine/talpa_select select || failure "Unable to do talpa_select select"
$INST/bin/savdctl disable || failure "Unable to disable on-access"
sleep 2
$INST/bin/savdctl enable || failure "Unable to enable on-access"
fi
exit 0
@paperclip
Copy link
Author

To use this, download the script to e.g. /root/autodeploy.sh

Then run /bin/bash /root/autodeploy.sh /root/talpa

Then add to crontab e.g.:
34 0 * * * /bin/bash /root/autodeploy.sh /root/talpa

@jamie-marchant
Copy link

Thanks, worked perfectly. Now I have 'Talpa' on a new kernel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment