Skip to content

Commit cd9a217

Browse files
committed
Merge branch 'grigruss'
2 parents fd93a6f + 5734073 commit cd9a217

4 files changed

Lines changed: 30 additions & 36 deletions

File tree

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@ Bash script with interactive terminal shell for 'dd'
33

44
Get release zip, extract and ...
55
```
6-
# Run idd.sh as root
7-
sudo ./idd.sh
6+
# Go to extracted directory
7+
cd interactive-dd
8+
9+
# Copy idd.sh to /usr/bin as root
10+
sudo cp idd.sh /usr/bin/idd
11+
12+
# Copy translations to /usr/share/idd/
13+
sudo cp translations/*.trans /usr/share/idd/
814
915
# After that:
1016
# Just run idd in directory with image-file

idd.sh

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,12 @@
1010
# Лицензия MIT, читайте файл LICENSE.md
1111

1212
# Check root
13-
if [[ `whoami` != "root" ]]; then echo -e "Run as root! You have no rights."; exit 2; fi
14-
15-
# Check localisation file
16-
if [[ ! -e "/usr/share/idd/idd.${LANG:0:2}" ]]; then
17-
if [[ -e "./lang/idd.${LANG:0:2}" ]]; then
18-
mkdir "/usr/share/idd"
19-
cp ./lang/* /usr/share/idd/
20-
cp $0 /usr/bin/idd
21-
echo "idd.sh installed successful!"
22-
echo "Run just 'idd' without '.sh'."
23-
exit 0
24-
else
25-
echo "Localisation files not found. Please download release archive from"
26-
echo "https://github.com/grigruss/interactive-dd/releases"
27-
echo "Extract and run 'idd.sh' from extracted directory."
28-
exit 2
29-
fi
30-
fi
13+
if [[ `whoami` != "root" ]]; then echo -e "\n\t\e[33;5mRun as root! You have no rights.\e[0m\n"; exit 2; fi
3114

3215
# Load locales
3316
IFS=$'\n'
3417
iddlocale=
35-
for line in $(cat "/usr/share/idd/idd.${LANG:0:2}"); do
18+
for line in $(cat "/usr/share/idd/${LANG:0:2}.trans"); do
3619
idx1=`expr index "$line" =`
3720
idx=`expr $idx1 - 1`
3821
nm="${line:0:$idx}"
@@ -53,7 +36,7 @@ list= # For lists of files/disks | Для списков файлов/диско
5336
# Рисует шапку/заголовок
5437
field(){
5538
echo -e "\e[37;45m\e[2J\e[1;0H"
56-
echo -e "$idd_header"
39+
echo -e "$idd_header dd (v0.4.1)\e[0m\e[37;45;1m"
5740
echo -e "$idd_target"
5841
echo -e "$idd_target1"
5942
echo -e "$idd_thankfulness"
@@ -76,7 +59,7 @@ chs1(){
7659
else
7760
showdevices
7861
fi
79-
echo -e "$idd_read_source_dest"
62+
echo -e "$idd_read_source_dest $d$idd_read_source_dest1"
8063
read file
8164
sl="${#list[*]}"
8265
if [[ $d == "$idd_choise_f" && $file == $sl ]]; then
@@ -109,10 +92,10 @@ chs2(){
10992
esac
11093
if [[ $d == $idd_choise_d ]]; then
11194
showdevices
112-
echo -e "$idd_read_source_dest"
95+
echo -e "$idd_read_source_dest $d$idd_read_source_dest1"
11396
read file
11497
else
115-
echo -e "$idd_type_filename"
98+
echo -e "$idd_type_filename $d$idd_type_filename1"
11699
read ff
117100
if [[ -e "$ff" && $ff != "/dev/null" ]]; then
118101
echo -e "$idd_file_exists_exit"; exit 2
@@ -130,13 +113,15 @@ chs2(){
130113
# Вывод нумерованного списка файлов в текущей директории
131114
showfiles(){
132115
echo -e "$idd_filelist"
133-
flist=(`ls *.i*`)
134116
count=1
135-
for file in ${flist[*]}; do
136-
echo -e "\t\t$count) $file"
137-
list[$count]=$file
138-
count=`expr $count + 1`
139-
done
117+
if [[ -e *.i* ]]; then
118+
flist=(`ls *.i*`)
119+
for file in ${flist[*]}; do
120+
echo -e "\t\t$count) $file"
121+
list[$count]=$file
122+
count=`expr $count + 1`
123+
done
124+
fi
140125
echo -e "\t\t$count$idd_type_from_kbd"
141126
}
142127

@@ -167,6 +152,7 @@ showdevices(){
167152
# Get device block size
168153
# Определение размера блока
169154
getbs(){
155+
if [[ ! -e /sys/block/$bsdev/queue/logical_block_size ]]; then bs=; return; fi
170156
bsdev=
171157
if [[ ${odev:0:4} == "/dev" ]]; then bsdev="${odev:5}"; else bsdev="no"; return; fi
172158
blocksize=`cat /sys/block/$bsdev/queue/logical_block_size`
@@ -189,7 +175,7 @@ showdata(){
189175
field
190176
echo -e "\e[30;47m\e[12H\e[0J"
191177
echo -e "$idd_source_choised\t$idev"
192-
echo -e "$idd_dest_choised$odev\t$mnt\e[0m\e[30;47m"
178+
echo -e "$idd_dest_choised\t$odev\t$mnt\e[0m\e[30;47m"
193179
echo -e "$idd_bs\t$bs"
194180
if [[ ! $bs ]]; then pbs=""; else pbs="bs=$bs "; fi
195181
echo -e "$idd_command\e[30;43m dd if=$idev of=$odev ${pbs}status=progress \e[0m\e[30;47m"

lang/idd.en renamed to translations/en.trans

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ idd_choise_f=file
1111
idd_choise_d=disk
1212
idd_choise_source1=\e[1D\e[0K\t\t\e[34mf) File\t\e[30md) Disk
1313
idd_choise_source2=\e[1D\e[0K\t\tf) File\t\e[34md) Disk\e[30m
14-
idd_read_source_dest=\tSelect the number of $d and press Enter
14+
idd_read_source_dest=\tSelect the number of
15+
idd_read_source_dest1= and press Enter
1516
idd_type_filename=\tType name of
1617
idd_type_filename1=:
1718
idd_file_exists=\tFile exists.

lang/idd.ru renamed to translations/ru.trans

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
# Rissuan UTF-8 locale
22

3-
idd_header=\e[37;45;4m\tИНТЕРАКТИВНАЯ ОБОЛОЧКА КОМАНДЫ dd (v0.4)\e[0m\e[37;45;1m
3+
idd_header=\e[37;45;4m\tИНТЕРАКТИВНАЯ ОБОЛОЧКА КОМАНДЫ
44
idd_target=\e[37;45;1m \e[4mВ целях:\e[0m\e[37;45;1m\n\tРоссийского Общества Свободного Программного Обеспечения (РОСПО)
55
idd_target1=\e[37;45;1m\tДля развития и улучшения качества российского СПО.
6-
idd_thankfulness=\e[37;45;1m \e[4mБлагодарность за консультации:\e[0m\e[37;45;1m\n\tМихаилу (vk.com/mikhailnov) и Сергею (vk.com/disable_enable)
6+
idd_thankfulness=\e[37;45;1m \e[4mБлагодарность за консультации и помощь:\e[0m\e[37;45;1m\n\tМихаилу (vk.com/mikhailnov), Сергею (vk.com/disable_enable) и Данилу (vk.com/danil.antoshkin)
77
idd_author_lic=\e[37;45;1m\n\tya@grigrus.ru vk.com/nixscript\n\t\t License MIT \n\e[0m\e[47m\e[0J
88

99
idd_choise_source=\e[30;47m\e[12H\e[0J\t\e[30mВыберите источник\n\t\tf) Файл\td) Диск\e[1A
1010
idd_choise_f=файл
1111
idd_choise_d=диск
1212
idd_choise_source1=\e[1D\e[0K\t\t\e[34mf) Файл\t\e[30md) Диск
1313
idd_choise_source2=\e[1D\e[0K\t\tf) Файл\t\e[34md) Диск\e[30m
14-
idd_read_source_dest=\tВыберите номер $dа и нажмите Enter
14+
idd_read_source_dest=\tВыберите номер
15+
idd_read_source_dest1=а и нажмите Enter
1516
idd_type_filename=\tВведите имя
1617
idd_type_filename1=а:
1718
idd_file_exists=\tФайл найден.

0 commit comments

Comments
 (0)