diff --git a/backup/archive_repos/_lib/colors.sh b/backup/archive_repos/_lib/colors.sh new file mode 100644 index 0000000..fe35ef5 --- /dev/null +++ b/backup/archive_repos/_lib/colors.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +# Sourced colors +# ------------------------------------------------------------------------------ + +#source ./lib/c/base.sh + +# UI colors +# ------------------------------------------------------------------------------ +ui_base="${ff_lightpurple_bg}" +ui_accent_light="${ff_lightpurple}" +ui_accent_dark="${ff_darkpurple}" +ui_text_normal="" +ui_text_muted="${ff_lightgrey}" +ui_dialog_bg="${ff_darkgrey_02_bg}" diff --git a/backup/archive_repos/_lib/config.sh b/backup/archive_repos/_lib/config.sh new file mode 100755 index 0000000..cd5ed9a --- /dev/null +++ b/backup/archive_repos/_lib/config.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# User configuration +# ------------------------------------------------------------------------------ +# +# +# +# ------------------------------------------------------------------------------ + +# User specified directories +# ------------------------------------------------------------------------------ +# base_dir="/Volumes/xxx/xxx/xxx" +# source_repo_dir="repos" +# output_dir="archive" +# repo_list="${base_dir}/_src/repo_list.txt" +# +# # Variables for functions - Don't mess with these +# # ------------------------------------------------------------------------------ +# filelines="$(cat $repo_list)" +# source="${base_dir}/${source_repo_dir}" +# output="${base_dir}/${output_dir}" + +# Debugging +# ------------------------------------------------------------------------------ +print_colors="yes" + +# Colors - source the colors.sh file +# ------------------------------------------------------------------------------ +source ./_lib/colors.sh diff --git a/backup/archive_repos/_lib/functions.sh b/backup/archive_repos/_lib/functions.sh new file mode 100755 index 0000000..4191f29 --- /dev/null +++ b/backup/archive_repos/_lib/functions.sh @@ -0,0 +1,90 @@ +#!/usr/bin/env bash + +indent() { + local ind=" " + printf "${ind}" +} + +sep() { + local ch="-" + local sep_line="$(printf '%*s' "60" | tr ' ' "$ch")" + echo -e "${indent}${grey}${sep_line}${reset}${indent}" + #echo -e "-----------------------------------------------------------------------------" +} + + +# Check directory existence +# ----------------------------------------------- + +# if [ ! -d "${source}" ]; then +# mkdir ${source} +# fi +# +# if [ ! -d "${output}" ]; then +# mkdir ${output} +# fi +# +# +# # Clone everything in repo_list to source folder +# # ----------------------------------------------- +# +# while read line; do +# #echo -e "git clone $line"; +# git -C $source/ clone --quiet $line +# done < ${repo_list} +# +# +# # Archive repos +# # ----------------------------------------------- +# +# cd ${source} +# +# for dir in */ +# do +# base=$(basename "$dir") +# tar -czf "${base}.tar.gz" "$dir" +# done +# +# +# # Copy archive files to output folder +# # ----------------------------------------------- +# +# mv *.tar.gz ${output} + + +# Cleanup +# ----------------------------------------------- + +zzz (){ + for line in $filelines; do + suffix=".git" + pre="${line##*/}" + pre=${pre%"${suffix}"} + f="${output}/${pre}.tar.gz" + if [ ! -f "$f" ]; then + sep + echo + indent; echo -e "WARNING: FILE DOES NOT EXIST!" + echo + indent; echo -e "${pre}.tar.gz should have been automatically created in" + indent; echo -e "${f}," + indent; echo -e "but for some reason it wasn't." + indent; echo + indent; echo -e "Check the source directory and try to run the archive operation manually:" + indent; echo -e "tar -czf $(echo "${pre}").tar.gz $(echo "${output}/")" + echo + sep + # else + # echo -e "It's there! \c" + # echo -e "${f}" + fi + done +} + +#zzz + +run() { + sep + indent; echo "Yay" + sep +} diff --git a/backup/archive_repos/_src/repo_list.txt b/backup/archive_repos/_src/repo_list.txt new file mode 100644 index 0000000..e69de29 diff --git a/backup/archive_repos/run.sh b/backup/archive_repos/run.sh new file mode 100755 index 0000000..25bbbb7 --- /dev/null +++ b/backup/archive_repos/run.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +source ./_lib/config.sh +source ./_lib/functions.sh + +run