#!/bin/bash
#ALD 1.3 join
#Добавление репозиториев ALD Pro 
cat <<EOL > /etc/apt/sources.list.d/zaldpro.list
deb http://dl.astralinux.ru/aldpro/stable/repository-main/ 2.1.0 main
deb http://dl.astralinux.ru/aldpro/stable/repository-extended/ generic main
EOL
# Установка клиента ALD Pro и ввод компьютера в домен
    search_domain="ald.local"
	pcname=$(hostname)
	password="P@ssw0rd21#"
	user="srv-ald-join"

	fuser /var/lib/dpkg/lock >/dev/null 2>&1
	fuser /var/lib/dpkg/lock-frontend >/dev/null 2>&1
	fuser /var/lib/dpkg/lock >/dev/null 2>&1

	apt update
	DEBIAN_FRONTEND=noninteractive apt-get install -q -y aldpro-client
	mkdir -p /etc/ssl/freeipa
	sed -e 's/127\.0\.1\.1.*//g' -i /etc/hosts
	/opt/rbta/aldpro/client/bin/aldpro-client-installer -c "$search_domain" -u $user -p $password -d "$pcname" -i -f
	/usr/bin/python3 /opt/rbta/aldpro/client/bin/aldpro-service-discovery.py	
	ln -s /usr/bin/astra-freeipa-domains-ctl /etc/domains.list.d/