#!/bin/sh -e

# Script for upgrade ALT SP Server (release 9) to ALT SP Server (release 10)
# Copyright (c) 2024 Andrey Cherepanov <cas@basealt.ru>

# This program is free software; you can redistribute it and/or modify it
# under the terms of GNU General Public License (GPL) version 3 or later.

if [ "$EUID" -ne 0 ]
  then echo "Please run as root"
  exit
fi

apt-get -y remove python3-module-pygobject3

apt-repo rm all
apt-repo add 'rpm [cert8] http://update.altsp.su/pub/distributions/ALTLinux c10f/branch/x86_64 classic gostcrypto'
apt-repo add 'rpm [cert8] http://update.altsp.su/pub/distributions/ALTLinux c10f/branch/x86_64-i586 classic'
apt-repo add 'rpm [cert8] http://update.altsp.su/pub/distributions/ALTLinux c10f/branch/noarch classic'
apt-get update

apt-get -y install branding-alt-spserver-release
/etc/init.d/udevd umount || true
apt-get -y install dev
/etc/init.d/udevd restart || true
apt-get -y dist-upgrade
apt-get -y dist-upgrade

rpm -e --nodeps python3-module-ndg libcanberra libbroker libcaf unixODBC libunixODBC2 xblas libxblas python3-module-google-api-client python3-module-markdown
apt-get -fy install

apt-get update && apt-get dist-upgrade -y

apt-get -y install dev-minimal apache2-mod_perl bpython3 cloud-init freeipa-client gcr gcr-libs git hwinfo-utils ibus integ libbrasero libcanberra-gtk3 libclutter libclutter-gtk3 libgtk+3-gir libwebkit2gtk libwxGTK3.0 libwxGTK3.0-gl libwxGTK3.0-media libwxGTK3.0-webview lsb lsb-desktop lsb-languages mkbootflash ntp ntp-utils osec-controls osec-cronjob osec-mailreport pacemaker pacemaker-cli pcs perl-Apache-Session perl-App-Nopaste perl-Archive-Tar perl-Archive-Zip perl-B-Hooks-EndOfScope perl-BSD-Resource perl-CGI-Emulate-PSGI perl-CGI-Session perl-CPAN perl-CPAN-Reporter perl-Class-Load perl-Class-Refresh perl-DBD-InterBase perl-DBD-Pg perl-DBD-mysql perl-DBI perl-DBIx-DBSchema perl-DBIx-SearchBuilder perl-DateTime perl-DateTime-Format-DateParse perl-DateTime-Format-Mail perl-DateTime-Format-Natural perl-DateTime-Format-W3CDTF perl-DateTime-Locale perl-DateTime-TimeZone perl-Devel-Caller perl-Devel-LexAlias perl-Devel-OverloadInfo perl-Digest-SHA perl-Digest-SHA1 perl-Eval-Closure perl-Git perl-GnuPG-Interface perl-HTML-Form perl-HTML-FormatText-WithLinks perl-HTML-FormatText-WithLinks-AndTables perl-HTML-Formatter perl-HTML-Mason perl-HTML-Mason-PSGIHandler perl-HTML-Tree perl-HTTP-Server-Simple-Mason perl-IO-Socket-SSL perl-IO-Zlib perl-Image-Info perl-LWP-Protocol-https perl-Locale-Maketext-Lexicon perl-Log-Dispatch perl-Log-Dispatch-Perl perl-Log-Log4perl perl-MIME-Lite perl-MIME-tools perl-Magick perl-MailTools perl-MooX-late perl-Moose perl-Net-HTTPS perl-Net-IDN-Encode perl-Net-SMTP-SSL perl-Net-Server perl-Package-DeprecationManager perl-Package-Stash perl-Package-Stash-XS perl-Params-ValidationCompiler perl-Plack perl-Plack-Middleware-Test-StashWarnings perl-RPM2 perl-Reply perl-Specio perl-Starlet perl-Sub-Identify perl-Template perl-Test-SharedFork perl-Test-Stream perl-Test-TCP perl-Type-Tiny perl-Variable-Magic perl-WWW-Mechanize perl-WWW-Pastebin-PastebinCom-Create perl-XML-DOM perl-XML-Parser perl-XML-RSS perl-XML-XPath perl-ldap perl-namespace-autoclean perl-namespace-clean pix policycoreutils python-module-wx3.0 python3-module-Naked python3-module-OpenSSL python3-module-Pygments python3-module-alabaster python3-module-algopy python3-module-automat python3-module-boto python3-module-crypto python3-module-cryptography python3-module-dbus python3-module-fasteners python3-module-fixtures python3-module-freeipa python3-module-ipaclient python3-module-keyring python3-module-matplotlib python3-module-matplotlib-cairo python3-module-matplotlib-gtk3 python3-module-matplotlib-tk python3-module-mpl_toolkits python3-module-ndg-httpsclient python3-module-networkx python3-module-networkx-core python3-module-networkx-drawing python3-module-numdifftools python3-module-numpy-testing python3-module-numpy-tests python3-module-oauth2client python3-module-openpyxl python3-module-pandas python3-module-pandas-tests python3-module-paramiko python3-module-pcs python3-module-policycoreutils python3-module-pycares python3-module-pycurl python3-module-pygobject3 python3-module-pynacl python3-module-requests python3-module-samba python3-module-schedutils python3-module-scikits.statsmodels python3-module-scikits.statsmodels-tests python3-module-scipy python3-module-secretstorage python3-module-setools python3-module-snmp python3-module-sphinx python3-module-sphinxcontrib-applehelp python3-module-sphinxcontrib-devhelp python3-module-sphinxcontrib-htmlhelp python3-module-sphinxcontrib-jsmath python3-module-sphinxcontrib-qthelp python3-module-sphinxcontrib-serializinghtml python3-module-talloc python3-module-testscenarios python3-module-testtools python3-module-tornado python3-module-twisted-conch python3-module-twisted-core python3-module-twisted-core-test python3-module-twisted-logger python3-module-twisted-names python3-module-twisted-pair python3-module-twisted-positioning python3-module-twisted-runner python3-module-twisted-web python3-module-twisted-words python3-module-urllib3 rt rt-mailgate samba-dc samba-dc-client sp syslinux tuned updater

