annotate bin/index @ 727:49538e2aad65 default tip

Add a useful editrc
author nanaya <me@nanaya.net>
date Tue, 24 Sep 2024 16:58:15 +0900
parents 5bafb912837e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
124
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
1 #!/bin/sh
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
2
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
3 #un(POSIX / bourne shell)-ness: "read -r"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
4
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
5 WORKDIR="${PWD}"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
6 TEMPFILE="${WORKDIR}/temp/all"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
7 RESFILE="${WORKDIR}/list/all"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
8 ARCDIR="${WORKDIR}/archives"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
9 FILEDIRS="complete1 complete3 complete4 complete5 incomplete movie"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
10 #FILEDIRS="complete-all incomplete movie"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
11
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
12 Err_Fatal() {
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
13 echo "Error: $*"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
14 exit 1
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
15 }
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
16
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
17 Progress_Init() {
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
18 _last="-"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
19 printf "${_last}"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
20 }
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
21
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
22 Progress_Anim() {
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
23 case "${_last}" in
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
24 /) _last="-";;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
25 -) _last=\\;;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
26 \\) _last=\|;;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
27 \|) _last="/";;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
28 esac
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
29 printf "\b${_last}"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
30 }
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
31
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
32 Progress_Done() { printf "\bdone\n"; }
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
33
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
34 Check_Dirs() {
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
35 [ -w "${WORKDIR}" ] || Err_Fatal "Unable to write ${WORKDIR}"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
36 for dir in temp list archives backup; do
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
37 mkdir -p "${WORKDIR}/${dir}" 2>/dev/null
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
38 [ -w "${WORKDIR}/${dir}" ] || Err_Fatal "Unable to write ${WORKDIR}/${dir}"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
39 done
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
40 }
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
41
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
42 Finish_Copy() {
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
43 printf "Copying result files... "
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
44 rm "${WORKDIR}/list/"*
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
45 cp "${WORKDIR}/temp/"* "${WORKDIR}/list"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
46 mkdir -p "archives/${DATE}" && cp "${WORKDIR}/temp/"* "${WORKDIR}/archives/${DATE}"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
47 echo "done"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
48 }
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
49
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
50 Generate_File_List() {
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
51 printf "Generating list of files... "
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
52 > "${TEMPFILE}-bare"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
53 for i in ${FILEDIRS}; do
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
54 printf "${i}... "
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
55 dir="/anime/${i}"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
56 [ -d "${dir}" ] && find "${dir}/"* -type f >> "${TEMPFILE}-bare"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
57 done
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
58 echo "done"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
59 printf "Checking list validity... "
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
60 [ -n "$(grep -v ^/ "${TEMPFILE}-bare")" ] && Err_Fatal "Newline in filename. Please check ${TEMPFILE}-bare"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
61 echo "done"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
62
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
63 printf "Generating list of filenames... "
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
64 sed -e 's/.*\/\([^/]*\)/\1/' "${TEMPFILE}-bare" > "${TEMPFILE}-basename"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
65 echo "done"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
66
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
67 printf "Sorting and finding duplicates... "
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
68 sort -- "${TEMPFILE}-basename" > "${TEMPFILE}-basename-sorted"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
69 mv -- "${TEMPFILE}-basename-sorted" "${TEMPFILE}-basename"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
70 sort -u -- "${TEMPFILE}-basename" > "${TEMPFILE}-basename-sortuniq"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
71 comm -23 -- "${TEMPFILE}-basename" "${TEMPFILE}-basename-sortuniq" > "${TEMPFILE}-dup-basename"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
72 echo "done"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
73 if [ "$(wc -l < "${TEMPFILE}-dup-basename")" -gt 0 ]; then
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
74 > "${TEMPFILE}-dup-bare"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
75 printf "Duplicate files detected. Generating list of duplicates... "
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
76 Progress_Init
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
77 while read -r dup; do
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
78 fgrep "${dup}" "${TEMPFILE}-bare" >> "${TEMPFILE}-dup-bare"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
79 Progress_Anim
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
80 done < "${TEMPFILE}-dup-basename"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
81 Progress_Done
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
82 Err_Fatal "Duplicated files detected. Please resolve this before continuing.
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
83 Check ${TEMPFILE}-dup-basename for list of duplicates"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
84 else
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
85 rm "${TEMPFILE}-dup-basename" "${TEMPFILE}-basename-sortuniq"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
86 fi
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
87 #yay finished
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
88 }
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
89
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
90 Generate_New_List() {
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
91 printf "Generating list of new files... "
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
92 Progress_Init
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
93 > "${TEMPFILE}-newbase"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
94 sort "${RESFILE}-basename" > "${TEMPFILE}-res-basename"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
95 mv "${TEMPFILE}-res-basename" "${RESFILE}-basename"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
96 comm -13 "${RESFILE}-basename" "${TEMPFILE}-basename" > "${TEMPFILE}-newbase"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
97 Progress_Anim
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
98 > "${TEMPFILE}-new"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
99 while read -r added; do
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
100 fgrep "${added}" "${TEMPFILE}-bare" >> "${TEMPFILE}-new"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
101 Progress_Anim
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
102 done < "${TEMPFILE}-newbase"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
103 rm "${TEMPFILE}-newbase"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
104 Progress_Done
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
105 }
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
106
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
107 Init_Check() {
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
108 cp "${TEMPFILE}-bare" "${TEMPFILE}-new"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
109 }
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
110
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
111 Run_ed2k() {
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
112 #[ "$(echo $(wc -l < "${TEMPFILE}-new"))" -eq 0 ] && Err_Fatal "Not an error. Just lazy to create new handler. (Nothing new)"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
113 printf "Generating ed2k links...0"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
114 > "${TEMPFILE}-ed2k-newlist"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
115 num=0
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
116 while read -r file; do
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
117 ed2k -l "${file}" >> "${TEMPFILE}-ed2k-newlist"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
118 num=$((num+1))
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
119 if [ "$((num%10))" -eq 0 ]; then
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
120 printf "${num}"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
121 else
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
122 printf "."
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
123 fi
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
124 done < "${TEMPFILE}-new"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
125 echo " done"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
126 }
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
127
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
128 Generate_Removed() {
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
129 printf "Generating list of removed files... "
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
130 Progress_Init
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
131 cp "${TEMPFILE}-ed2k-newlist" "${ARCDIR}/ed2k-newlist.${DATE}"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
132 cat "${RESFILE}-ed2k-newlist" >> "${TEMPFILE}-ed2k-newlist"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
133 sort -u "${TEMPFILE}-ed2k-newlist" > "${TEMPFILE}-ed2k-newlist-temp"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
134 mv "${TEMPFILE}-ed2k-newlist-temp" "${TEMPFILE}-ed2k-newlist"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
135 Progress_Anim
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
136 comm -13 "${TEMPFILE}-basename" "${RESFILE}-basename" | sort > "${TEMPFILE}-removed"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
137 Progress_Anim
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
138 if [ "$(echo $(wc -l < "${TEMPFILE}-removed"))" -gt 0 ]; then
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
139 > "${TEMPFILE}-ed2k-newlisttemp"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
140 while read -r deleted; do
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
141 fgrep "${deleted}" "${TEMPFILE}-ed2k-newlist" >> "${TEMPFILE}-ed2k-removed"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
142 Progress_Anim
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
143 fgrep -v "${deleted}" "${TEMPFILE}-ed2k-newlist" > "${TEMPFILE}-ed2k-newlisttemp"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
144 mv "${TEMPFILE}-ed2k-newlisttemp" "${TEMPFILE}-ed2k-newlist"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
145 Progress_Anim
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
146 done < "${TEMPFILE}-removed"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
147 cp "${TEMPFILE}-ed2k-removed" "${ARCDIR}/ed2k-removed.${DATE}"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
148 #sed -e 's/ed2k:\/\/|file|\(.*\)|[^|]*|[^|]*|$/\1/' "${TEMPFILE}-ed2k-removed" > "${TEMPFILE}-base-removed"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
149 Progress_Anim
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
150 while read -r deleted; do
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
151 fgrep "${deleted}" "${RESFILE}-bare" >> "${TEMPFILE}-bare-removed"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
152 Progress_Anim
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
153 done < "${TEMPFILE}-removed"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
154 cp "${TEMPFILE}-bare-removed" "${ARCDIR}/bare-removed.${DATE}"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
155 fi
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
156 Progress_Done
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
157 }
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
158
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
159 INIT=
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
160 UPDATE=
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
161 DATE=$(date -u "+%Y%m%d-%H.%M")
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
162 case "$1" in
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
163 init) INIT=1;;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
164 update|up) UPDATE=1;;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
165 *) Err_Fatal "You fail.";;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
166 esac
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
167 Check_Dirs
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
168 [ -n "${UPDATE}" ] && cd "${WORKDIR}" && tar zcf "${WORKDIR}/backup/${DATE}.tar.gz" "temp" "list" "archives"
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
169 [ -n "${UPDATE}" ] && rm "${WORKDIR}/temp/"* 2>/dev/null
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
170 Generate_File_List
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
171 [ -n "${INIT}" ] && Init_Check
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
172 [ -n "${UPDATE}" ] && Generate_New_List
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
173 Run_ed2k
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
174 [ -n "${UPDATE}" ] && Generate_Removed
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
175 Finish_Copy
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
176