Как организовать управление группой ПК: различия между версиями

Материал из IT в школе
Перейти к навигацииПерейти к поиску
нет описания правки
Строка 1: Строка 1:




Строка 133: Строка 134:


После этого периодически (каждые 60 сек ) загружает и запускает файл reg.sh
После этого периодически (каждые 60 сек ) загружает и запускает файл reg.sh
В файл reg sh я добавляю при необходимости неотложные команды (обычно он пуст)
В файл start.sh записаны скрипты инициализации ПК:<syntaxhighlight lang="bash">
set_mime()
{
#mime om libreofuice
if [ ! -f /etc/xdg/local/mimeapps.list ]; then
mkdir /etc/xdg/local
echo 'XDG_CONFIG_DIRS="/etc/xdg/local:$XDG_CONFIG_DIRS"' > /etc/profile.d/00-local.sh
chmod +x /etc/profile.d/00-local.sh
cp /etc/xdg/mos/mimeapps.list /etc/xdg/local/
sed -i '/^#.\+$/d'  /etc/xdg/local/mimeapps.list
sed -i 's/onlyoffice-desktopeditors.desktop;//g' /etc/xdg/local/mimeapps.list
sed -i 's/r7-office-desktopeditors.desktop;//g' /etc/xdg/local/mimeapps.list
sed -i '/^application\/vnd/  s/$/r7-office-desktopeditors.desktop;onlyoffice-desktopeditors.desktop;/' /etc/xdg/local/mimeapps.list
sed -i '/^text\/csv/  s/$/r7-office-desktopeditors.desktop;onlyoffice-desktopeditors.desktop;/' /etc/xdg/local/mimeapps.list
sed -i '/^application\/rtf/  s/$/r7-office-desktop;onlyoffice-desktopeditors.desktop;/' /etc/xdg/local/mimeapps.list
sed -i '/^application\/msword/  s/$/r7-office-desktop;onlyoffice-desktopeditors.desktop;/' /etc/xdg/local/mimeapps.list
fi
}
set_grub_timeout0()
{
#grub disable timeout
sed -i -r 's/^#*(GRUB_TIMEOUT=).*/GRUB_TIMEOUT=0/' /etc/sysconfig/grub2
sed -i -r 's/^#*(GRUB_HIDDEN_TIMEOUT=).*/GRUB_HIDDEN_TIMEOUT=$GRUB_TIMEOUT/' /etc/sysconfig/grub2
grub-mkconfig -o /boot/grub/grub.cfg
}
set_shutdown()
{
if [ -z "`crontab -l | grep shutdown`" ]; then
echo -e "@reboot /root/onreboot.sh\n0 22 * * * /sbin/shutdown now\n0 7 * * * /sbin/shutdown now\n" | crontab -u root -
fi
}
set_kde()
{
#set some flags
FD=`cat /home/${USR}/.config/plasma-org.kde.plasma.desktop-appletsrc | grep alphaSort`
if  [ "${FD}" == "" ]; then
sed -i '/^favoritesPortedToKAstats=.*/i alphaSort=true\nlimitDepth=true\nshowIconsRootLevel=true' /home/${USR}/.config/plasma-org.kde.plasma.desktop-appletsrc
fi
#отключение масштаба
if [ -z "`cat /home/${USR}/.config/kwinrc | grep 'zoomEnabled=false'`"  ]; then
echo -e "[Plugins]\nzoomEnabled=false\n" >>  /home/${USR}/.config/kwinrc
fi
#отключить засыпание
sed -i '/AC\]\[DPMS/,+2d' /home/${USR}/.config/powermanagementprofilesrc
sed -i '/AC\]\[DimDisp/,+2d' /home/${USR}/.config/powermanagementprofilesrc
#блокировка файлов настроек
cd /home/${USR}/.config/
for i in plasma-org.kde.plasma.desktop-appletsrc kdeglobals  powermanagementprofilesrc systemsettingsrc kcmfonts
do
if [ ! -z "${LOCK}" ] ; then
chown root:${USR} ${i}
chmod 040 ${i}
else
chown ${USR}:${USR} ${i}
chmod 644 ${i}
fi
done
}
create_veyon_share()
{
#создать общую папку
echo -e "[Desktop Entry]\nIcon=folder-remote\nName=Задания\nType=Application\nExec=dolphin sftp://${USR}:648@${VEYON}/home/share" > "/home/${USR}/Рабочий стол/share.desktop"
chown ${USR}:${USR}  "/home/${USR}/Рабочий стол/share.desktop"
chmod 744 "/home/${USR}/Рабочий стол/share.desktop"
#создать каталог сдать работы
mkdir "/home/${USR}/Рабочий стол/Сдать работы"
chown ${USR}:${USR} "/home/${USR}/Рабочий стол/Сдать работы"
}
clean_wifi()
{
#удалить wifi соединения
rm /etc/NetworkManager/system-connections/Study.MOS.nmconnection
rm /etc/NetworkManager/system-connections/Study.nmconnection
}
setup_chromium()
{
#создать хромиум on desktop
echo -e "#!/usr/bin/env xdg-open\n[Desktop Entry]\nIcon=chromium\nName=Chromium\nType=Application\nExec=chromium" > "/home/${USR}/Рабочий стол/Chromium.desktop"
chown ${USR}:${USR}  "/home/${USR}/Рабочий стол/Chromium.desktop"
chmod 744 "/home/${USR}/Рабочий стол/Chromium.desktop"
#  Установка Chrome браузером по умолчанию
if [ ! -f /home/student/.config/mimeapps.list ]; then
    echo -e '#!/usr/bin/env xdg-open\n[Default Applications]\nx-scheme-handler/http=chromium\nx-scheme-handler/https=chromium'  > "/home/${USR}/.config/mimeapps.list"
    chown ${USR}:${USR} /home/${USR}/.config/mimeapps.list
else
    sed -i -r 's/(http=|https=).*/\1chromium/' "/home/${USR}/.config/mimeapps.list"
fi
}
clean()
{
CLN="${CLEAN} /home/teacher/default.png /root/upd.sh /home/${USR}/Рабочий__стол/Chromium home/${USR}/Рабочий_стол/Основы__работы__в__МОС.desktop /home/${USR}/Рабочий__стол/Основы__работы__в__МОС /home/${USR}/Рабочий__стол/yandex-browser.desktop /home/${USR}/Рабочий__стол/mosobrtv.desktop /home/${USR}/Рабочий__стол/Chromium"
for i in ${CLN}
do
NAME="${i//__/ /}"
echo DELETE $NAME
rm -f "${NAME}"
done
}
check_repo()
{
#remove some repos
if [ -f /etc/apt/sources.list.d/alt.list ] || [ -f /etc/apt/sources.list.d/yandex.list ] || [ -f /etc/apt/sources.list.d/ipsl.list ] || [ -f /etc/apt/sources.list.d/heanet.list ]; then
rm  /etc/apt/sources.list.d/*
fi
if [ ! -z '`cat /etc/apt/sources.list.d/mos-base-repo.list | grep "#"`' ] || [ ! -f '/etc/apt/sources.list.d/mos-base-repo.list' ]; then
echo -e "rpm http://repo.os.mos.ru/a/p10/base/release x86_64 classic\nrpm http://repo.os.mos.ru/a/p10/base/release x86_64-i586 classic\nrpm http://repo.os.mos.ru/a/p10/base/release noarch classic\n" > /etc/apt/sources.list.d/mos-base-repo.list
fi
if [ ! -z '`cat /etc/apt/sources.list.d/mos-repo.list | grep "#"`' ] || [ ! -f '/etc/apt/sources.list.d/mos-repo.list' ]; then
echo -e "rpm http://repo.os.mos.ru/a/p10/mos/release x86_64 hasher\nrpm http://repo.os.mos.ru/a/p10/mos/release noarch hasher\nrpm http://repo.os.mos.ru/a/p10/mos/release x86_64-i586 hasher\n" > /etc/apt/sources.list.d/mos-repo.list
fi
}
update()
{
check_repo
remove-old-kernels -f
apt-get update
apt-get -y dist-upgrade
update-kernel -f
apt-get clean
}
setup_wallpaper()
{
if [ ! -f  /etc/648.png ]; then
wget -O /etc/648.png http://${SERVER}/648.png
fi
if [ -z "`cat /home/${USR}/.config/plasma-org.kde.plasma.desktop-appletsrc | grep 648.png`" ]; then
sed -i 's/^Image=.\+$/Image=\/etc\/648\.png/g' /home/${USR}/.config/plasma-org.kde.plasma.desktop-appletsrc
fi
}
setup_x11vnc()
{
if [ ! -f /root/vnc/passwd ]; then
/sbin/chkconfig x11vnc on
/sbin/service x11vnc start
mkdir /root/.vnc/
x11vnc --storepasswd password /root/.vnc/passwd
fi
}
setup_pkt()
{
remove-old-kernels -y
apt-get -y remove ${REMOVE}
for i in ${INSTALL}
do
echo INSTALL ${i} ?
if [ -z "`rpm -qa | grep  -e \"${i}-[0-9]\" `" ] ; then
echo INSTALL ${i} !
apt-get -y install ${INSTALL}
else
echo ALREADY INSTALLED
fi
done
for i in ${INSTALLEPM}
do
echo INSALLEPM ${i} ?
if [ ! -f  "/usr/bin/${i}" ] ; then
echo INSALLEPM ${i} !
NAME="$(echo $i | tr '[A-Z]' '[a-z]')"
epm play --auto ${NAME}
else
echo ALREADY INSTALLED
fi
done
}
setup_timesync()
{
if [ -f /etc/systemd/timesyncd.conf ]; then
if [ -z "`cat /etc/systemd/timesyncd.conf | grep ${SERVER}`" ] ; then
echo "NTP=${SERVER}" >> /etc/systemd/timesyncd.conf
systemctl enable systemd-timesyncd
systemctl restart systemd-timesyncd
fi
fi
}
vbox_user()
{
USER="$1"
if [ -z "`cat /etc/group | grep vboxusers`" ] ;  then
return
fi
if [ -z "`cat /etc/group | grep vboxusers | grep ${USER}`" ] ;  then
usermod -a -G vboxusers ${USER}
fi
}
setup_lo()
{
if [ ! -h /usr/bin/libreoffice ]; then
ln -s /opt/libreoffice7.5/program/soffice /usr/bin/libreoffice
fi
mv /usr/share/applications/libreoffice7.5-base.desktop /usr/share/applications/base.desktop
mv /usr/share/applications/libreoffice7.5-calc.desktop /usr/share/applications/calc.desktop
mv /usr/share/applications/libreoffice7.5-draw.desktop /usr/share/applications/draw.desktop
mv /usr/share/applications/libreoffice7.5-impress.desktop /usr/share/applications/impress.desktop
mv /usr/share/applications/libreoffice7.5-math.desktop /usr/share/applications/math.desktop
mv /usr/share/applications/libreoffice7.5-writer.desktop /usr/share/applications/writer.desktop
mv /usr/share/applications/libreoffice7.5-startcenter.desktop /usr/share/applications/startcenter.desktop
mv /usr/share/applications/libreoffice7.5-xsltfilter.desktop /usr/share/applications/xsltfilter.desktop
if [  -d /opt/libreoffice7.5 ]; then
return
fi
cd /tmp
rm lo.tar.gz
wget http://${SERVER}/lo.tar.gz
tar xvf lo.tar.gz
apt-get -y install /tmp/RPMS/*.rpm
rm lo.tar.gz
rm -rf /tmp/RPMS/
for USR in ${USERS}
do
rm -rf /home/${USR}/.config/.libreoffice
done
}
setup_bl()
{
if [  -d /opt/blender* ]; then
return
fi
cd /opt
rm bl.tar.xz
wget http://${SERVER}/bl.tar.xz
tar xvf bl.tar.xz
rm bl.tar.xz
CAT="`ls /opt/ | grep blender`"
cp /opt/${CAT}/blender.desktop /usr/share/applications/blender.desktop
rm /usr/bin/blender
ln -s /opt/${CAT}/blender /usr/bin/blender
}
setup_panel()
{
echo "*****************************************"
echo "*****************PANEL*******************"
echo "*****************************************"
REMOVE="apt-indicator cheese"
INSTALL="yandex-browser-stable kde5-kamerka guvcview x11vnc-service"
EPM=""
update
setup_timesync
set_mime
setup_pkt
setup_x11vnc
set_shutdown
for USR in ${USERS}
do
echo user ${USR}
clean
set_kde
setup_wallpaper
#clean
CLEAN="/home/${USR}/.local/share/plasma_icons/catalogue.desktop /home/${USR}/.local/share/plasma_icons/r7-office-desktopeditors.desktop /home/${USR}/Рабочий__сто��/Общая__папка"
#start page
wget -O /etc/start_.html http://${SERVER}/start.html
if [ -f /etc/start_.html ] ; then
rm /etc/start.html
mv /etc/start_.html /etc/start.html
sed -i 's/^Exec=.\+$/Exec=chromium --enable-local-file-accesses \/etc\/start.html/g' /home/${USR}/.local/share/plasma_icons/chromium.desktop
fi
#set common folder
sed -i  /nas648/,/bookmark/d /home/${USR}/.local/share/user-places.xbel
TT=`cat /home/teacher/.local/share/user-places.xbel | grep "${SERVER}"`
if  [ "${TT}" == "" ]; then
echo -e "<bookmark href=\"smb://boards:boards@${SERVER}/boards\">\n<title>\nОбщая папка\n</title>\n</bookmark>" > /tmp/add.txt
sed -i '/<\/xbel>/{
r /tmp/add.txt
a <\/xbel>
d
}' /home/${USR}/.local/share/user-places.xbel
rm /tmp/add.txt
fi
done
}
setup_note()
{
echo "*****************************************"
echo "*****************NOTE********************"
echo "*****************************************"
REMOVE="apt-indicator cheese kernel-modules-e1000e-std-def LibreOffice-common blender openboard"
INSTALL="yandex-browser-stable kde5-kamerka xorg-96dpi guvcview x11vnc-service systemd-timesyncd"
INSTALLEPM="zoom teams skype sferum Telegram viber tamtam"
update
set_mime
setup_lo
setup_bl
setup_pkt
setup_x11vnc
setup_timesync
#hold hp
if [ -z "`cat /etc/apt/apt.conf.d/hold-hplip.conf | grep hplip`" ] ; then
echo 'RPM::Hold { ^hplip; };' > /etc/apt/apt.conf.d/hold-hplip.conf
fi
for USR in ${USERS}
do
echo user ${USR}
#clean
#set_kde
done
}
setup_cc()
{
echo "****************************************"
echo "*****************CC*********************"
echo "****************************************"
REMOVE="apt-indicator cheese LibreOffice-common blender openboard"
INSTALL="yandex-browser-stable kde5-kamerka guvcview pinta virtualbox x11vnc-service systemd-timesyncd"
INSTALLEPM="zoom teams skype sferum Telegram viber tamtam"
update
set_mime
clean
setup_lo
setup_bl
setup_pkt
setup_x11vnc
setup_timesync
if [ ! -z "${TIMEOUT}" ]; then
set_grub_timeout0
fi
setup_wine
clean_wifi
set_shutdown
vbox_user student
vbox_user teacher
rm -rf /home/student/.config/.libreoffice
for USR in ${USERS}
do
echo user ${USR}
set_kde
setup_chromium
create_veyon_share
setup_wallpaper
done
}
setup_other()
{
echo "****************************************"
echo "*****************OTHER******************"
echo "****************************************"
REMOVE="apt-indicator cheese LibreOffice-common blender"
INSTALL="yandex-browser-stable kde5-kamerka guvcview pinta virtualbox x11vnc-service systemd-timesyncd"
INSTALLEPM="zoom teams skype sferum Telegram viber tamtam"
update
set_mime
clean
setup_lo
setup_bl
setup_pkt
setup_x11vnc
setup_timesync
for USR in `ls /home/ | grep -v MOS.RU`
do
echo user ${USR}
set_kde
setup_chromium
done
}
HN=`hostname`
TYPE=${HN:0:1}
IN=(${HN//-/ })
CORP=${IN[1]}
CAB=${IN[2]}
COMP=${IN[3]}
if [ ${TYPE} == 'p' ] ; then
USERS="teacher"
if [ ${CORP} == "1" ] ; then
SERVER=10.xxx.xxx.26
setup_panel
exit
fi
if [ ${CORP} == "2" ] ; then
SERVER=10.xxx.xxx.26
setup_panel
exit
fi
fi
if [ ${TYPE} == 'm' ] ; then
LOCK=1
USERS="student"
if [ ${CORP} == "1" ] ; then
  SERVER="172.xxx.xxx.16"
  if [ ${CAB} == 'xx' ]; then
  TIMEOUT=0
  VEYON="mxxxx.local"
  setup_cc
  exit
  fi
  if [ ${CAB} == 'xx' ]; then
  TIMEROUT=0
  VEYON="mxxxx.local"
  setup_cc
  exit
  fi
  if [ ${CAB} == 'xx' ]; then
  USERS="student k10a k10b"
  VEYON="mxxxx.local"
  setup_cc
  exit
  fi
  if [ ${CAB} == '34a' ]; then
  VEYON="mxxxx.local"
  setup_cc
  exit
  fi
fi
if [ ${CORP} == "2" ] ; then
  SERVER="172.xx.xx.16"
  if [ ${CAB} == 'xx' ]; then
  TIMEOUT=0
  VEYON="mxxxx.local"
  setup_cc
  exit
  fi
  if [ ${CAB} == 'xx' ]; then
  TIMEOUT=0
  VEYON="mxxxx.local"
  setup_cc
  exit
  fi
fi
fi
if [ ${TYPE} == 'n' ] ; then
USERS='user'
if [ ${CORP} == "1" ] ; then
SERVER="172.xx.xx.16"
setup_note
exit
fi
if [ ${CORP} == "2" ] ; then
SERVER="172.xx.xx.16"
setup_note
exit
fi
fi
setup_other
</syntaxhighlight>
[[Категория:Скрипты]]
[[Категория:Скрипты]]
[[Категория:МОС]]
[[Категория:МОС]]

Навигация