# Sample configuration file
# Except for the DEVICE_IP, these are the settings used by default.
# To override them, copy this file to "config" and adjust it to your needs.
# Of course you can ommit (remove/comment out) settings which do not differ from yours
# (e.g. have your "config" file only holding the DEVICE_IP)
# For a detailed description, please refer to the corresponding Wiki page:
# https://codeberg.org/izzy/Adebar/wiki/Configuration

# ------------------------=[ directories ]=--
# base below which all output (scripts and real backups) are placed
STORAGE_BASE=
# where to place the "real backups" (relative to "${STORAGE_BASE}/${OUTDIR}")
USERDIR="userApps"
SYSDIR="sysApps"
PARTBACKUPDIR="images"
# documentary files can have their own place (again, relative to "${STORAGE_BASE}/${OUTDIR}")
DOCDIR="docs"
# similar for pulled configuration files
CONFDIR="conf"
# and for data pulled, e.g. SMS
DATADIR="data"
# where Adebar stores information between runs, e.g. app names
CACHEDIR=""
# additional cache dirs for Bloatware and other pre-installed stuff (space separated list
# of directories relative to $CACHEDIR/appnames/ – directory names may NOT contain spaces
# APPCACHESPLUS="sysApps/Android sysApps/Google sysApps"
APPCACHESPLUS=""
# base dir for transfers (install, push files, etc.
TRANSFER_DIR=""

# -------------------=[ device specifics ]=--
# Serial of the device. Useful when multiple devices are connected.
#SERIAL="1234567890ABCDEF"
# Give you device a name you can understand
DEVICE_NAME="MyDroid"
# If you set up encryption for backups enter your password here, so
# automatically confirmed backups will work.
# Remember, this is plain text!!! Also: spaces in passwords currently don't work
BACKUP_PASSWORD=""

# ---------------------=[ TiBu specifics ]=--
# IP of the Android device
DEVICE_IP="192.168.101.111"
# port the built-in TiBu web server listens to
TIBU_PORT="8080"
# URL path to the pull-able stuff
TIBU_SDINT="/storage/INTERNAL/Storage-ALL.zip"
TIBU_SDEXT="/storage/SAMSUNG_EXT_SD_CARD/Storage-ALL.zip"
TIBU_BACKUPS="/TitaniumBackup-ALL.zip"

# ---------------------------=[ Features ]=--
# 1=enabled, 0=disabled; whether to ...
# create a script to "freeze/disable" apps
MK_APPDISABLE=1
# create a script to enable all apps
MK_APPENABLE=1
# create the script to backup user apps+data / system app-data
MK_USERBACKUP=1
MK_SYSBACKUP=1
# in case the backup script was aborted and you are want to start backup at aborted point and keep already backed up files (not rewriting existing .ab files)
SKIP_EXISTING_USERBACKUP=0
SKIP_EXISTING_SYSBACKUP=0
RETRY_FAILED_BACKUPS=0
# Whether to backup 'shared storage' (i.e. contents of the SD card(s)) without prompt?
AUTO_BACKUP_SHARED=0
# on running the restore scripts for apps, what delay should be between two apps?
# p = "prompt", 0..99 = delay in seconds
MK_APPRESTORE_DELAY=p
# Similarly, when using AUTO_CONFIRM, specify the delay in seconds
MK_AUTOCONFIRM_DELAY=3
# If the default auto-confirm sequence (22 23) doesn't work for you, specify a different one. Here's e.g. what the Xiaomi Mi8 wants:
MK_AUTOCONFIRM_SEQUENCE=(61 61 61 66)
# Optionally, if your device requires a different sequence for restore (again the Xiaomi Mi8) – leave empty/untouched otherwise:
MK_AUTOCONFIRM_SEQUENCE_2=(61 61 66)
# trigger an export from XPosed and pull it. Requires XPrivacy PRO key.
MK_XPRIVACY_EXPORT=0
# pull the XPrivacy databases when found (not contained in adb backup; root required)
MK_XPRIVACY_PULL=0
# pull settings/configs from the device
PULL_SETTINGS=1
# pull data (e.g. SMS)
PULL_DATA=1
# create the script to pull stuff from the TiBu web server
MK_TIBU=0
# process package information via dumpsys and generate userApps.md/sysApps.md/uninstApps.md
MK_DEFAULTAPPS=1
MK_USERAPPS=1
MK_SYSAPPS=0
MK_SYSAPPS_RETRIEVE_NAMES=0
MK_DISAPPS=1
MK_UNINSTAPPS=1
# deal with the default-install-location (where apps should be installed)
MK_INSTALLLOC=1
# Create deviceInfo.md
MK_DEVICEINFO=1
# Include sensor stats? (takes a little, and is not supported by all devices)
MK_DEVICEINFO_SENSORS=1
# Include details from 'pm list features'? Looks a bit cryptic, and you might not feel it useful ;)
MK_DEVICEINFO_PMLISTFEATURES=1
# Include device status (e.g. battery status)?
MK_DEVICEINFO_STATUS=1
# Include device policy details (device admins)? Can get quite long on Samsung devices ;)
MK_DEVICEINFO_DEVICEPOLICY=0
# Show details on the "mobile radio" (SIM etc)? You'll want to turn this off e.g. for your WiFi-only tablet.
MK_RADIO=1
# Partition details for device doc and backup script
MK_PARTINFO=1
MK_PARTBACKUP=0
PARTITION_SRC="auto" # auto|mtd|emmc|byname|parts



# -------------------=[ UserApp Specials ]=--
# Name the app install sources how you want them to be displayed
APP_INSTALL_SRC[org.fdroid.fdroid]="F-Droid"
APP_INSTALL_SRC[com.machiav3lli.fdroid]="Neo Store"
APP_INSTALL_SRC[cm.aptoide.pt]="Aptoide"
APP_INSTALL_SRC[com.android.vending]="Google Play"
APP_INSTALL_SRC[com.google.android.feedback]="Google Play (Feedback)"
APP_INSTALL_SRC[com.aurora.store]="Aurora Store"
# Link to their respective markets
APP_MARKET_URL[org.fdroid.fdroid]="https://f-droid.org/repository/browse/?fdid=%s"
APP_MARKET_URL[com.machiav3lli.fdroid]="https://f-droid.org/packages/%s"
APP_MARKET_URL[com.android.vending]="https://play.google.com/store/apps/details?id=%s"
APP_MARKET_URL[com.google.android.feedback]="https://play.google.com/store/apps/details?id=%s"
APP_MARKET_URL[com.aurora.store]="https://play.google.com/store/apps/details?id=%s"
APP_MARKET_URL[unknown]=""


# -------------------------------=[ Misc ]=--
# Show progress in terminal (0=disabled, 1..3 are verbosity levels)
PROGRESS=1
# Use ANSI sequences on terminal (to highlight text)?
USE_ANSI=1
# Use separate subdirs on each run?
TIMESTAMPED_SUBDIRS=0
# If TIMESTAMPED_SUBDIRS, do we want a symlink point to the latest one?
LINK_LATEST_SUBDIR=0
# If TIMESTAMPED_SUBDIRS, how many generations to keep (0=all)?
KEEP_SUBDIR_GENERATIONS=0
# Script to call when finished (leave empty for none)
POSTRUN_CMD=""
# Script to call for retrieving app names
APPNAME_CMD=""
# If your device is rooted, but the ADB daemon does not run in root mode, set this to 1
ROOT_COMPAT=0
# Run "pm disable" and "pm enable" command as root?
ROOT_PMDISABLE=0
# Shall we use root_appbackup/root_apprestore instead of "adb backup"?
ROOT_BACKUP=0
# Wether backups should be automatically confirmed via keypresses send with adb
# (set to 1 to enable)
AUTO_CONFIRM=1
# Shall Adebar try to automatically unlock your device when running your
# backup/restore script? Doesn't work with all devices/ROMs, and requires
# that no password/pin/pattern is set.
AUTO_UNLOCK=1
# Use a fixed location for the Bash interpreter (instead of having it auto-evaluated)
# BASH_LOCATION="/bin/bash"
# Where to link wiki references to. If you run a local mirror of the Adebar repo
# (e.g. using Gitea), you can point it there.
WIKI_BASE="https://codeberg.org/izzy/Adebar/wiki"