update-kernel -t un-def -y

rpm -e --nodeps libasyncns libcom_err libcups libgsm libieee1284 libwebp7 libwireless libXrandr libxshmfence libXxf86vm
apt-get -fy install
apt-get -y install btrfs-progs e2fsprogs etcnet etcnet-defaults-server foo2zjs ifrename ima-evm-integrity-check interactivesystem krb5-kadmin krb5-kdc ldap-user-tools libe2fs libss lsb-core   lz11-V2 mc quota updater 
rpm -e --nodeps libSM libXau libXcomposite libXcursor libXdmcp libXext libXfixes libXinerama
apt-get -fy install
rpm -e --nodeps libjbig liblame liblmdb
apt-get -fy install

rpm -e --nodeps apache-commons-logging bash-builtin-lockf control++-wl cpp8 fuse GConf hashalot ilmbase24-common ipt-so libaom2 libbeecrypt7 libboost_iostreams1.67.0 libboost_system1.67.0 libboost_thread1.67.0 libcloudproviders libcrypt-devel libffi6 libGConf libGLU libgnome-keyring libgraphene-gir libgtk4 libgtk4-gir libhalf24 libhogweed4 libiex24 libilmimf24 libilmthread24 libimaevm0 libjson-c4 libmozjs60 libnettle6 libnsl2 libnumpy libnumpy-py3 libpoppler90 libprotobuf17 libqhull libre2 libtk libx265-160 libxmlrpc libxmlrpc++ libxmlrpc-client ndpi-netfilter openexr24-common osec-controls python3-module-apipkg python3-module-asn1crypto python3-module-atomicwrites python3-module-bcrypt python3-module-black python3-module-cycler python3-module-dateutil python3-module-h2 python3-module-hamcrest python3-module-hpack python3-module-hyperframe python3-module-hypothesis python3-module-iniconfig python3-module-IPy python3-module-kiwisolver python3-module-lark-parser python3-module-libcst python3-module-matplotlib python3-module-matplotlib-cairo python3-module-matplotlib-gtk3 python3-module-matplotlib-tk python3-module-more-itertools python3-module-mpl_toolkits python3-module-mpmath python3-module-nose python3-module-numpy python3-module-numpy-testing python3-module-pathspec python3-module-priority python3-module-py python3-module-pytest python3-module-regex python3-module-scipy python3-module-setuptools python3-module-sortedcontainers python3-modules-tkinter python3-module-toml python3-module-twisted-conch python3-module-twisted-core-tests python3-module-twisted-pair python3-module-twisted-positioning python3-module-twisted-runner python3-module-twisted-web python3-module-typing-inspect python-base python-module-audit python-module-cython-hidapi python-module-numpy python-module-pkg_resources python-module-pycairo python-module-serial python-strict pytz-zoneinfo sudo tcl-tix tk tripso udev-rule-generator udev-rule-generator-net vlan-utils xml-commons-apis xsltproc kernel-modules-ipt-so-std-def kernel-modules-ndpi-std-def
apt-get -fy install

apt-get clean

systemctl disable integalert systemd-update-done.service system-update-cleanup.service
systemctl daemon-reload && systemctl daemon-reexec


UDEV_RULE="/etc/udev/rules.d/80-net-setup-link.rules"
if [[ ! -L $UDEV_RULE ]]; then
    ln -s /dev/null $UDEV_RULE
fi    

echo
echo "Upgrade is complete."
echo

