You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
126 lines
4.7 KiB
126 lines
4.7 KiB
#!/bin/bash |
|
|
|
#Создан: Вт 06 авг 2013 22:07:30 |
|
#Изменён: Ср 07 авг 2013 00:22:45 |
|
|
|
#---------------------------------------------------------------------- |
|
# |
|
# Copyright (C) 2013, Maxim Lihachev, <envrm@yandex.ru> |
|
# |
|
# 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 program 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 <http://www.gnu.org/licenses/>. |
|
#---------------------------------------------------------------------- |
|
|
|
# |
|
# Скрипт скачивает и распаковывает установочный файл и |
|
# все доступные карты ДубльГис |
|
# |
|
|
|
#Стартовая страница |
|
GISPAGE="http://msk.2gis.ru/" |
|
#Директория для сохранения файлов *.msi |
|
DOWNLOADDIR="./updates/" |
|
#Директория для сохранения дистрибутива 2ГИС |
|
DATADIR="./updates/gis/" |
|
|
|
#Файл для сохранения адресов оболочки и доступных карт |
|
WGETLIST="./wgetlist.txt" |
|
|
|
#Загрузка оболочки 2ГИС и файлов карт |
|
download2GIS() { |
|
#Удаление файлов старше 14 дней в директории с обновлениями |
|
find $DOWNLOADDIR -type f -mtime +14 -exec rm -f {} \; |
|
|
|
#Создание директории для файлов карт |
|
\mkdir -v -p "$DOWNLOADDIR" |
|
|
|
#Оболочка 2ГИС |
|
\curl -s "${GISPAGE}how-get/download/" \ |
|
| \grep -E -o 'href="http://download\.2gis\.ru/arhives/2GISShell.*\.msi"' \ |
|
| cut -d '"' -f 2 > $WGETLIST |
|
|
|
#Карты всех доступных городов |
|
for url in `\curl -s $GISPAGE | \grep -E -o 'http://\w+\.2gis\.ru/" class' | \cut -d '"' -f 1`; do |
|
\curl -s "${url}how-get/download/" \ |
|
| \grep -E -o 'href="http://download\.2gis\.ru/arhives/2GISData_.*\.msi"' \ |
|
| cut -d '"' -f 2 >> $WGETLIST |
|
done |
|
|
|
\wget -t 10 -N -c -P $DOWNLOADDIR -i $WGETLIST |
|
|
|
#Удаление временного файла |
|
\rm -f $WGETLIST |
|
} |
|
|
|
#Сборка дистрибутива 2ГИС |
|
build2GIS() { |
|
#Удаление директории 2ГИС |
|
\rm -rf -v $DATADIR |
|
|
|
#Создание дерева директорий 2ГИС |
|
\mkdir -v -p "${DATADIR}/Plugins/DGisLan" |
|
|
|
#Распаковка файлов *.msi |
|
for file in $DOWNLOADDIR/*.msi; do |
|
\7z -y x "$file" -o$DATADIR |
|
done |
|
|
|
#Переименовывание файлов и организация структуры директорий 2ГИС |
|
# gis/ |
|
# ├── Data_[map 1].dgdat |
|
# ├── Data_[map 2].dgdat |
|
# ├── Data_[map 2].dgdat |
|
# ├── grym.exe |
|
# └── Plugins/ |
|
# ├── DGisLan.chm |
|
# ├── DGisLan.dgxpi |
|
# ├── DGisLan.dll |
|
# ├── DGisLayer.chm |
|
# ├── DGisLayer.dgxpi |
|
# ├── DGisLayer.dll |
|
# ├── DGisNotes.chm |
|
# ├── DGisNotes.dgxpi |
|
# ├── DGisNotes.dll |
|
# └── DGisLan/ |
|
# ├── [map 1].dglf |
|
# └── [map 2].dglf |
|
# |
|
for file in $DATADIR/*; do if test -f "$file"; then |
|
case "$file" in |
|
*_DGDAT) \mv -v "$file" "$DATADIR/Data_`echo -n $(basename $file) | sed 's/_DGDAT/.dgdat/'`";; |
|
*_DGLAN) \mv -v "$file" "$DATADIR/Plugins/DGisLan/`echo -n $(basename $file) | sed 's/_DGLAN/.dglf/'`";; |
|
*Sgn) \mv -v "$file" "$DATADIR/Plugins/`echo -n $(basename $file) | sed 's/Sgn/.dgxpi/'`";; |
|
*Dll) \mv -v "$file" "$DATADIR/Plugins/`echo -n $(basename $file) | sed 's/Dll/.dll/'`";; |
|
*Chm) \mv -v "$file" "$DATADIR/Plugins/`echo -n $(basename $file) | sed 's/Chm/.chm/'`";; |
|
*EXE) \mv -v "$file" "$DATADIR/`echo -n $(basename $file) | sed 's/EXE/.exe/'`";; |
|
esac |
|
fi |
|
done |
|
|
|
#Удаление лишних файлов |
|
\rm -f -v $DATADIR/MarkInstall |
|
\rm -f -v $DATADIR/TrayNotify.exe |
|
\rm -f -v $DATADIR/UpdateService.exe |
|
} |
|
|
|
#Разбор аргументов командной строки |
|
case "$1" in |
|
-h) printf "Использование: $0 [options] |
|
-h - вывод справки по использованию. |
|
-d - только загрузка файлов обновлений. |
|
-x - только распаковка обновлений.\n";; |
|
-d) download2GIS;; |
|
-x) build2GIS;; |
|
*) download2GIS; build2GIS;; |
|
esac |
|
|
|
|