# ------------=[ Example postrun function ]=--
# to avoid possible collisions with functions defined by Adebar itself, use
# the "uf_" ("user function") prefix for your own functions
# This example function glues the files from the created doc/ directory
# to one file in your web tree, the file name based on your DEVICE_NAME
# setting, using the default templates shipping with Adebar (make sure to
# adjust WEBDIR and TPLDIR accordingly when using this):
uf_postrun() {
  local WEBDIR="/var/www/docs"
  local TPLDIR="/home/johnny/adebar/templates/default"
  cp "${TPLDIR}/head.html" "${WEBDIR}/${DEVICE_NAME}.md"
  sed -i "s/__DEVICE_NAME__/${DEVICE_NAME}/" "${WEBDIR}/${DEVICE_NAME}.md"
  sed -i "s/__DATE__/$(date +'%Y-%m-%d')/" "${WEBDIR}/${DEVICE_NAME}.md"
  echo >> "${WEBDIR}/${DEVICE_NAME}.md"
  cat "${TPLDIR}/tocopen.html" >> "${WEBDIR}/${DEVICE_NAME}.md"
  cat "${OUTDIR}/docs/deviceInfo.head" >> "${WEBDIR}/${DEVICE_NAME}.md"
  cat "${OUTDIR}/docs/apps.head" >> "${WEBDIR}/${DEVICE_NAME}.md"
  cat "${TPLDIR}/tocclose.html" >> "${WEBDIR}/${DEVICE_NAME}.md"
  echo >> "${WEBDIR}/${DEVICE_NAME}.md"
  cat "${OUTDIR}/docs/deviceInfo.md" >> "${WEBDIR}/${DEVICE_NAME}.md"
  echo >> "${WEBDIR}/${DEVICE_NAME}.md"
  echo "<h1 id='apps'>Apps</h1>" >> "${WEBDIR}/${DEVICE_NAME}.md"
  [[ -f "${OUTDIR}/docs/defaultApps.md" ]] && {
    echo >> "${WEBDIR}/${DEVICE_NAME}.md"
    cat "${OUTDIR}/docs/defaultApps.md" >> "${WEBDIR}/${DEVICE_NAME}.md"
  }
  cat "${OUTDIR}/docs/userApps.md" >> "${WEBDIR}/${DEVICE_NAME}.md"
  [[ -f "${OUTDIR}/docs/sysApps.md" ]] && {
    echo >> "${WEBDIR}/${DEVICE_NAME}.md"
    cat "${OUTDIR}/docs/sysApps.md" >> "${WEBDIR}/${DEVICE_NAME}.md"
  }
  [[ -f "${OUTDIR}/docs/disApps.md" ]] && {
    echo >> "${WEBDIR}/${DEVICE_NAME}.md"
    cat "${OUTDIR}/docs/disApps.md" >> "${WEBDIR}/${DEVICE_NAME}.md"
  }
  [[ -f "${OUTDIR}/docs/uninstApps.md" ]] && {
    echo >> "${WEBDIR}/${DEVICE_NAME}.md"
    cat "${OUTDIR}/docs/uninstApps.md" >> "${WEBDIR}/${DEVICE_NAME}.md"
  }
  cat "${TPLDIR}/foot.html" >> "${WEBDIR}/${DEVICE_NAME}.md"
  mv "${WEBDIR}/${DEVICE_NAME}.md" "${WEBDIR}/${DEVICE_NAME}.html"
  cp "${TPLDIR}/adebar.css" "${WEBDIR}"
}

# --=[ Example function to retrieve app names ]=--
# This example function tries to get the app name from Google Playstore
# by scraping the corresponding web page (Playstore has the app name
# in the page's TITLE attribute). To use this, set APPNAME_CMD="uf_getAppname"
uf_getAppname() {
  URL="https://play.google.com/store/apps/details?id=$1"
  RSTRIP=" - Android-Apps"
  LSTRIP="A Better"
  TITLE=$(wget --quiet -O - $URL | sed -n -e 'H;${x;s!.*<head[^>]*>\(.*\)</head>.*!\1!;tnext};b;:next;s!.*<title[^>]*>\(.*\)</title>.*!\1!p')
  TITLE="${TITLE%%${RSTRIP}*}"
  if [[ -n "${TITLE}" ]]; then
    echo "${TITLE}"
  else
    echo "$1"
  fi
}
