minor tweak
This commit is contained in:
parent
0fb8a165d1
commit
1e9f944b71
33 changed files with 646 additions and 7 deletions
24
debian/.debhelper/generated/sapphrc/dh_installchangelogs.dch.trimmed
vendored
Normal file
24
debian/.debhelper/generated/sapphrc/dh_installchangelogs.dch.trimmed
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
sapphrc (1.2.1) UNRELEASED; urgency=medium
|
||||
|
||||
* minor tweak
|
||||
|
||||
-- Penelope Gwen <support@pogmom.me> Tue, 09 Apr 2024 01:13:11 -0600
|
||||
|
||||
sapphrc (1.2) unstable; urgency=medium
|
||||
|
||||
* fix some problematic synchronization (hopefully)
|
||||
|
||||
-- Penelope Gwen <support@pogmom.me> Tue, 09 Apr 2024 00:34:22 -0600
|
||||
|
||||
sapphrc (1.1) unstable; urgency=medium
|
||||
|
||||
* fixed broken updown logic
|
||||
|
||||
-- Penelope Gwen <support@pogmom.me> Sun, 31 Mar 2024 19:51:41 -0600
|
||||
|
||||
sapphrc (1.0) unstable; urgency=medium
|
||||
|
||||
* Initial release.
|
||||
*
|
||||
|
||||
-- Penelope Gwen <support@pogmom.me> Fri, 08 Mar 2024 11:49:45 -0700
|
22
debian/.debhelper/generated/sapphrc/installed-by-dh_install
vendored
Normal file
22
debian/.debhelper/generated/sapphrc/installed-by-dh_install
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
./lib/sapphrc/sapphrc-font
|
||||
./lib/sapphrc/sapphrc-functions
|
||||
./lib/sapphrc/version
|
||||
./usr/bin/sapphrc
|
||||
./usr/bin/sapphrc_backup
|
||||
./usr/bin/sapphrc_exclude
|
||||
./usr/bin/sapphrc_include
|
||||
./usr/bin/sapphrc_profile
|
||||
./usr/bin/sapphrc_push
|
||||
./usr/bin/sapphrc_restore
|
||||
./usr/bin/sapphrc_setup
|
||||
./usr/bin/sapphrc_updown
|
||||
./usr/share/doc/sapphrc/sapphrc
|
||||
./usr/share/doc/sapphrc/sapphrc_backup
|
||||
./usr/share/doc/sapphrc/sapphrc_exclude
|
||||
./usr/share/doc/sapphrc/sapphrc_include
|
||||
./usr/share/doc/sapphrc/sapphrc_profile
|
||||
./usr/share/doc/sapphrc/sapphrc_restore
|
||||
./usr/share/doc/sapphrc/sapphrc_setup
|
||||
./lib/sapphrc/sapphrc-font
|
||||
./lib/sapphrc/sapphrc-functions
|
||||
./lib/sapphrc/version
|
0
debian/.debhelper/generated/sapphrc/installed-by-dh_installdocs
vendored
Normal file
0
debian/.debhelper/generated/sapphrc/installed-by-dh_installdocs
vendored
Normal file
6
debian/changelog
vendored
6
debian/changelog
vendored
|
@ -1,3 +1,9 @@
|
|||
sapphrc (1.2.1) UNRELEASED; urgency=medium
|
||||
|
||||
* minor tweak
|
||||
|
||||
-- Penelope Gwen <support@pogmom.me> Tue, 09 Apr 2024 01:13:11 -0600
|
||||
|
||||
sapphrc (1.2) unstable; urgency=medium
|
||||
|
||||
* fix some problematic synchronization (hopefully)
|
||||
|
|
1
debian/debhelper-build-stamp
vendored
Normal file
1
debian/debhelper-build-stamp
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
sapphrc
|
2
debian/files
vendored
Normal file
2
debian/files
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
sapphrc_1.2.1_all.deb unknown optional
|
||||
sapphrc_1.2.1_arm64.buildinfo unknown optional
|
2
debian/sapphrc.substvars
vendored
Normal file
2
debian/sapphrc.substvars
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
misc:Depends=
|
||||
misc:Pre-Depends=
|
12
debian/sapphrc/DEBIAN/control
vendored
Normal file
12
debian/sapphrc/DEBIAN/control
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
Package: sapphrc
|
||||
Version: 1.2.1
|
||||
Architecture: all
|
||||
Maintainer: Penelope Gwen <support@pogmom.me>
|
||||
Installed-Size: 38
|
||||
Depends: git, rsync
|
||||
Section: unknown
|
||||
Priority: optional
|
||||
Multi-Arch: foreign
|
||||
Homepage: https://github.com/SapphicLinux/sapphrc
|
||||
Description: dotfiles backup and profiles
|
||||
<Insert long description, indented with spaces.>
|
23
debian/sapphrc/DEBIAN/md5sums
vendored
Normal file
23
debian/sapphrc/DEBIAN/md5sums
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
17a69f82dbf9ed9c31b76223179ff03c lib/sapphrc/sapphrc-font
|
||||
887e1cbf1c0827b5fcb122929e6ae668 lib/sapphrc/sapphrc-functions
|
||||
add9573d0bdbe6b511957d850d7ceb80 lib/sapphrc/version
|
||||
05b21f1a3b14d31456a5a5a5c392ec70 usr/bin/sapphrc
|
||||
db74088af111223d722b5ad1815a2033 usr/bin/sapphrc_backup
|
||||
0c8b60289f3b7336ab643d34cb127e85 usr/bin/sapphrc_exclude
|
||||
dc574a79564e9fb12e31d568eda9856c usr/bin/sapphrc_include
|
||||
7f38e9ffdb7114bfa220eb5383ba6edb usr/bin/sapphrc_profile
|
||||
5a2873ae3f9f4c3aed1f7b12fda4e256 usr/bin/sapphrc_push
|
||||
d15289bfb96359c624467131cc651075 usr/bin/sapphrc_restore
|
||||
6df947d6a7698409edbbbd69a1d3cd7b usr/bin/sapphrc_setup
|
||||
50e4fade076af154b41e223d00460ac5 usr/bin/sapphrc_updown
|
||||
b794024466f2912a3efe1ce2cd87df90 usr/share/doc-base/sapphrc.sapphrc
|
||||
d1806ef45b08784cf1d9f9c9aa9fc960 usr/share/doc/sapphrc/README.Debian
|
||||
d4e264c85217cb206c5c55097abf065e usr/share/doc/sapphrc/changelog.gz
|
||||
7977b1c333dd7894f4814089d33a2ec7 usr/share/doc/sapphrc/copyright
|
||||
3c7964357e6b03a50f25f94da5c2892e usr/share/doc/sapphrc/sapphrc
|
||||
0beb8e7fb8106891c2060ad505d5fa18 usr/share/doc/sapphrc/sapphrc_backup
|
||||
d7120b1b933403e4c39102cf80e39189 usr/share/doc/sapphrc/sapphrc_exclude
|
||||
47be009181fb3492c6d5e5469753f6af usr/share/doc/sapphrc/sapphrc_include
|
||||
9b1e4607b52d1def509eef8de3a3ea7c usr/share/doc/sapphrc/sapphrc_profile
|
||||
654b2d496019b0d43973f2fea7db5c15 usr/share/doc/sapphrc/sapphrc_restore
|
||||
d41d8cd98f00b204e9800998ecf8427e usr/share/doc/sapphrc/sapphrc_setup
|
4
debian/sapphrc/lib/sapphrc/sapphrc-font
vendored
Normal file
4
debian/sapphrc/lib/sapphrc/sapphrc-font
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
bold=$(tput bold)
|
||||
normal=$(tput sgr0)
|
107
debian/sapphrc/lib/sapphrc/sapphrc-functions
vendored
Normal file
107
debian/sapphrc/lib/sapphrc/sapphrc-functions
vendored
Normal file
|
@ -0,0 +1,107 @@
|
|||
#!/bin/bash
|
||||
|
||||
sapphrc_config="$HOME/.config/sapphrc"
|
||||
|
||||
usage(){
|
||||
echo -n "sapphrc "
|
||||
cat /usr/share/doc/sapphrc/$(basename $0)
|
||||
}
|
||||
|
||||
check_name(){
|
||||
if [ -z "${1}" ];then
|
||||
$2 || echo "Profile name cannot be blank"
|
||||
return 0
|
||||
fi
|
||||
if [[ ! "$1" =~ ^[a-zA-Z0-9_-]+$ ]];then
|
||||
$2 || echo "Profile name can only contain numbers, letters, hyphens, and underscores"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
validate_profile(){
|
||||
profile_name="${1}"
|
||||
first_check=true
|
||||
while check_name "${profile_name}" "$first_check";do
|
||||
first_check=false
|
||||
if [ "$COMMAND" == "create" ];then
|
||||
read -p "Profile Name: " profile_name
|
||||
else
|
||||
backups=( "${sapphrc_config}/backups/"* )
|
||||
echo "$backups"
|
||||
if [ -d "${backups[0]}" ];then
|
||||
select d in $(ls "${sapphrc_config}/backups/");do test -n "$d" && break; echo ">>> Invalid Selection"; done
|
||||
profile_name="$d"
|
||||
else
|
||||
echo "No backups exist!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
sapphrc_profile="${sapphrc_config}/backups/${profile_name}"
|
||||
sapphrc_profile_rcdir="${sapphrc_profile}/home/.sapphrc"
|
||||
sapphrc_profile_rc="${sapphrc_profile_rcdir}/${profile_name}"
|
||||
}
|
||||
|
||||
inex_func(){
|
||||
validate_profile "${profile_name}"
|
||||
[ ${#@} -eq 0 ] && echo "No files selected" && exit 1
|
||||
for file in "$@";do
|
||||
fullpath=$(realpath "${file}")
|
||||
if ! [[ "$fullpath" =~ ^"$HOME/".* ]];then
|
||||
echo "file not in home dir"
|
||||
break
|
||||
fi
|
||||
if ! [[ -d "$file" || -f "$file" ]];then
|
||||
echo "file does not exist"
|
||||
break
|
||||
fi
|
||||
filelist+=(${fullpath#$HOME/})
|
||||
done
|
||||
|
||||
for e in ${filelist[@]};do
|
||||
echo $e
|
||||
done
|
||||
|
||||
read -p "${bold}Add the listed files/directories to profile '${profile_name}'?${normal} (Y/n)" yn
|
||||
if ! [[ "${yn}" =~ ^([nN][oO]|[nN])$ ]];then
|
||||
for e in ${filelist[@]};do
|
||||
if grep -q ^"${e}"$ "${sapphrc_config}/backups/${profile_name}/${inex}";then
|
||||
echo "already in file"
|
||||
else
|
||||
echo $e|tee -a "${sapphrc_config}/backups/${profile_name}/${inex}" >/dev/null
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
inex_rm(){
|
||||
validate_profile "${profile_name}"
|
||||
i=0
|
||||
while read line; do
|
||||
rmfiles+=("$i");i=$(($i+1))
|
||||
rmfiles+=("$line")
|
||||
rmfiles+=("$line")
|
||||
done < "${sapphrc_config}/backups/${profile_name}/${inex}"
|
||||
[ ${#rmfiles[@]} -eq 0 ] && echo "No files in list" && exit 1
|
||||
choices=($(dialog --checklist --output-fd 1 "Select options:" 0 0 0 "${rmfiles[@]}"))
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "User canceled."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for choice in "${choices[@]}"; do
|
||||
rmlines="${rmlines}$((${choice}+1))d;"
|
||||
done
|
||||
sed -i "${rmlines}" "${sapphrc_config}/backups/${profile_name}/${inex}"
|
||||
echo "Removed ${#choices[@]} paths from ${profile_name} ${inex} list"
|
||||
}
|
||||
|
||||
validate_backupdir(){
|
||||
if [ -d "$HOME/.config/sapphrc/backups/.git" ];then
|
||||
echo "backup folder looks good!"
|
||||
else
|
||||
echo "git repo not initialized! Something's gone wrong"
|
||||
exit 1
|
||||
fi
|
||||
}
|
1
debian/sapphrc/lib/sapphrc/version
vendored
Normal file
1
debian/sapphrc/lib/sapphrc/version
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
1.2
|
68
debian/sapphrc/usr/bin/sapphrc
vendored
Executable file
68
debian/sapphrc/usr/bin/sapphrc
vendored
Executable file
|
@ -0,0 +1,68 @@
|
|||
#!/bin/bash
|
||||
|
||||
COMMAND="${1}"
|
||||
VERSION=$(cat /lib/sapphrc/version)
|
||||
|
||||
setup() {
|
||||
sapphrc_setup $@
|
||||
}
|
||||
|
||||
profile() {
|
||||
sapphrc_profile $@
|
||||
}
|
||||
|
||||
backup() {
|
||||
sapphrc_backup $@
|
||||
}
|
||||
|
||||
restore() {
|
||||
sapphrc_restore $@
|
||||
}
|
||||
|
||||
updown() {
|
||||
sapphrc_updown $@
|
||||
}
|
||||
|
||||
push() {
|
||||
sapphrc_push $@
|
||||
}
|
||||
|
||||
include(){
|
||||
sapphrc_include $@
|
||||
}
|
||||
|
||||
exclude(){
|
||||
sapphrc_exclude $@
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo "Sapphic Package Manager v${VERSION}"
|
||||
cat /usr/share/doc/sapphrc/sapphrc
|
||||
sed -e 's/^/ /' /usr/share/doc/sapphrc/sapphrc_setup
|
||||
sed -e 's/^/ /' /usr/share/doc/sapphrc/sapphrc_profile
|
||||
sed -e 's/^/ /' /usr/share/doc/sapphrc/sapphrc_backup
|
||||
sed -e 's/^/ /' /usr/share/doc/sapphrc/sapphrc_restore
|
||||
}
|
||||
|
||||
case $COMMAND in
|
||||
setup|profile|backup|restore|updown|push|include|exclude )
|
||||
shift 1;;&
|
||||
setup )
|
||||
setup $@;;
|
||||
profile )
|
||||
profile $@;;
|
||||
backup )
|
||||
backup $@;;
|
||||
restore )
|
||||
restore $@;;
|
||||
updown )
|
||||
updown $@;;
|
||||
push )
|
||||
push $@;;
|
||||
include )
|
||||
include $@;;
|
||||
exclude )
|
||||
exclude $@;;
|
||||
*|usage )
|
||||
usage;;
|
||||
esac
|
21
debian/sapphrc/usr/bin/sapphrc_backup
vendored
Executable file
21
debian/sapphrc/usr/bin/sapphrc_backup
vendored
Executable file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
source /lib/sapphrc/sapphrc-functions
|
||||
source /lib/sapphrc/sapphrc-font
|
||||
validate_backupdir
|
||||
|
||||
sapphrc_config="$HOME/.config/sapphrc"
|
||||
|
||||
cat "${sapphrc_config}/active_profiles" | while read profile_name
|
||||
do
|
||||
backup_homedir="$sapphrc_config/backups/${profile_name}/home"
|
||||
include_list="$sapphrc_config/backups/${profile_name}/include"
|
||||
exclude_list="$sapphrc_config/backups/${profile_name}/exclude"
|
||||
echo "${include_list}"
|
||||
echo "${exclude_list}"
|
||||
echo "${HOME}"
|
||||
echo "${backup_homedir}"
|
||||
rsync -arvSH --files-from="${include_list}" --exclude-from="${exclude_list}" --exclude '.config/sapphrc/' "${HOME}" "${backup_homedir}"
|
||||
done
|
||||
|
||||
find ${HOME}/.config/sapphrc/backups/ -name *.swp -type f -exec rm {} \;
|
36
debian/sapphrc/usr/bin/sapphrc_exclude
vendored
Executable file
36
debian/sapphrc/usr/bin/sapphrc_exclude
vendored
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/bin/bash
|
||||
|
||||
COMMAND=$1
|
||||
|
||||
source /lib/sapphrc/sapphrc-functions
|
||||
source /lib/sapphrc/sapphrc-font
|
||||
|
||||
inex="exclude"
|
||||
|
||||
case $COMMAND in
|
||||
add|remove )
|
||||
shift 1;;&
|
||||
add )
|
||||
action="add";;
|
||||
remove )
|
||||
action="remove";;
|
||||
* )
|
||||
usage
|
||||
exit 1;;
|
||||
esac
|
||||
|
||||
while getopts 'hp:' flag; do
|
||||
case "${flag}" in
|
||||
p ) echo "${OPTARG}";shift 2;profile_name="${OPTARG}";;&
|
||||
h ) usage;exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
validate_backupdir
|
||||
|
||||
case "${action}" in
|
||||
add )
|
||||
inex_func "$@";;
|
||||
remove )
|
||||
inex_rm "$@";;
|
||||
esac
|
36
debian/sapphrc/usr/bin/sapphrc_include
vendored
Executable file
36
debian/sapphrc/usr/bin/sapphrc_include
vendored
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/bin/bash
|
||||
|
||||
COMMAND=$1
|
||||
|
||||
source /lib/sapphrc/sapphrc-functions
|
||||
source /lib/sapphrc/sapphrc-font
|
||||
|
||||
inex="include"
|
||||
|
||||
case $COMMAND in
|
||||
add|remove )
|
||||
shift 1;;&
|
||||
add )
|
||||
action="add";;
|
||||
remove )
|
||||
action="remove";;
|
||||
* )
|
||||
usage
|
||||
exit 1;;
|
||||
esac
|
||||
|
||||
while getopts 'hp:' flag; do
|
||||
case "${flag}" in
|
||||
p ) echo "${OPTARG}";shift 2;profile_name="${OPTARG}";;&
|
||||
h ) usage;exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
validate_backupdir
|
||||
|
||||
case "${action}" in
|
||||
add )
|
||||
inex_func "$@";;
|
||||
remove )
|
||||
inex_rm "$@";;
|
||||
esac
|
74
debian/sapphrc/usr/bin/sapphrc_profile
vendored
Executable file
74
debian/sapphrc/usr/bin/sapphrc_profile
vendored
Executable file
|
@ -0,0 +1,74 @@
|
|||
#!/bin/bash
|
||||
|
||||
source /lib/sapphrc/sapphrc-functions
|
||||
source /lib/sapphrc/sapphrc-font
|
||||
|
||||
COMMAND="${1}"
|
||||
|
||||
sapphrc_config="${HOME}/.config/sapphrc"
|
||||
|
||||
create(){
|
||||
mkdir -p "${sapphrc_profile_rcdir}"
|
||||
touch "${sapphrc_profile}/"{include,exclude}
|
||||
echo '#!/bin/bash'|tee "${sapphrc_profile_rc}" > /dev/null
|
||||
echo ".sapphrc/${profile_name}"|tee "${sapphrc_profile}/include" > /dev/null
|
||||
chmod +x "${sapphrc_profile_rc}"
|
||||
echo "Successfully created '${profile_name}'"
|
||||
join "${profile_name}"
|
||||
}
|
||||
|
||||
remove(){
|
||||
echo "WARNING: really remove profile '${profile_name}'?"
|
||||
echo "~${sapphrc_profile#$HOME} and all its contents will be deleted!"
|
||||
read -p "Confirm removal (y/N): " confirm_remove
|
||||
if [[ "${confirm_remove}" =~ ^([yY][eE][sS]|[yY])$ ]];then
|
||||
leave
|
||||
echo "removing '${profile_name}'"
|
||||
rm -r "${sapphrc_profile}"
|
||||
echo "Profile '${profile_name}' has been removed. Be sure to leave the profile on other machines/accounts to avoid synchronization issues."
|
||||
fi
|
||||
}
|
||||
|
||||
join(){
|
||||
if grep -q ^"${profile_name}"$ "${sapphrc_config}/active_profiles";then
|
||||
echo "Already joined ${profile_name}, nothing to do."
|
||||
else
|
||||
echo "${profile_name}"|tee -a "${sapphrc_config}/active_profiles" > /dev/null
|
||||
echo "Successfully joined '${profile_name}'!"
|
||||
fi
|
||||
}
|
||||
|
||||
leave(){
|
||||
if grep -q ^"${profile_name}"$ "${sapphrc_config}/active_profiles";then
|
||||
sed -i '/^'"${profile_name}"'$/d' "${sapphrc_config}/active_profiles"
|
||||
[ -e "${HOME}/.sapphrc/${profile_name}" ] && rm "${HOME}/.sapphrc/${profile_name}"
|
||||
echo "Successfully left '${profile_name}'!"
|
||||
else
|
||||
echo "You have not joined '${profile_name}', nothing to do."
|
||||
fi
|
||||
}
|
||||
|
||||
list(){
|
||||
echo "${bold}Active profiles:${normal}"
|
||||
cat "${sapphrc_config}/active_profiles"
|
||||
echo "${bold}Available profiles:${normal}"
|
||||
ls "${sapphrc_config}/backups/" | cat
|
||||
}
|
||||
|
||||
case $COMMAND in
|
||||
create|remove|join|leave )
|
||||
validate_backupdir;shift 1;
|
||||
validate_profile $@;;&
|
||||
create )
|
||||
create $@;;
|
||||
remove )
|
||||
remove $@;;
|
||||
join )
|
||||
join $@;;
|
||||
leave )
|
||||
leave $@;;
|
||||
list )
|
||||
list;;
|
||||
*|usage )
|
||||
usage;;
|
||||
esac
|
11
debian/sapphrc/usr/bin/sapphrc_push
vendored
Executable file
11
debian/sapphrc/usr/bin/sapphrc_push
vendored
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
source /lib/sapphrc/sapphrc-functions
|
||||
source /lib/sapphrc/sapphrc-font
|
||||
validate_backupdir
|
||||
|
||||
cd "$HOME/.config/sapphrc/backups"
|
||||
git add .;
|
||||
git add -u;
|
||||
git commit -m "New backup `date +'%Y-%m-%d %H:%M:%S'`";
|
||||
git push origin main
|
19
debian/sapphrc/usr/bin/sapphrc_restore
vendored
Executable file
19
debian/sapphrc/usr/bin/sapphrc_restore
vendored
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
|
||||
source /lib/sapphrc/sapphrc-functions
|
||||
source /lib/sapphrc/sapphrc-font
|
||||
validate_backupdir
|
||||
|
||||
cd "$HOME/.config/sapphrc/backups"
|
||||
git config pull.rebase false
|
||||
git pull --no-edit
|
||||
|
||||
sapphrc_config="$HOME/.config/sapphrc"
|
||||
|
||||
cat "${sapphrc_config}/active_profiles" | while read profile_name
|
||||
do
|
||||
backup_homedir="$sapphrc_config/backups/${profile_name}/home"
|
||||
include_list="$sapphrc_config/backups/${profile_name}/include"
|
||||
exclude_list="$sapphrc_config/backups/${profile_name}/exclude"
|
||||
rsync -arvSH --files-from="${include_list}" --exclude-from="${exclude_list}" --exclude '.config/sapphrc/' "${backup_homedir}" "${HOME}"
|
||||
done
|
65
debian/sapphrc/usr/bin/sapphrc_setup
vendored
Executable file
65
debian/sapphrc/usr/bin/sapphrc_setup
vendored
Executable file
|
@ -0,0 +1,65 @@
|
|||
#!/bin/bash
|
||||
|
||||
sapphrc_config="$HOME/.config/sapphrc"
|
||||
if [ -f "${aspphic_config}/backups/.init_complete" ];then
|
||||
echo "already setup"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
mkdir -p "${sapphrc_config}"
|
||||
mkdir -p "${HOME}/.sapphrc"
|
||||
|
||||
while true;do
|
||||
read -p "pull from an existing backup repo? (y/n) " gitrepo_exists
|
||||
case $gitrepo_exists in
|
||||
[Yy] )
|
||||
read -p "Enter YOUR git repo url: " git_url
|
||||
git clone "${git_url}" "${sapphrc_config}/backups"
|
||||
touch "${sapphrc_config}/backups/.init_complete"
|
||||
backup_count="0"
|
||||
backups=($(ls "${sapphrc_config}/backups/"))
|
||||
for b in ${backups[@]};do
|
||||
[ -d "${sapphrc_config}/backups/${b}" ] && backup_count=$(($backup_count+1))
|
||||
done
|
||||
|
||||
if [[ backup_count -gt 0 ]];then
|
||||
read -p "Found existing profile(s). Join one? (Y/n) " yn
|
||||
[[ "${yn}" =~ ^([nN][oO]|[nN])$ ]] || sapphrc profile join
|
||||
else
|
||||
sapphrc profile create default
|
||||
fi
|
||||
break
|
||||
;;
|
||||
[Nn] )
|
||||
mkdir -p "${sapphrc_config}/backups"
|
||||
cd "${sapphrc_config}/backups"
|
||||
git init
|
||||
touch "${sapphrc_config}/backups/.init_complete"
|
||||
git add .
|
||||
git commit -m "first commit"
|
||||
git branch -M main
|
||||
read -p "Enter YOUR git repo url: " git_url
|
||||
git remote add origin "${git_url}"
|
||||
git push -u origin main
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
##link ~/.sapphrc/* files to .bashrc
|
||||
sapphrc_bashrc="$(awk '/.sapphrc/,/done/' ~/.bashrc)"
|
||||
if [[ "${#sapphrc_bashrc}" -eq 0 ]];then
|
||||
echo "for file in ~/.sapphrc/* ; do" >> $HOME/.bashrc
|
||||
echo " if [ -f \""'$file'"\" ] ; then" >> $HOME/.bashrc
|
||||
echo " source \""'$file'"\"" >> $HOME/.bashrc
|
||||
echo " fi" >> $HOME/.bashrc
|
||||
echo "done" >> $HOME/.bashrc
|
||||
fi
|
||||
|
||||
if [ ! "$(crontab -l | grep -i 'sapphrc_updown')" ];then
|
||||
mkdir -p $HOME/.cache/sapphrc/
|
||||
crontab -l > $HOME/.cache/sapphrc/crontab
|
||||
echo "*/15 * * * * sapphrc_updown" >> $HOME/.cache/sapphrc/crontab
|
||||
crontab $HOME/.cache/sapphrc/crontab
|
||||
rm $HOME/.cache/sapphrc/crontab
|
||||
fi
|
18
debian/sapphrc/usr/bin/sapphrc_updown
vendored
Executable file
18
debian/sapphrc/usr/bin/sapphrc_updown
vendored
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
source /lib/sapphrc/sapphrc-functions
|
||||
source /lib/sapphrc/sapphrc-font
|
||||
validate_backupdir
|
||||
|
||||
cd "$HOME/.config/sapphrc/backups"
|
||||
sapphrc_backup
|
||||
gs="$(git status | grep -i 'modified')"
|
||||
git fetch origin
|
||||
reslog=$(git log HEAD..origin/main --oneline)
|
||||
|
||||
if [[ "${reslog}" == "" ]];then
|
||||
#remote changes exist
|
||||
sapphrc_restore
|
||||
fi
|
||||
sapphrc_push
|
||||
exit
|
20
debian/sapphrc/usr/share/doc-base/sapphrc.sapphrc
vendored
Normal file
20
debian/sapphrc/usr/share/doc-base/sapphrc.sapphrc
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
Document: sapphrc
|
||||
Title: Debian sapphrc Manual
|
||||
Author: <insert document author here>
|
||||
Abstract: This manual describes what sapphrc is
|
||||
and how it can be used to
|
||||
manage online manuals on Debian systems.
|
||||
Section: unknown
|
||||
|
||||
Format: debiandoc-sgml
|
||||
Files: /usr/share/doc/sapphrc/sapphrc.sgml.gz
|
||||
|
||||
Format: postscript
|
||||
Files: /usr/share/doc/sapphrc/sapphrc.ps.gz
|
||||
|
||||
Format: text
|
||||
Files: /usr/share/doc/sapphrc/sapphrc.text.gz
|
||||
|
||||
Format: HTML
|
||||
Index: /usr/share/doc/sapphrc/html/index.html
|
||||
Files: /usr/share/doc/sapphrc/html/*.html
|
6
debian/sapphrc/usr/share/doc/sapphrc/README.Debian
vendored
Normal file
6
debian/sapphrc/usr/share/doc/sapphrc/README.Debian
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
sapphrc for Debian
|
||||
-----------------
|
||||
|
||||
<Possible notes regarding this package - if none, delete this file.>
|
||||
|
||||
-- Penelope Gwen <support@pogmom.me> Fri, 08 Mar 2024 11:49:45 -0700
|
BIN
debian/sapphrc/usr/share/doc/sapphrc/changelog.gz
vendored
Normal file
BIN
debian/sapphrc/usr/share/doc/sapphrc/changelog.gz
vendored
Normal file
Binary file not shown.
43
debian/sapphrc/usr/share/doc/sapphrc/copyright
vendored
Normal file
43
debian/sapphrc/usr/share/doc/sapphrc/copyright
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Source: <url://example.com>
|
||||
Upstream-Name: sapphrc
|
||||
Upstream-Contact: <preferred name and address to reach the upstream project>
|
||||
|
||||
Files:
|
||||
*
|
||||
Copyright:
|
||||
<years> <put author's name and email here>
|
||||
<years> <likewise for another author>
|
||||
License: GPL-3.0+
|
||||
|
||||
Files:
|
||||
debian/*
|
||||
Copyright:
|
||||
2024 Penelope Gwen <support@pogmom.me>
|
||||
License: GPL-3.0+
|
||||
|
||||
License: GPL-3.0+
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
.
|
||||
This package is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
Comment:
|
||||
On Debian systems, the complete text of the GNU General
|
||||
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
|
||||
|
||||
# Please also look if there are files or directories which have a
|
||||
# different copyright/license attached and list them here.
|
||||
# Please avoid picking licenses with terms that are more restrictive than the
|
||||
# packaged work, as it may make Debian's contributions unacceptable upstream.
|
||||
#
|
||||
# If you need, there are some extra license texts available in two places:
|
||||
# /usr/share/debhelper/dh_make/licenses/
|
||||
# /usr/share/common-licenses/
|
6
debian/sapphrc/usr/share/doc/sapphrc/sapphrc
vendored
Normal file
6
debian/sapphrc/usr/share/doc/sapphrc/sapphrc
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
Usage: spm command [options]
|
||||
|
||||
Sapphrc is a dotfiles manager with support for multiple profile and git synchonization
|
||||
|
||||
Commands:
|
||||
usage: Print this dialogue
|
3
debian/sapphrc/usr/share/doc/sapphrc/sapphrc_backup
vendored
Normal file
3
debian/sapphrc/usr/share/doc/sapphrc/sapphrc_backup
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
backup: update profile based on current configuration
|
||||
usage:
|
||||
sapphrc backup
|
3
debian/sapphrc/usr/share/doc/sapphrc/sapphrc_exclude
vendored
Normal file
3
debian/sapphrc/usr/share/doc/sapphrc/sapphrc_exclude
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
backup: update profile based on current configuration
|
||||
usage:
|
||||
sapphrc exclude [action] (-p )
|
1
debian/sapphrc/usr/share/doc/sapphrc/sapphrc_include
vendored
Normal file
1
debian/sapphrc/usr/share/doc/sapphrc/sapphrc_include
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
include
|
8
debian/sapphrc/usr/share/doc/sapphrc/sapphrc_profile
vendored
Normal file
8
debian/sapphrc/usr/share/doc/sapphrc/sapphrc_profile
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
profile: manage sapphrc profiles
|
||||
usage:
|
||||
sapphrc profile [action] (profile)
|
||||
actions:
|
||||
create: creates a new sapphrc profile and joins it
|
||||
remove: leaves and deletes an existing sapphrc profile
|
||||
join: joins an existing sapphrc profile
|
||||
leave: leaves an existing sapphrc profile
|
3
debian/sapphrc/usr/share/doc/sapphrc/sapphrc_restore
vendored
Normal file
3
debian/sapphrc/usr/share/doc/sapphrc/sapphrc_restore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
backup: update current configuration from available profile updates
|
||||
usage:
|
||||
sapphrc restore
|
0
debian/sapphrc/usr/share/doc/sapphrc/sapphrc_setup
vendored
Normal file
0
debian/sapphrc/usr/share/doc/sapphrc/sapphrc_setup
vendored
Normal file
|
@ -10,15 +10,9 @@ gs="$(git status | grep -i 'modified')"
|
|||
git fetch origin
|
||||
reslog=$(git log HEAD..origin/main --oneline)
|
||||
|
||||
echo $gs
|
||||
echo " "
|
||||
echo $reslog
|
||||
|
||||
if [[ "${reslog}" == "" ]];then
|
||||
#remote changes exist
|
||||
sapphrc_restore
|
||||
elif [[ $gs == *"modified"* ]];then
|
||||
#local changes exist
|
||||
sapphrc_push
|
||||
fi
|
||||
sapphrc_push
|
||||
exit
|
||||
|
|
Loading…
Add table
Reference in a new issue