Fix script

This commit is contained in:
Austen Adler 2019-10-26 23:32:34 -04:00
parent ef47f7183e
commit 8a6bf95e36
2 changed files with 10 additions and 3 deletions

View File

@ -1,6 +1,7 @@
= Android Borgmatic Setup = Android Borgmatic Setup
== Installation == Installation
.... ....
apt-get update
apt-get install -y wget apt-get install -y wget
wget https://gitea.austenwares.com/stonewareslord/android-borgmatic-setup/archive/master.tar.gz wget https://gitea.austenwares.com/stonewareslord/android-borgmatic-setup/archive/master.tar.gz
tar -xf master.tar.gz tar -xf master.tar.gz
@ -9,5 +10,5 @@ cd android-borgmatic-setup
.... ....
.... ....
apt-get install -y wget && wget https://gitea.austenwares.com/stonewareslord/android-borgmatic-setup/archive/master.tar.gz && tar -xf master.tar.gz && cd android-borgmatic-setup && ./init.sh apt-get update && apt-get install -y wget && wget https://gitea.austenwares.com/stonewareslord/android-borgmatic-setup/archive/master.tar.gz && tar -xf master.tar.gz && cd android-borgmatic-setup && ./init.sh
.... ....

10
init.sh
View File

@ -12,13 +12,15 @@ die() {
exit 1 exit 1
} }
install_requirements() { install_requirements() {
termux-setup-storage
LAST_UPDATE="$(stat -c %Y /data/data/com.termux/files/usr/var/cache/apt/pkgcache.bin)" LAST_UPDATE="$(stat -c %Y /data/data/com.termux/files/usr/var/cache/apt/pkgcache.bin)"
NOW="$(date +%s)" NOW="$(date +%s)"
if ((NOW - LAST_UPDATE > 60 * 60 * 24)); then if ((NOW - LAST_UPDATE > 60 * 60 * 24)); then
apt-get update apt-get update
fi fi
apt-get upgrade -y apt-get upgrade -y
apt-get install -y python screen wget openssh apt-get install -y python screen wget openssh clang
if ! command -v borgmatic 2>/dev/null || ! command -v borg 2>/dev/null; then if ! command -v borgmatic 2>/dev/null || ! command -v borg 2>/dev/null; then
get_debs get_debs
@ -28,6 +30,10 @@ install_requirements() {
if [[ ! -e ~/.ssh/id_ed25519 ]]; then if [[ ! -e ~/.ssh/id_ed25519 ]]; then
ssh-keygen -t ed25519 -N '' -f ~/.ssh/id_ed25519 ssh-keygen -t ed25519 -N '' -f ~/.ssh/id_ed25519
fi fi
if ! command -v borgmatic; then
pip3 install borgmatic
fi
} }
get_debs() { get_debs() {
wget "$DEBS_URL" -O "$DEBS_FNAME" wget "$DEBS_URL" -O "$DEBS_FNAME"
@ -64,7 +70,7 @@ install_templates() {
mkdir -p "$HOME/.config/borgmatic" mkdir -p "$HOME/.config/borgmatic"
cp "$SCRIPT_DIR/config.yaml" "$BORGMATIC_CONFIG_FILE" cp "$SCRIPT_DIR/config.yaml" "$BORGMATIC_CONFIG_FILE"
set -x set +x
replace "$BORGMATIC_CONFIG_FILE" REPO "user@files:$(hostname)" "What is your repository?" replace "$BORGMATIC_CONFIG_FILE" REPO "user@files:$(hostname)" "What is your repository?"
replace "$BORGMATIC_CONFIG_FILE" CROSS_FILESYSTEM "true" "Cross filesystem?" replace "$BORGMATIC_CONFIG_FILE" CROSS_FILESYSTEM "true" "Cross filesystem?"
replace "$BORGMATIC_CONFIG_FILE" REMOTE_PATH "borg1" "Remote borg command?" replace "$BORGMATIC_CONFIG_FILE" REMOTE_PATH "borg1" "Remote borg command?"