Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
eepm
Commits
db22b2f8
Commit
db22b2f8
authored
Aug 18, 2016
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit packed files
parent
5ea8127b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
478 additions
and
81 deletions
+478
-81
epm.sh
packed/epm.sh
+277
-74
serv.sh
packed/serv.sh
+201
-7
No files found.
packed/epm.sh
View file @
db22b2f8
...
@@ -345,7 +345,8 @@ assure_exists()
...
@@ -345,7 +345,8 @@ assure_exists()
eget
()
eget
()
{
{
$SHAREDIR
/tools-eget
"
$@
"
assure_exists wget
internal_tools_eget
"
$@
"
}
}
get_package_type
()
get_package_type
()
...
@@ -687,7 +688,7 @@ case $PMTYPE in
...
@@ -687,7 +688,7 @@ case $PMTYPE in
apt-dpkg|aptitude-dpkg
)
apt-dpkg|aptitude-dpkg
)
assure_exists deborphan
assure_exists deborphan
showcmd deborphan
showcmd deborphan
a
=
deborphan |
su
docmd epm remove
a
=
deborphan | docmd epm remove
;;
;;
#aura)
#aura)
# sudocmd aura -Oj
# sudocmd aura -Oj
...
@@ -704,7 +705,7 @@ case $PMTYPE in
...
@@ -704,7 +705,7 @@ case $PMTYPE in
docmd epm remove
$PKGLIST
docmd epm remove
$PKGLIST
;;
;;
urpm-rpm
)
urpm-rpm
)
showcmd urpm
q
--auto
-orphans
showcmd urpm
e
--report
-orphans
sudocmd urpme
--auto-orphans
sudocmd urpme
--auto-orphans
;;
;;
#emerge)
#emerge)
...
@@ -725,9 +726,15 @@ case $PMTYPE in
...
@@ -725,9 +726,15 @@ case $PMTYPE in
#pkgng)
#pkgng)
# sudocmd pkg autoremove
# sudocmd pkg autoremove
# ;;
# ;;
#zypper-rpm)
zypper-rpm
)
# sudocmd zypper clean
# https://www.linux.org.ru/forum/desktop/11931830
# ;;
assure_exists zypper zypper 1.9.2
# For zypper < 1.9.2: zypper se -si | grep 'System Packages'
sudocmd zypper packages
--orphaned
# FIXME: x86_64/i586 are duplicated
local
PKGLIST
=
$(
zypper packages
--orphaned
|
tail
-n
+5 |
cut
-d
\|
-f
3 |
sort
-u
)
sudocmd zypper remove
--clean-deps
$PKGLIST
;;
*
)
*
)
fatal
"Have no suitable command for
$PMTYPE
"
fatal
"Have no suitable command for
$PMTYPE
"
;;
;;
...
@@ -755,7 +762,7 @@ __epm_autoremove_altrpm()
...
@@ -755,7 +762,7 @@ __epm_autoremove_altrpm()
|
grep
-E
-v
--
"-(devel|debuginfo)$"
\
|
grep
-E
-v
--
"-(devel|debuginfo)$"
\
|
grep
-E
-v
--
"-(util|tool|plugin|daemon)"
\
|
grep
-E
-v
--
"-(util|tool|plugin|daemon)"
\
|
sed
-e
"s/
\.
32bit
$/
/g"
\
|
sed
-e
"s/
\.
32bit
$/
/g"
\
|
grep
-E
-v
--
"^(libsystemd|libreoffice|libnss|eepm)"
)
|
grep
-E
-v
--
"^(libsystemd|libreoffice|libnss|
libvirt-client|libvirt-daemon|
eepm)"
)
[
-n
"
$pkgs
"
]
&&
sudocmd rpm
-v
-e
$pkgs
&&
flag
=
1
[
-n
"
$pkgs
"
]
&&
sudocmd rpm
-v
-e
$pkgs
&&
flag
=
1
info
"Removing unused python/perl modules..."
info
"Removing unused python/perl modules..."
...
@@ -782,13 +789,12 @@ epm_autoremove()
...
@@ -782,13 +789,12 @@ epm_autoremove()
case
$DISTRNAME
in
case
$DISTRNAME
in
ALTLinux
)
ALTLinux
)
__epm_autoremove_altrpm
__epm_autoremove_altrpm
docmd epm remove-old-kernels
assure_exists remove-old-kernels update-kernel 0.9.9
sudocmd remove-old-kernels
if
which nvidia-clean-driver 2>/dev/null
;
then
if
which nvidia-clean-driver 2>/dev/null
;
then
sudocmd nvidia-clean-driver
sudocmd nvidia-clean-driver
fi
fi
return
return
;;
;;
*
)
*
)
...
@@ -838,9 +844,14 @@ case $PMTYPE in
...
@@ -838,9 +844,14 @@ case $PMTYPE in
pkgng
)
pkgng
)
sudocmd pkg autoremove
sudocmd pkg autoremove
;;
;;
#zypper-rpm)
zypper-rpm
)
# sudocmd zypper clean
# https://www.linux.org.ru/forum/desktop/11931830
# ;;
assure_exists zypper zypper 1.9.3
sudocmd zypper packages
--unneeded
# FIXME: x86_64/i586 are duplicated
local
PKGLIST
=
$(
zypper packages
--unneeded
|
tail
-n
+5 |
cut
-d
\|
-f
3 |
sort
-u
)
sudocmd zypper remove
--clean-deps
$PKGLIST
;;
*
)
*
)
fatal
"Have no suitable command for
$PMTYPE
"
fatal
"Have no suitable command for
$PMTYPE
"
;;
;;
...
@@ -914,9 +925,9 @@ __epm_changelog_unlocal_names()
...
@@ -914,9 +925,9 @@ __epm_changelog_unlocal_names()
#yum-rpm)
#yum-rpm)
# sudocmd yum clean all
# sudocmd yum clean all
# ;;
# ;;
#
urpm-rpm)
urpm-rpm
)
# sudocmd urpmi --clean
docmd urpmq
--changelog
$@
| less
#
;;
;;
#zypper-rpm)
#zypper-rpm)
# sudocmd zypper clean
# sudocmd zypper clean
# ;;
# ;;
...
@@ -961,11 +972,11 @@ case $PMTYPE in
...
@@ -961,11 +972,11 @@ case $PMTYPE in
apt-dpkg
)
apt-dpkg
)
#sudocmd apt-get update || exit
#sudocmd apt-get update || exit
#sudocmd apt-get check || exit
#sudocmd apt-get check || exit
sudocmd apt-get
-f
install
||
exit
sudocmd apt-get
-f
install
||
return
sudocmd apt-get autoremove
sudocmd apt-get autoremove
;;
;;
aptitude-dpkg
)
aptitude-dpkg
)
sudocmd aptitude
-f
install
||
exit
sudocmd aptitude
-f
install
||
return
#sudocmd apt-get autoremove
#sudocmd apt-get autoremove
;;
;;
yum-rpm
)
yum-rpm
)
...
@@ -1195,15 +1206,15 @@ epm_clean()
...
@@ -1195,15 +1206,15 @@ epm_clean()
case
$PMTYPE
in
case
$PMTYPE
in
apt-rpm
)
apt-rpm
)
sudocmd apt-get clean
sudocmd apt-get clean
__remove_alt_apt_cache_file
[
-n
"
$force
"
]
&&
__remove_alt_apt_cache_file
;;
;;
apt-dpkg
)
apt-dpkg
)
sudocmd apt-get clean
sudocmd apt-get clean
__remove_deb_apt_cache_file
[
-n
"
$force
"
]
&&
__remove_deb_apt_cache_file
;;
;;
aptitude-dpkg
)
aptitude-dpkg
)
sudocmd aptitude clean
sudocmd aptitude clean
__remove_deb_apt_cache_file
[
-n
"
$force
"
]
&&
__remove_deb_apt_cache_file
;;
;;
yum-rpm
)
yum-rpm
)
sudocmd yum clean all
sudocmd yum clean all
...
@@ -1443,22 +1454,14 @@ epm_download()
...
@@ -1443,22 +1454,14 @@ epm_download()
# File bin/epm-epm_install:
# File bin/epm-epm_install:
myinit
(){
etersoft_updates_site
=
"http://updates.etersoft.ru/pub/Etersoft/Sisyphus/
$(
$DISTRVENDOR
-e
)
/"
download_dir
=
"/tmp"
}
download_epm
(){
download_link
=
$etersoft_updates_site
$(
wget
-qO-
$etersoft_updates_site
/ |
grep
-m1
-Eo
"eepm[^
\"
]+
\.
$(
$DISTRVENDOR
-p
)
"
|
tail
-n1
)
#"
eepm_package
=
"
$download_dir
/
$(
basename
$download_link
)
"
wget
-O
$eepm_package
$download_link
}
epm_epm_install
(){
epm_epm_install
(){
myinit
assure_exists wget
download_epm
||
fatal
"Error. Check download link:
$download_link
"
local
etersoft_updates_site
=
"http://updates.etersoft.ru/pub/Korinf/
$(
$DISTRVENDOR
-e
)
"
epm i
$eepm_package
||
fatal
# FIXME: some way to get latest package
rm
-fv
$eepm_package
local
download_link
=
$etersoft_updates_site
/
$(
wget
-qO-
$etersoft_updates_site
/ |
grep
-m1
-Eo
"eepm[^
\"
]+
\.
$(
$DISTRVENDOR
-p
)
"
|
tail
-n1
)
#"
pkg_names
=
pkg_files
=
pkg_urls
=
$download_link
epm_install
}
}
# File bin/epm-filelist:
# File bin/epm-filelist:
...
@@ -1468,6 +1471,7 @@ __alt_local_content_filelist()
...
@@ -1468,6 +1471,7 @@ __alt_local_content_filelist()
{
{
local
CI
=
"
$(
get_local_alt_contents_index
)
"
local
CI
=
"
$(
get_local_alt_contents_index
)
"
[
-n
"
$CI
"
]
||
fatal
"Have no local contents index"
# TODO: safe way to use less
# TODO: safe way to use less
#local OUTCMD="less"
#local OUTCMD="less"
...
@@ -1475,7 +1479,7 @@ __alt_local_content_filelist()
...
@@ -1475,7 +1479,7 @@ __alt_local_content_filelist()
OUTCMD
=
"cat"
OUTCMD
=
"cat"
{
{
[
-n
"
$USETTY
"
]
&&
ech
o
"Search in
$CI
for
$1
..."
[
-n
"
$USETTY
"
]
&&
inf
o
"Search in
$CI
for
$1
..."
grep
-h
--
".*
$1
$"
$CI
|
sed
-e
"s|
\(
.*
\)\t\(
.*
\)
|
\1
|g"
grep
-h
--
".*
$1
$"
$CI
|
sed
-e
"s|
\(
.*
\)\t\(
.*
\)
|
\1
|g"
}
|
$OUTCMD
}
|
$OUTCMD
}
}
...
@@ -1634,6 +1638,10 @@ case $PMTYPE in
...
@@ -1634,6 +1638,10 @@ case $PMTYPE in
__epm_info_rpm_low
&&
return
__epm_info_rpm_low
&&
return
docmd yum info
$pkg_names
docmd yum info
$pkg_names
;;
;;
urpmi-rpm
)
__epm_info_rpm_low
&&
return
docmd urpmq
-i
$pkg_names
;;
dnf-rpm
)
dnf-rpm
)
__epm_info_rpm_low
&&
return
__epm_info_rpm_low
&&
return
docmd dnf info
$pkg_names
docmd dnf info
$pkg_names
...
@@ -1747,15 +1755,6 @@ __separate_sudocmd()
...
@@ -1747,15 +1755,6 @@ __separate_sudocmd()
return
0
return
0
}
}
download_pkg_urls
()
{
local
url
[
-z
"
$1
"
]
&&
return
for
url
in
$*
;
do
eget
$url
||
warning
"Skipped"
done
}
epm_install_names
()
epm_install_names
()
{
{
if
[
-n
"
$non_interactive
"
]
;
then
if
[
-n
"
$non_interactive
"
]
;
then
...
@@ -1858,7 +1857,7 @@ epm_ni_install_names()
...
@@ -1858,7 +1857,7 @@ epm_ni_install_names()
sudocmd apt-get
-y
$noremove
--force-yes
-o
Dpkg::Options::
=
"--force-confdef"
-o
Dpkg::Options::
=
"--force-confold"
$APTOPTIONS
install
$@
sudocmd apt-get
-y
$noremove
--force-yes
-o
Dpkg::Options::
=
"--force-confdef"
-o
Dpkg::Options::
=
"--force-confold"
$APTOPTIONS
install
$@
return
;;
return
;;
aptitude-dpkg
)
aptitude-dpkg
)
sudocmd aptitde
-y
install
$@
sudocmd aptit
u
de
-y
install
$@
return
;;
return
;;
yum-rpm
)
yum-rpm
)
sudocmd yum
-y
$YUMOPTIONS
install
$@
sudocmd yum
-y
$YUMOPTIONS
install
$@
...
@@ -1989,6 +1988,8 @@ epm_install_files()
...
@@ -1989,6 +1988,8 @@ epm_install_files()
apt-rpm
)
apt-rpm
)
__epm_check_if_try_install_deb
$@
&&
return
__epm_check_if_try_install_deb
$@
&&
return
# do not use low-level for install by file path
if
!
is_dirpath
"
$@
"
||
[
"
$(
get_package_type
"
$@
"
)
"
=
"rpm"
]
;
then
sudocmd rpm
-Uvh
$force
$nodeps
$@
&&
return
sudocmd rpm
-Uvh
$force
$nodeps
$@
&&
return
local
RES
=
$?
local
RES
=
$?
...
@@ -1996,6 +1997,7 @@ epm_install_files()
...
@@ -1996,6 +1997,7 @@ epm_install_files()
# if run with --nodeps, do not fallback on hi level
# if run with --nodeps, do not fallback on hi level
[
-n
"
$nodeps
"
]
&&
return
$RES
[
-n
"
$nodeps
"
]
&&
return
$RES
fi
# use install_names
# use install_names
;;
;;
...
@@ -2147,6 +2149,57 @@ epm_print_install_command()
...
@@ -2147,6 +2149,57 @@ epm_print_install_command()
esac
esac
}
}
download_pkg_urls
()
{
local
url
[
-z
"
$pkg_urls
"
]
&&
return
for
url
in
$pkg_urls
;
do
# TODO: use some individual tmp dir
local
new_file
=
/tmp/
$(
basename
"
$url
"
)
if
eget
-O
$new_file
$url
&&
[
-s
"
$new_file
"
]
;
then
pkg_files
=
"
$pkg_files
$new_file
"
to_remove_pkg_files
=
"
$to_remove_pkg_files
$new_file
"
else
warning
"Failed to download
$url
, ignoring"
fi
done
}
__handle_pkg_urls
()
{
[
-n
"
$pkg_urls
"
]
||
return
# TODO: do it correcly
to_remove_pkg_files
=
case
$PMTYPE
in
apt-rpm
)
# ALT Linux really?
pkg_names
=
"
$pkg_names
$pkg_urls
"
;;
#deepsolver-rpm)
# pkg_names="$pkg_names $pkg_urls"
# ;;
#urpm-rpm)
# pkg_names="$pkg_names $pkg_urls"
# ;;
pacman
)
pkg_names
=
"
$pkg_names
$pkg_urls
"
;;
yum-rpm|dnf-rpm
)
pkg_names
=
"
$pkg_names
$pkg_urls
"
;;
#zypper-rpm)
# pkg_names="$pkg_names $pkg_urls"
# ;;
*
)
# use workaround with eget: download and put in pkg_files
download_pkg_urls
;;
esac
pkg_urls
=
}
epm_install
()
epm_install
()
{
{
...
@@ -2155,19 +2208,13 @@ epm_install()
...
@@ -2155,19 +2208,13 @@ epm_install()
return
return
fi
fi
# Download urls via eget pkg_urls and use eget
# in any case it will put pkg_urls into pkg_files or pkg_names
# TODO: use optimization (rpm can download packages by url, yum too?)
__handle_pkg_urls
#[ -n "$pkg_urls" ] && warning "URL using does not realize yet"
#download_pkg_urls "$pkg_urls"
# temp. hack
pkg_files
=
"
$pkg_files
$pkg_urls
"
# TODO: add downloaded files to $pkg_files
[
-z
"
$pkg_files$pkg_names
$pkg_urls
"
]
&&
info
"Skip empty install list"
&&
return
22
[
-z
"
$pkg_files$pkg_names
"
]
&&
info
"Skip empty install list"
&&
return
22
local
names
=
"
$(
echo
$pkg_names
| filter_out_installed_packages
)
"
local
names
=
"
$(
echo
$pkg_names
| filter_out_installed_packages
)
"
local
files
=
"
$(
echo
$pkg_files
| filter_out_installed_packages
)
"
local
files
=
"
$(
echo
$pkg_files
| filter_out_installed_packages
)
"
local
urls
=
"
$(
echo
$pkg_urls
| filter_out_installed_packages
)
"
[
-z
"
$files$names
"
]
&&
info
"Skip empty install list"
&&
return
22
[
-z
"
$files$names
"
]
&&
info
"Skip empty install list"
&&
return
22
...
@@ -2178,6 +2225,11 @@ epm_install()
...
@@ -2178,6 +2225,11 @@ epm_install()
epm_install_names
$names
||
return
epm_install_names
$names
||
return
epm_install_files
$files
epm_install_files
$files
# TODO: reinvent
local
RETVAL
=
$?
[
-n
"
$to_remove_pkg_files
"
]
&&
rm
-fv
$to_remove_pkg_files
return
$RETVAL
}
}
# File bin/epm-Install:
# File bin/epm-Install:
...
@@ -2294,7 +2346,7 @@ epm_kernel_update()
...
@@ -2294,7 +2346,7 @@ epm_kernel_update()
fi
fi
assure_exists update-kernel update-kernel 0.9.9
assure_exists update-kernel update-kernel 0.9.9
sudocmd update-kernel
$pkg_filenames
||
return
sudocmd update-kernel
$pkg_filenames
||
return
sudocmd remove-old-kernels
$pkg_filenames
docmd epm remove-old-kernels
$pkg_filenames
||
fatal
return
;;
return
;;
esac
esac
...
@@ -3619,7 +3671,7 @@ epm_remove_names()
...
@@ -3619,7 +3671,7 @@ epm_remove_names()
sudocmd snappy uninstall
$@
sudocmd snappy uninstall
$@
return
;;
return
;;
zypper-rpm
)
zypper-rpm
)
sudocmd zypper remove
$@
sudocmd zypper remove
--clean-deps
$@
return
;;
return
;;
mpkg
)
mpkg
)
sudocmd mpkg remove
$@
sudocmd mpkg remove
$@
...
@@ -3685,7 +3737,7 @@ epm_remove_nonint()
...
@@ -3685,7 +3737,7 @@ epm_remove_nonint()
sudocmd yum
-y
remove
$@
sudocmd yum
-y
remove
$@
return
;;
return
;;
zypper-rpm
)
zypper-rpm
)
sudocmd zypper
--non-interactive
remove
$@
sudocmd zypper
--non-interactive
remove
--clean-deps
$@
return
;;
return
;;
slackpkg
)
slackpkg
)
sudocmd /usr/sbin/slackpkg
-batch
=
on
-default_answer
=
yes
remove
$@
sudocmd /usr/sbin/slackpkg
-batch
=
on
-default_answer
=
yes
remove
$@
...
@@ -3764,6 +3816,50 @@ epm_remove()
...
@@ -3764,6 +3816,50 @@ epm_remove()
}
}
# File bin/epm-remove_old_kernels:
epm_remove_old_kernels
()
{
case
$DISTRNAME
in
ALTLinux
)
if
!
__epm_query_package kernel-image
>
/dev/null
;
then
info
"No installed kernel packages, skipping cleaning"
return
fi
assure_exists update-kernel update-kernel 0.9.9
sudocmd remove-old-kernels
$pkg_filenames
return
;;
Ubuntu
)
if
!
__epm_query_package linux-image
>
/dev/null
;
then
info
"No installed kernel packages, skipping cleaning"
return
fi
info
"Note: it is enough to use eepm autoremove for old kernel removing..."
info
"Check also http://ubuntuhandbook.org/index.php/2016/05/remove-old-kernels-ubuntu-16-04/"
# http://www.opennet.ru/tips/2980_ubuntu_apt_clean_kernel_packet.shtml
case
$DISTRVERSION
in
10.04|12.04|14.04|15.04|15.10
)
assure_exists purge-old-kernels bikeshed
;;
*
)
# since Ubuntu 16.04
assure_exists purge-old-kernels byobu
;;
esac
sudocmd purge-old-kernels
$pkg_filenames
return
;;
Gentoo
)
sudocmd emerge
-P
gentoo-sources
return
;;
esac
case
$PMTYPE
in
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
esac
}
# File bin/epm-removerepo:
# File bin/epm-removerepo:
epm_removerepo
()
epm_removerepo
()
...
@@ -3990,9 +4086,12 @@ case $PMTYPE in
...
@@ -3990,9 +4086,12 @@ case $PMTYPE in
fi
fi
;;
;;
urpm-rpm|zypper-rpm
)
#zypper-rpm)
# FIXME: use hi level commands
# # FIXME: use hi level commands
CMD
=
"rpm -q --requires"
# CMD="rpm -q --requires"
# ;;
urpm-rpm
)
CMD
=
"urpmq --requires"
;;
;;
yum-rpm
)
yum-rpm
)
if
is_installed
$pkg_names
;
then
if
is_installed
$pkg_names
;
then
...
@@ -4219,13 +4318,13 @@ __alt_local_content_search()
...
@@ -4219,13 +4318,13 @@ __alt_local_content_search()
{
{
local
CI
=
"
$(
get_local_alt_contents_index
)
"
local
CI
=
"
$(
get_local_alt_contents_index
)
"
[
-n
"
$CI
"
]
||
fatal
"Have no local contents index"
#local OUTCMD="less"
#local OUTCMD="less"
#[ -n "$USETTY" ] || OUTCMD="cat"
#[ -n "$USETTY" ] || OUTCMD="cat"
OUTCMD
=
"cat"
OUTCMD
=
"cat"
{
{
[
-n
"
$USETTY
"
]
&&
ech
o
"Search in
$CI
for
$1
..."
[
-n
"
$USETTY
"
]
&&
inf
o
"Search in
$CI
for
$1
..."
# note! tabulation below!
# note! tabulation below!
grep
-h
--
".*
$1
.* "
$CI
|
sed
-e
"s|
\(
.*
\)\t\(
.*
\)
|
\2
:
\1
|g"
grep
-h
--
".*
$1
.* "
$CI
|
sed
-e
"s|
\(
.*
\)\t\(
.*
\)
|
\2
:
\1
|g"
}
|
$OUTCMD
}
|
$OUTCMD
...
@@ -4553,11 +4652,11 @@ epm_update()
...
@@ -4553,11 +4652,11 @@ epm_update()
case
$PMTYPE
in
case
$PMTYPE
in
apt-rpm
)
apt-rpm
)
sudocmd apt-get update
||
exit
sudocmd apt-get update
||
return
#sudocmd apt-get -f install || exit
#sudocmd apt-get -f install || exit
;;
;;
apt-dpkg
)
apt-dpkg
)
sudocmd apt-get update
||
exit
sudocmd apt-get update
||
return
#sudocmd apt-get -f install || exit
#sudocmd apt-get -f install || exit
#sudocmd apt-get autoremove
#sudocmd apt-get autoremove
;;
;;
...
@@ -4565,7 +4664,7 @@ case $PMTYPE in
...
@@ -4565,7 +4664,7 @@ case $PMTYPE in
# sudocmd snappy
# sudocmd snappy
# ;;
# ;;
aptitude-dpkg
)
aptitude-dpkg
)
sudocmd aptitude update
||
exit
sudocmd aptitude update
||
return
;;
;;
yum-rpm
)
yum-rpm
)
info
"update command is stubbed for yum"
info
"update command is stubbed for yum"
...
@@ -4640,26 +4739,28 @@ epm_upgrade()
...
@@ -4640,26 +4739,28 @@ epm_upgrade()
case
$PMTYPE
in
case
$PMTYPE
in
apt-rpm|apt-dpkg
)
apt-rpm|apt-dpkg
)
# non_interactive
local
APTOPTIONS
=
"
$(
subst_option non_interactive
-y
)
"
# Функцию добавления параметра при условии
# Функцию добавления параметра при условии
CMD
=
"apt-get dist-upgrade
$noremove
"
CMD
=
"apt-get
$APTOPTIONS
dist-upgrade
$noremove
"
;;
;;
aptitude-dpkg
)
aptitude-dpkg
)
CMD
=
"aptitude dist-upgrade"
CMD
=
"aptitude dist-upgrade"
;;
;;
yum-rpm
)
yum-rpm
)
local
OPTIONS
=
"
$(
subst_option non_interactive
-y
)
"
# can do update repobase automagically
# can do update repobase automagically
CMD
=
"yum update"
CMD
=
"yum
$OPTIONS
update"
;;
;;
dnf-rpm
)
dnf-rpm
)
CMD
=
"dnf distro-sync"
local
OPTIONS
=
"
$(
subst_option non_interactive
-y
)
"
CMD
=
"dnf
$OPTIONS
distro-sync"
;;
;;
snappy
)
snappy
)
CMD
=
"snappy update"
CMD
=
"snappy update"
;;
;;
urpm-rpm
)
urpm-rpm
)
# or --auto-select --replace-files
# or --auto-select --replace-files
CMD
=
"urpmi --
auto-update
"
CMD
=
"urpmi --
update --auto-select
"
;;
;;
zypper-rpm
)
zypper-rpm
)
CMD
=
"zypper dist-upgrade"
CMD
=
"zypper dist-upgrade"
...
@@ -4750,6 +4851,9 @@ case $PMTYPE in
...
@@ -4750,6 +4851,9 @@ case $PMTYPE in
yum-rpm
)
yum-rpm
)
CMD
=
"repoquery --whatrequires"
CMD
=
"repoquery --whatrequires"
;;
;;
urpm-rpm
)
CMD
=
"urpmq --whatrequires"
;;
dnf-rpm
)
dnf-rpm
)
CMD
=
"repoquery --whatrequires"
CMD
=
"repoquery --whatrequires"
;;
;;
...
@@ -4793,6 +4897,9 @@ case $PMTYPE in
...
@@ -4793,6 +4897,9 @@ case $PMTYPE in
yum-rpm
)
yum-rpm
)
CMD
=
"yum whatprovides"
CMD
=
"yum whatprovides"
;;
;;
urpm-rpm
)
CMD
=
"urpmq --whatprovides"
;;
dnf-rpm
)
dnf-rpm
)
CMD
=
"yum provides"
CMD
=
"yum provides"
;;
;;
...
@@ -4807,9 +4914,9 @@ esac
...
@@ -4807,9 +4914,9 @@ esac
docmd
$CMD
$pkg
docmd
$CMD
$pkg
}
}
internal_distr_info
()
internal_distr_info
()
{
{
#!/bin/sh
# Author: Vitaly Lipatov <lav@etersoft.ru>
# Author: Vitaly Lipatov <lav@etersoft.ru>
# 2007, 2009, 2010, 2012 (c) Etersoft
# 2007, 2009, 2010, 2012 (c) Etersoft
# 2007 Public domain
# 2007 Public domain
...
@@ -5155,6 +5262,99 @@ esac
...
@@ -5155,6 +5262,99 @@ esac
}
}
internal_tools_eget
()
{
# eget - simply shell on wget for loading directories over http
# Example use:
# eget ftp://ftp.altlinux.ru/pub/security/ssl/*
#
# Copyright (C) 2014-2014, 2016 Etersoft
# Copyright (C) 2014 Daniil Mikhailov <danil@etersoft.ru>
# Copyright (C) 2016 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
WGET
=
"wget"
if
[
"
$1
"
=
"-q"
]
;
then
WGET
=
"wget -q"
shift
fi
# TODO:
# download to this file
WGET_OPTION_TARGET
=
if
[
"
$1
"
=
"-O"
]
;
then
TARGETFILE
=
"
$2
"
WGET_OPTION_TARGET
=
"-O
$2
"
shift
2
fi
# TODO:
# -P support
# If ftp protocol or have no asterisk, just download
# TODO: use has()
if
echo
"
$1
"
|
grep
-q
"
\(
^ftp://
\|
[^*]
$\
)"
;
then
$WGET
$WGET_OPTION_TARGET
"
$1
"
return
fi
echo
"Fall to http workaround"
URL
=
$(
echo
"
$1
"
|
grep
"/$"
||
dirname
"
$1
"
)
# mask allowed only in last part of path
MASK
=
$(
basename
"
$1
"
)
get_index
()
{
MYTMPDIR
=
"
$(
mktemp
-d
)
"
INDEX
=
$MYTMPDIR
/index
$WGET
$URL
-O
$INDEX
}
print_files
()
{
cat
$INDEX
|
grep
-o
-E
'href="([^\*/"#]+)"'
|
cut
-d
'"'
-f2
}
create_fake_files
()
{
DIRALLFILES
=
"
$MYTMPDIR
/files/"
mkdir
-p
"
$DIRALLFILES
"
print_files |
while
read
line
;
do
touch
$DIRALLFILES
/
$(
basename
"
$line
"
)
done
}
download_files
()
{
ERROR
=
0
for
line
in
$DIRALLFILES
/
$MASK
;
do
$WGET
$URL
/
$(
basename
"
$line
"
)
||
ERROR
=
1
done
return
$ERROR
}
get_index
||
return
create_fake_files
download_files
||
echo
"There was some download errors"
>
&2
rm
-rf
"
$MYTMPDIR
"
}
#PATH=$PATH:/sbin:/usr/sbin
#PATH=$PATH:/sbin:/usr/sbin
set_pm_type
set_pm_type
...
@@ -5179,7 +5379,7 @@ $(get_help HELPOPT)
...
@@ -5179,7 +5379,7 @@ $(get_help HELPOPT)
print_version
()
print_version
()
{
{
echo
"EPM package manager version 1.
8.6
"
echo
"EPM package manager version 1.
9.1
"
echo
"Running on
$(
$DISTRVENDOR
)
('
$PMTYPE
' package manager uses '
$PKGFORMAT
' package format)"
echo
"Running on
$(
$DISTRVENDOR
)
('
$PMTYPE
' package manager uses '
$PKGFORMAT
' package format)"
echo
"Copyright (c) Etersoft 2012-2016"
echo
"Copyright (c) Etersoft 2012-2016"
echo
"This program may be freely redistributed under the terms of the GNU AGPLv3."
echo
"This program may be freely redistributed under the terms of the GNU AGPLv3."
...
@@ -5358,6 +5558,9 @@ check_command()
...
@@ -5358,6 +5558,9 @@ check_command()
kernel-update|kernel-upgrade|update-kernel|upgrade-kernel
)
# HELPCMD: update system kernel to the last repo version
kernel-update|kernel-upgrade|update-kernel|upgrade-kernel
)
# HELPCMD: update system kernel to the last repo version
epm_cmd
=
kernel_update
epm_cmd
=
kernel_update
;;
;;
remove-old-kernels|remove-old-kernel
)
# HELPCMD: remove old system kernels (exclude current or last two kernels)
epm_cmd
=
remove_old_kernels
;;
# Other commands
# Other commands
clean
)
# HELPCMD: clean local package cache
clean
)
# HELPCMD: clean local package cache
...
@@ -5393,7 +5596,7 @@ check_command()
...
@@ -5393,7 +5596,7 @@ check_command()
site|url
)
# HELPCMD: open package's site in a browser (use -p for open packages.altlinux.org site)
site|url
)
# HELPCMD: open package's site in a browser (use -p for open packages.altlinux.org site)
epm_cmd
=
site
epm_cmd
=
site
;;
;;
ei|epminstall|selfinstall
)
# HELPCMD: install or update eepm from all in one script
ei|epminstall|
epm-install|
selfinstall
)
# HELPCMD: install or update eepm from all in one script
epm_cmd
=
epm_install
epm_cmd
=
epm_install
;;
;;
print
)
# HELPCMD: print various info, run epm print help for details
print
)
# HELPCMD: print various info, run epm print help for details
...
...
packed/serv.sh
View file @
db22b2f8
...
@@ -340,7 +340,8 @@ assure_exists()
...
@@ -340,7 +340,8 @@ assure_exists()
eget
()
eget
()
{
{
$SHAREDIR
/tools-eget
"
$@
"
assure_exists wget
internal_tools_eget
"
$@
"
}
}
get_package_type
()
get_package_type
()
...
@@ -501,6 +502,9 @@ serv_common()
...
@@ -501,6 +502,9 @@ serv_common()
shift
shift
case
$SERVICETYPE
in
case
$SERVICETYPE
in
service-chkconfig|service-upstart
)
service-chkconfig|service-upstart
)
if
is_anyservice
$SERVICE
;
then
fatal
"Have no idea how to call anyservice service with args"
fi
sudocmd service
$SERVICE
"
$@
"
sudocmd service
$SERVICE
"
$@
"
;;
;;
service-initd|service-update
)
service-initd|service-update
)
...
@@ -525,11 +529,17 @@ serv_common()
...
@@ -525,11 +529,17 @@ serv_common()
serv_disable
()
serv_disable
()
{
{
local
SERVICE
=
"
$1
"
is_service_running
$1
&&
{
serv_stop
$1
||
return
;
}
is_service_running
$1
&&
{
serv_stop
$1
||
return
;
}
is_service_autostart
$1
||
{
echo
"Service
$1
already disabled for startup"
&&
return
;
}
is_service_autostart
$1
||
{
echo
"Service
$1
already disabled for startup"
&&
return
;
}
case
$SERVICETYPE
in
case
$SERVICETYPE
in
service-chkconfig|service-upstart
)
service-chkconfig|service-upstart
)
if
is_anyservice
$SERVICE
;
then
sudocmd anyservice
$SERVICE
off
return
fi
sudocmd chkconfig
$1
off
sudocmd chkconfig
$1
off
;;
;;
service-initd|service-update
)
service-initd|service-update
)
...
@@ -547,13 +557,18 @@ serv_disable()
...
@@ -547,13 +557,18 @@ serv_disable()
# File bin/serv-enable:
# File bin/serv-enable:
serv_enable
()
__
serv_enable
()
{
{
is_service_running
$1
||
serv_start
$1
||
return
local
SERVICE
=
"
$1
"
is_service_autostart
$1
&&
echo
"Service
$1
already enabled for startup"
&&
return
is_service_autostart
$1
&&
echo
"Service
$1
already enabled for startup"
&&
return
case
$SERVICETYPE
in
case
$SERVICETYPE
in
service-chkconfig
)
service-chkconfig
)
if
is_anyservice
$SERVICE
;
then
sudocmd anyservice
$SERVICE
on
return
fi
sudocmd chkconfig
--add
$1
||
return
sudocmd chkconfig
--add
$1
||
return
sudocmd chkconfig
$1
on
sudocmd chkconfig
$1
on
;;
;;
...
@@ -574,6 +589,13 @@ serv_enable()
...
@@ -574,6 +589,13 @@ serv_enable()
}
}
serv_enable
()
{
__serv_enable
"
$1
"
||
return
# start if need
is_service_running
$1
||
serv_start
$1
||
return
}
# File bin/serv-list:
# File bin/serv-list:
serv_list
()
serv_list
()
...
@@ -592,6 +614,11 @@ serv_list()
...
@@ -592,6 +614,11 @@ serv_list()
for
i
in
$(
serv_list_all
)
;
do
for
i
in
$(
serv_list_all
)
;
do
is_service_running
$i
>
/dev/null
&&
echo
$i
is_service_running
$i
>
/dev/null
&&
echo
$i
done
done
# TODO: только запущенные
if
[
-n
"
$ANYSERVICE
"
]
;
then
sudocmd
$ANYSERVICE
list
return
fi
;;
;;
esac
esac
}
}
...
@@ -604,6 +631,11 @@ serv_list_all()
...
@@ -604,6 +631,11 @@ serv_list_all()
service-chkconfig|service-upstart
)
service-chkconfig|service-upstart
)
# service --status-all for Ubuntu/Fedora
# service --status-all for Ubuntu/Fedora
sudocmd chkconfig
--list
|
cut
-f1
sudocmd chkconfig
--list
|
cut
-f1
if
[
-n
"
$ANYSERVICE
"
]
;
then
sudocmd anyservice list
return
fi
;;
;;
service-initd|service-update
)
service-initd|service-update
)
sudocmd
ls
$INITDIR
/ |
grep
-v
README
sudocmd
ls
$INITDIR
/ |
grep
-v
README
...
@@ -636,6 +668,35 @@ serv_list_startup()
...
@@ -636,6 +668,35 @@ serv_list_startup()
serv_print
()
serv_print
()
{
{
echo
"Detected init system:
$SERVICETYPE
"
echo
"Detected init system:
$SERVICETYPE
"
[
-n
"
$ANYSERVICE
"
]
&&
echo
"anyservice is detected too"
}
# File bin/serv-reload:
serv_reload
()
{
local
SERVICE
=
"
$1
"
shift
case
$SERVICETYPE
in
service-chkconfig|service-upstart
)
if
is_anyservice
$SERVICE
;
then
sudocmd anyservice
$SERVICE
reload
return
fi
sudocmd service
$SERVICE
reload
"
$@
"
;;
service-initd|service-update
)
sudocmd
$INITDIR
/
$SERVICE
reload
"
$@
"
;;
systemd
)
sudocmd systemctl reload
$SERVICE
"
$@
"
;;
*
)
fatal
"Have no suitable command for
$SERVICETYPE
"
;;
esac
}
}
# File bin/serv-restart:
# File bin/serv-restart:
...
@@ -648,6 +709,10 @@ serv_restart()
...
@@ -648,6 +709,10 @@ serv_restart()
case
$SERVICETYPE
in
case
$SERVICETYPE
in
service-chkconfig|service-upstart
)
service-chkconfig|service-upstart
)
if
is_anyservice
$SERVICE
;
then
sudocmd anyservice
$SERVICE
restart
return
fi
sudocmd service
$SERVICE
restart
"
$@
"
sudocmd service
$SERVICE
restart
"
$@
"
;;
;;
service-initd|service-update
)
service-initd|service-update
)
...
@@ -671,6 +736,10 @@ serv_start()
...
@@ -671,6 +736,10 @@ serv_start()
case
$SERVICETYPE
in
case
$SERVICETYPE
in
service-chkconfig|service-upstart
)
service-chkconfig|service-upstart
)
if
is_anyservice
$SERVICE
;
then
sudocmd anyservice
$SERVICE
start
return
fi
sudocmd service
$SERVICE
start
"
$@
"
sudocmd service
$SERVICE
start
"
$@
"
;;
;;
service-initd|service-update
)
service-initd|service-update
)
...
@@ -689,8 +758,14 @@ serv_start()
...
@@ -689,8 +758,14 @@ serv_start()
is_service_running
()
is_service_running
()
{
{
local
SERVICE
=
"
$1
"
case
$SERVICETYPE
in
case
$SERVICETYPE
in
service-chkconfig|service-upstart
)
service-chkconfig|service-upstart
)
if
is_anyservice
$1
;
then
$SUDO
anyservice
$1
status
>
/dev/null
return
fi
$SUDO
service
$1
status
>
/dev/null
$SUDO
service
$1
status
>
/dev/null
;;
;;
service-initd|service-update
)
service-initd|service-update
)
...
@@ -707,8 +782,15 @@ is_service_running()
...
@@ -707,8 +782,15 @@ is_service_running()
is_service_autostart
()
is_service_autostart
()
{
{
local
SERVICE
=
"
$1
"
case
$SERVICETYPE
in
case
$SERVICETYPE
in
service-chkconfig|service-upstart
)
service-chkconfig|service-upstart
)
if
is_anyservice
$SERVICE
;
then
$ANYSERVICE
$SERVICE
isautostarted
return
fi
# FIXME: check for current runlevel
# FIXME: check for current runlevel
LANG
=
C
$SUDO
chkconfig
$1
--list
|
grep
-q
"[35]:on"
LANG
=
C
$SUDO
chkconfig
$1
--list
|
grep
-q
"[35]:on"
;;
;;
...
@@ -733,6 +815,10 @@ serv_status()
...
@@ -733,6 +815,10 @@ serv_status()
case
$SERVICETYPE
in
case
$SERVICETYPE
in
service-chkconfig|service-upstart
)
service-chkconfig|service-upstart
)
if
is_anyservice
$SERVICE
;
then
sudocmd anyservice
$SERVICE
status
return
fi
sudocmd service
$SERVICE
status
"
$@
"
sudocmd service
$SERVICE
status
"
$@
"
;;
;;
service-update
)
service-update
)
...
@@ -756,6 +842,10 @@ serv_stop()
...
@@ -756,6 +842,10 @@ serv_stop()
case
$SERVICETYPE
in
case
$SERVICETYPE
in
service-chkconfig|service-upstart
)
service-chkconfig|service-upstart
)
if
is_anyservice
$SERVICE
;
then
sudocmd anyservice
$SERVICE
stop
return
fi
sudocmd service
$SERVICE
stop
"
$@
"
sudocmd service
$SERVICE
stop
"
$@
"
;;
;;
service-initd|service-update
)
service-initd|service-update
)
...
@@ -781,7 +871,7 @@ serv_try_restart()
...
@@ -781,7 +871,7 @@ serv_try_restart()
case
$SERVICETYPE
in
case
$SERVICETYPE
in
service-chkconfig|service-upstart
)
service-chkconfig|service-upstart
)
is_service_running
$SERVICE
||
return
0
is_service_running
$SERVICE
||
return
0
sudocmd service
$SERVICE
restart
"
$@
"
docmd serv
$SERVICE
restart
"
$@
"
;;
;;
service-initd|service-update
)
service-initd|service-update
)
is_service_running
$SERVICE
||
return
0
is_service_running
$SERVICE
||
return
0
...
@@ -828,9 +918,9 @@ serv_usage()
...
@@ -828,9 +918,9 @@ serv_usage()
_print_additional_usage
_print_additional_usage
}
}
internal_distr_info
()
internal_distr_info
()
{
{
#!/bin/sh
# Author: Vitaly Lipatov <lav@etersoft.ru>
# Author: Vitaly Lipatov <lav@etersoft.ru>
# 2007, 2009, 2010, 2012 (c) Etersoft
# 2007, 2009, 2010, 2012 (c) Etersoft
# 2007 Public domain
# 2007 Public domain
...
@@ -1176,6 +1266,99 @@ esac
...
@@ -1176,6 +1266,99 @@ esac
}
}
internal_tools_eget
()
{
# eget - simply shell on wget for loading directories over http
# Example use:
# eget ftp://ftp.altlinux.ru/pub/security/ssl/*
#
# Copyright (C) 2014-2014, 2016 Etersoft
# Copyright (C) 2014 Daniil Mikhailov <danil@etersoft.ru>
# Copyright (C) 2016 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
WGET
=
"wget"
if
[
"
$1
"
=
"-q"
]
;
then
WGET
=
"wget -q"
shift
fi
# TODO:
# download to this file
WGET_OPTION_TARGET
=
if
[
"
$1
"
=
"-O"
]
;
then
TARGETFILE
=
"
$2
"
WGET_OPTION_TARGET
=
"-O
$2
"
shift
2
fi
# TODO:
# -P support
# If ftp protocol or have no asterisk, just download
# TODO: use has()
if
echo
"
$1
"
|
grep
-q
"
\(
^ftp://
\|
[^*]
$\
)"
;
then
$WGET
$WGET_OPTION_TARGET
"
$1
"
return
fi
echo
"Fall to http workaround"
URL
=
$(
echo
"
$1
"
|
grep
"/$"
||
dirname
"
$1
"
)
# mask allowed only in last part of path
MASK
=
$(
basename
"
$1
"
)
get_index
()
{
MYTMPDIR
=
"
$(
mktemp
-d
)
"
INDEX
=
$MYTMPDIR
/index
$WGET
$URL
-O
$INDEX
}
print_files
()
{
cat
$INDEX
|
grep
-o
-E
'href="([^\*/"#]+)"'
|
cut
-d
'"'
-f2
}
create_fake_files
()
{
DIRALLFILES
=
"
$MYTMPDIR
/files/"
mkdir
-p
"
$DIRALLFILES
"
print_files |
while
read
line
;
do
touch
$DIRALLFILES
/
$(
basename
"
$line
"
)
done
}
download_files
()
{
ERROR
=
0
for
line
in
$DIRALLFILES
/
$MASK
;
do
$WGET
$URL
/
$(
basename
"
$line
"
)
||
ERROR
=
1
done
return
$ERROR
}
get_index
||
return
create_fake_files
download_files
||
echo
"There was some download errors"
>
&2
rm
-rf
"
$MYTMPDIR
"
}
INITDIR
=
/etc/init.d
INITDIR
=
/etc/init.d
PATH
=
$PATH
:/sbin:/usr/sbin
PATH
=
$PATH
:/sbin:/usr/sbin
...
@@ -1242,8 +1425,17 @@ is_active_systemd && CMD="systemd"
...
@@ -1242,8 +1425,17 @@ is_active_systemd && CMD="systemd"
SERVICETYPE
=
$CMD
SERVICETYPE
=
$CMD
ANYSERVICE
=
$(
which anyservice 2>/dev/null
)
}
}
# TODO: done it on anyservice part
is_anyservice
()
{
[
-n
"
$ANYSERVICE
"
]
||
return
# check if anyservice is exists and checkd returns true
$ANYSERVICE
"
$1
"
checkd 2>/dev/null
}
phelp
()
phelp
()
...
@@ -1260,7 +1452,7 @@ $(get_help HELPOPT)
...
@@ -1260,7 +1452,7 @@ $(get_help HELPOPT)
print_version
()
print_version
()
{
{
echo
"Service manager version 1.
8.6
"
echo
"Service manager version 1.
9.1
"
echo
"Running on
$(
$DISTRVENDOR
)
"
echo
"Running on
$(
$DISTRVENDOR
)
"
echo
"Copyright (c) Etersoft 2012, 2013, 2016"
echo
"Copyright (c) Etersoft 2012, 2013, 2016"
echo
"This program may be freely redistributed under the terms of the GNU AGPLv3."
echo
"This program may be freely redistributed under the terms of the GNU AGPLv3."
...
@@ -1298,7 +1490,9 @@ check_command()
...
@@ -1298,7 +1490,9 @@ check_command()
restart
)
# HELPCMD: restart service
restart
)
# HELPCMD: restart service
serv_cmd
=
restart
serv_cmd
=
restart
;;
;;
#reload) # HELPCMD: reload service
reload
)
# HELPCMD: reload service
serv_cmd
=
reload
;;
start
)
# HELPCMD: start service
start
)
# HELPCMD: start service
serv_cmd
=
start
serv_cmd
=
start
;;
;;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment