| | | |
Offset 768, 14 lines modified | Offset 768, 176 lines modified |
768 | ··local·end_key_cnt | 768 | ··local·end_key_cnt |
769 | ··fsdb=$(_get_secrets_dir_paths_mapping) | 769 | ··fsdb=$(_get_secrets_dir_paths_mapping) |
770 | ··end_key_cnt=$(get_gpg_key_count) | 770 | ··end_key_cnt=$(get_gpg_key_count) |
771 | ··[[·$start_key_cnt·-ne·$end_key_cnt·]]·&&·_fsdb_clear_hashes·"$fsdb" | 771 | ··[[·$start_key_cnt·-ne·$end_key_cnt·]]·&&·_fsdb_clear_hashes·"$fsdb" |
772 | } | 772 | } |
773 | #!/usr/bin/env·bash | 773 | #!/usr/bin/env·bash |
| |
| 774 | #·shellcheck·disable=2016 |
| 775 | AWK_FSDB_UPDATE_HASH=' |
| 776 | BEGIN·{·FS=":";·OFS=":";·} |
| 777 | { |
| 778 | ··if·(·key·==·$1·) |
| 779 | ··{ |
| 780 | ····print·key,hash; |
| 781 | ··} |
| 782 | ··else |
| 783 | ··{ |
| 784 | ····print·$1,$2; |
| 785 | ··} |
| 786 | } |
| 787 | ' |
| |
| 788 | function·_optional_clean·{ |
| 789 | ··local·clean="$1" |
| 790 | ··local·verbose=${2:-""} |
| |
| 791 | ··if·[[·$clean·-eq·1·]];·then |
| 792 | ····_find_and_clean_formated·"*$SECRETS_EXTENSION"·"$verbose" |
| 793 | ··fi |
| 794 | } |
| |
| |
| 795 | function·_optional_delete·{ |
| 796 | ··local·delete="$1" |
| 797 | ··local·verbose=${2:-""} |
| |
| 798 | ··if·[[·$delete·-eq·1·]];·then |
| 799 | ····local·path_mappings |
| 800 | ····path_mappings=$(_get_secrets_dir_paths_mapping) |
| |
| 801 | ····#·We·use·custom·formating·here: |
| 802 | ····if·[[·!·-z·"$verbose"·]];·then |
| 803 | ······echo·&&·echo·'removing·unencrypted·files:' |
| 804 | ····fi |
| |
| 805 | ····while·read·-r·line;·do |
| 806 | ······#·So·the·formating·would·not·be·repeated·several·times·here: |
| 807 | ······local·filename |
| 808 | ······filename=$(_get_record_filename·"$line") |
| 809 | ······_find_and_clean·"*$filename"·"$verbose" |
| 810 | ····done·<·"$path_mappings" |
| |
| 811 | ····if·[[·!·-z·"$verbose"·]];·then |
| 812 | ······echo |
| 813 | ····fi |
| 814 | ··fi |
| 815 | } |
| |
| 816 | function·_get_checksum_local·{ |
| 817 | ··local·checksum="$SECRETS_CHECKSUM_COMMAND" |
| 818 | ··echo·"$checksum" |
| 819 | } |
| |
| 820 | function·_get_file_hash·{ |
| 821 | ··local·input_path="$1"·#·Required |
| 822 | ··local·checksum_local |
| 823 | ··local·file_hash |
| |
| 824 | ··checksum_local="$(_get_checksum_local)" |
| 825 | ··file_hash=$($checksum_local·"$input_path"·|·gawk·'{print·$1}') |
| |
| 826 | ··echo·"$file_hash" |
| 827 | } |
| |
| 828 | function·_optional_fsdb_update_hash·{ |
| 829 | ··local·key="$1" |
| 830 | ··local·hash="$2" |
| 831 | ··local·fsdb··········#·path_mappings |
| |
| 832 | ··fsdb=$(_get_secrets_dir_paths_mapping) |
| |
| 833 | ··_gawk_inplace·-v·key="$key"·-v·hash="$hash"·"'$AWK_FSDB_UPDATE_HASH'"·"$fsdb" |
| 834 | } |
| |
| |
| 835 | function·hide·{ |
| 836 | ··local·clean=0 |
| 837 | ··local·delete=0 |
| 838 | ··local·fsdb_update_hash=0·#·add·checksum·hashes·to·fsdb |
| 839 | ··local·verbose='' |
| |
| 840 | ··OPTIND=1 |
| |
| 841 | ··while·getopts·'cdmvh'·opt;·do |
| 842 | ····case·"$opt"·in |
| 843 | ······c)·clean=1;; |
| |
| 844 | ······d)·delete=1;; |
| |
| 845 | ······m)·fsdb_update_hash=1;; |
| |
| 846 | ······v)·verbose='v';; |
| |
| 847 | ······h)·_show_manual_for·'hide';; |
| |
| 848 | ······*)·_invalid_option_for·'hide';; |
| 849 | ····esac |
| 850 | ··done |
| |
| 851 | ··shift·$((OPTIND-1)) |
| 852 | ··[·"$1"·=·'--'·]·&&·shift |
| |
| 853 | ··#·We·need·user·to·continue: |
| 854 | ··_user_required |
| |
| 855 | ··#·If·-c·option·was·provided,·it·would·clean·the·hidden·files |
| 856 | ··#·before·creating·new·ones. |
| 857 | ··_optional_clean·"$clean"·"$verbose" |
| |
| 858 | ··#·Encrypting·files: |
| |
| 859 | ··local·path_mappings |
| 860 | ··path_mappings=$(_get_secrets_dir_paths_mapping) |
| |
| 861 | ··local·counter=0 |
| 862 | ··while·read·-r·record;·do |
| 863 | ····local·filename |
Max diff block lines reached; 5725/9725 bytes (58.87%) of diff not shown.
|