added my_syspatch.sh

master
Pratham Patel 3 months ago
commit bc5c333cf4

@ -0,0 +1,44 @@
#!/usr/bin/env bash
OPENBSD_VERSION=$(uname -r)
DOWNLOAD_URL="https://cdn.openbsd.org/pub/OpenBSD/${OPENBSD_VERSION}/"
FILES_TO_DOWNLOAD=("src.tar.gz" "sys.tar.gz" "SHA256.sig")
MY_SYSPATCH_DIR=/root/syspatch_dir
FILE_1_EXTRACTED=0
FILE_2_EXTRACTED=0
if [ ! -d $MY_SYSPATCH_DIR ]
then
mkdir $MY_SYSPATCH_DIR
else
cd $MY_SYSPATCH_DIR
fi
# for each file, download it if it doesn't exist
for INDV_FILE in ${FILES_TO_DOWNLOAD[@]}
do
FILE_URL=${DOWNLOAD_URL}${INDV_FILE}
FILE_PATH=${MY_SYSPATCH_DIR}/${INDV_FILE}
if [ ! -f $FILE_PATH ]
then
echo "Downloading $INDV_FILE"
wget -q ${FILE_URL} -O $FILE_PATH
fi
done
if [ FILE_1_EXTRACTED -eq 0 ]
then
signify -C -p /etc/signify/openbsd-$(uname -r | sed 's/\.//')-base.pub -x ${FILES_TO_DOWNLOAD[2]} ${FILES_TO_DOWNLOAD[0]} && tar -xzf ${FILES_TO_DOWNLOAD[0]} && FILE_1_EXTRACTED=1
rm ${FILES_TO_DOWNLOAD[0]}
fi
if [ FILE_2_EXTRACTED -eq 0 ]
then
signify -C -p /etc/signify/openbsd-$(uname -r | sed 's/\.//')-base.pub -x ${FILES_TO_DOWNLOAD[2]} ${FILES_TO_DOWNLOAD[1]} && tar -xzf ${FILES_TO_DOWNLOAD[0]} && FILE_2_EXTRACTED=1
rm ${FILES_TO_DOWNLOAD[1]}
fi
Loading…
Cancel
Save