Compare commits

...

3 Commits

Author SHA1 Message Date
Dmitry Belyaev de0fa9eb69 run config/update_files.sh 2023-05-16 23:49:06 +03:00
Dmitry Belyaev 1c9c22477c fix spaces 2023-05-16 23:44:00 +03:00
Dmitry Belyaev d92d4e4400 add update_files.sh 2023-05-16 23:43:02 +03:00
3 changed files with 90 additions and 94 deletions

View File

@ -1,14 +1,14 @@
#!/bin/bash
tab() {
sed -e "s/^/$(printf %$1s)/"
sed -e "s/^/$(printf %$1s)/"
}
not_empty() {
sed -e "/^$/d"
sed -e "/^$/d"
}
define(){ IFS='\n' read -r -d '' ${1} || true; }
define() { IFS='\n' read -r -d '' ${1} || true; }
#ls -l | tab 10
@ -19,22 +19,21 @@ permissions: '0644'
EOF
print_file() {
CONTENT=$(cat $1 | gzip | base64)
echo "- path: $2"
cat <<< $FILE_OPTS_COMMON | not_empty | tab 2
echo " content: |"
cat <<< $CONTENT | tab 4
echo " "
CONTENT=$(cat $1 | gzip | base64)
echo "- path: $2"
cat <<<"$FILE_OPTS_COMMON" | not_empty | tab 2
echo " content: |"
cat <<<"$CONTENT" | tab 4
echo " "
}
gen__write_files() {
echo "write_files:"
print_file src/srv1cv83@.service /etc/systemd/system/srv1cv83@.service | tab 2
print_file src/srv1cv83-ras@.service /etc/systemd/system/srv1cv83-ras@.service | tab 2
print_file src/apache-proxy /etc/nginx/sites-available/apache-proxy | tab 2
echo "write_files:"
print_file src/srv1cv83@.service /etc/systemd/system/srv1cv83@.service | tab 2
print_file src/srv1cv83-ras@.service /etc/systemd/system/srv1cv83-ras@.service | tab 2
print_file src/apache-proxy /etc/nginx/sites-available/apache-proxy | tab 2
}
pushd config
pushd config >/dev/null 2>&1
gen__write_files | tab 4
popd
popd >/dev/null 2>&1

View File

@ -15,57 +15,55 @@ autoinstall:
debconf-selections: |
ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true
packages:
- openssh-server
- openssh-client
- mosh
- mc
- htop
- ca-certificates
- curl
- wget
- apt-transport-https
- apt-utils
- locales-all
- language-pack-ru
- language-pack-ru-base
- unixodbc
- libfreetype6
- fontconfig
- t1utils
- apache2
- nginx
- unzip
- libc6-i386
- git
- build-essential
- python-is-python3
- python3-pip
- python3-virtualenv
- dkms
- samba
- fusesmb
- samba-vfs-modules
- cifs-utils
- avahi-daemon
- avahi-dnsconfd
- libnss-winbind
- libnss-mdns
- cups
- wsdd
- libxt6
- libtcmalloc-minimal4
- openssh-server
- openssh-client
- mosh
- mc
- htop
- ca-certificates
- curl
- wget
- apt-transport-https
- apt-utils
- locales-all
- language-pack-ru
- language-pack-ru-base
- unixodbc
- libfreetype6
- fontconfig
- t1utils
- apache2
- nginx
- unzip
- libc6-i386
- git
- build-essential
- python-is-python3
- python3-pip
- python3-virtualenv
- dkms
- samba
- fusesmb
- samba-vfs-modules
- cifs-utils
- avahi-daemon
- avahi-dnsconfd
- libnss-winbind
- libnss-mdns
- cups
- wsdd
- libxt6
- libtcmalloc-minimal4
late-commands:
- stat /cdrom/1c/install >/dev/null 2>/dev/null && sh -exc "mkdir -p /target/var/install/1c && cp /cdrom/1c/install/* /target/var/install/1c/" || echo skip 1c distr copy
- sync
- echo --- done! ---
user-data:
hostname: srv1c
groups:
- postgres
- grp1cv8
- www-data
users:
- default
- name: admin1c
@ -78,23 +76,20 @@ autoinstall:
passwd: $6$rounds=4096$X0PCsEEYkoirzYwF$vFfmCzOhzPQUsdXbrlt0cyX0wEiuRc2WecIUMyO2ZkTYzSh8oz2Sp87OFVxCHp0sPklRDmdwkK56EZCar.N1o/
ssh_import_id:
- gh:b4tman
#ssh_authorized_keys:
# - <ssh pub key 1>
#ssh_authorized_keys:
# - <ssh pub key 1>
- name: postgres
primary_group: postgres
groups: grp1cv8
system: true
passwd: $6$rounds=4096$7HbuIwc5Gbm.$eDOOBbMBh9teE82CE9MGJXJuK3nRuJpjIbkUqOmPN7FyH/Nj.3bgDosdM1WoztBXHYwgCyd1dhya/5aR36Njm1
locale: "ru_RU.UTF-8"
timezone: Europe/Moscow
ntp:
enabled: true
ntp_client: auto
package_update: true
package_upgrade: true
write_files:
- path: /etc/systemd/system/srv1cv83@.service
encoding: gzip+base64
@ -116,7 +111,6 @@ autoinstall:
ZWjWpJOSN22e1T1B0sm737v37Jl0/JK+SN0ColTD6pWiXk6n8xu5o3E790x+BB1sPS7ZjqqaYxcF
d39SjclOrBfGa5OkpvmVTc3Y8272bh6f3+CXxPgOMPHItqZ5xZ2n/WCi+QZPbpIXVCr8towrCtyH
yrPp32UKFA+EdjftO0MGs7MtzVHLO261my/TH0B8qt7jBgAA
- path: /etc/systemd/system/srv1cv83-ras@.service
encoding: gzip+base64
owner: root:root
@ -128,7 +122,6 @@ autoinstall:
gqmLPCn5hU7Gby7gaHgPCs+lD0me9+RxMv4cD2W/kqQjNzbHkpALEXxRDkbDUY+9orU17py2qq7m
1duSvRMedIJlG1SiDKVu7C55JxqNNtOVqsGoUYlfuQKtPb+10dmmDjsDymQicIl96PLg7dNJtWWK
Ipdm1/J/2tGhvJIBAAA=
- path: /etc/nginx/sites-available/apache-proxy
encoding: gzip+base64
owner: root:root
@ -150,15 +143,13 @@ autoinstall:
nRxxNIpiRwDoh+Exg14eHzAOOjMAdYfFeYpuZroxvVjOMPSO5kKdi2OwqrMpLzH7QVnFc8ST5Rdc
URZgN5qWdJyF7WtgO//sPyEr/dtHaO+90n5F91WqH0wVWNgzaDuitcgqm24he/ZxrBuyM7TfTP3G
tbsgI/Pbhurmo070ccCxM0Sz21vH9JppDQfD3mUYBO6PQ+D4P+kPwX+oL4ivUwgAAA==
runcmd:
# --- fix hosts ---
- |
set -x
echo " " >> /etc/hosts
echo "127.0.0.1 localhost srv1c srv1c.local" >> /etc/hosts
echo "::1 localhost srv1c srv1c.local" >> /etc/hosts
set -x
echo " " >> /etc/hosts
echo "127.0.0.1 localhost srv1c srv1c.local" >> /etc/hosts
echo "::1 localhost srv1c srv1c.local" >> /etc/hosts
# --- force locale install ---
- |
set -x
@ -166,26 +157,22 @@ autoinstall:
update-locale LANG=ru_RU.UTF-8
export LC_ALL=ru_RU.UTF-8
export LANG=ru_RU.UTF-8
# --- force set timezone ---
- timedatectl set-timezone Europe/Moscow
# --- force apt update ---
- |
set -x
set -x
apt-get update
apt-get -y dist-upgrade
apt-get clean
# --- install hasp ---
- |
set -x
set -x
mkdir -p /tmp/ldk
curl -SLo /tmp/ldk/installer.tar.gz https://b4tman.ru/_static/Sentinel_LDK_Ubuntu_DEB_Runtime_Installer.tar.gz
tar xzf /tmp/ldk/installer.tar.gz --strip-components=1 -C /tmp/ldk
sh -xc 'dpkg -i $(find /tmp/ldk -name "aksusb*amd64.deb" -type f)'
rm -rf /tmp/ldk
# --- install ttf-mscorefonts ---
- |
set -x
@ -194,18 +181,16 @@ autoinstall:
chown _apt:root /var/lib/update-notifier/package-data-downloads/partial/
apt-get install --no-install-recommends --no-install-suggests -y ttf-mscorefonts-installer
rm -rf /var/lib/update-notifier/package-data-downloads/partial/*
# --- install postgres ---
- |
set -x
set -x
curl -SLo /tmp/pgpro-repo-add.sh https://repo.postgrespro.ru/1c-15/keys/pgpro-repo-add.sh
sh /tmp/pgpro-repo-add.sh
rm -f /tmp/pgpro-repo-add.sh
apt-get install -y postgrespro-1c-15-contrib postgrespro-1c-15-jit
# --- postgres init ---
- |
set -x
set -x
echo postgres > /tmp/pgpswd
/opt/pgpro/1c-15/bin/pg-setup initdb --tune=1c -k -E UTF8 -g --locale ru_RU.UTF-8 -T russian --pwfile=/tmp/pgpswd
rm -f /tmp/pgpswd
@ -218,7 +203,6 @@ autoinstall:
/opt/pgpro/1c-15/bin/pg-setup service enable
/opt/pgpro/1c-15/bin/pg-setup service start
apt-get install -y postgrespro-1c-15
# --- install 1c ---
- |
set -x
@ -236,17 +220,15 @@ autoinstall:
# stat /var/install/1c >/dev/null 2>/dev/null && $(find /tmp/1c -name "setup-full-*.run" -type f) --mode unattended --enable-components additional_admin_functions,integrity_monitoring,config_storage_server,client_full,client_thin_fib,liberica_jre,server,server_admin,ws,ru || echo skip 1c install
stat /tmp/1c >/dev/null 2>/dev/null && rm -rf /tmp/1c || echo skip 1c install
stat /opt/1cv8/x86_64 >/dev/null 2>/dev/null && ln -s $(find /opt/1cv8/x86_64 -name "8.3.*" -type d) /opt/1cv8/x86_64/current || echo skip 1c install
# --- 1c config ---
- |
echo \ \ >> /opt/1cv8/conf/conf.cfg
echo "JavaHome=/opt/1cv8/x86_64/current/jre" >> /opt/1cv8/conf/conf.cfg
echo "JAVA_HOME=/opt/1cv8/x86_64/current/jre" >> /opt/1cv8/conf/conf.cfg
echo "UpdateDBCfg=v2" >> /opt/1cv8/conf/conf.cfg
# --- 1c web init ---
- |
set -x
set -x
# stop services
systemctl stop apache2
systemctl stop nginx
@ -262,7 +244,7 @@ autoinstall:
sed -i 's%VirtualHost\s\*\:80%VirtualHost\ \*\:33380%' /etc/apache2/sites-available/001-1c.conf
sed -i 's%DocumentRoot\s\/var\/www\/html%DocumentRoot \/var\/www-1c\/html%' /etc/apache2/sites-available/001-1c.conf
sed -i 's%\#Include.*$%Include /etc/apache2/conf-available/1c.conf%' /etc/apache2/sites-available/001-1c.conf
# load 1c handler module
# load 1c handler module
echo LoadModule _1cws_module "/opt/1cv8/x86_64/current/wsap24.so" >> /etc/apache2/conf-available/1c.conf
# allow www root
echo \<Directory\ \"/var/www-1c/html\"\> >> /etc/apache2/conf-available/1c.conf
@ -288,10 +270,9 @@ autoinstall:
# enable+start 1c service
stat /opt/1cv8/x86_64/current/ragent >/dev/null 2>/dev/null && systemctl enable srv1cv83@current --now || echo ignoring 1c service
stat /opt/1cv8/x86_64/current/ras >/dev/null 2>/dev/null && systemctl enable srv1cv83-ras@current --now || echo ignoring 1c ras service
# --- install & config webpub1c ---
- |
set -x
set -x
sudo -u admin1c sh -exc "git clone --branch v0.0.1 https://github.com/b4tman/webpub1c /home/admin1c/webpub1c && cd /home/admin1c/webpub1c && virtualenv venv && . venv/bin/activate && pip install -r requirements.txt"
sed -i "s%apache_config:.*\$%apache_config: /etc/apache2/conf-available/1c.conf%" /home/admin1c/webpub1c/webpub1c.yml
mkdir -p /var/www-1c/vrd
@ -301,7 +282,6 @@ autoinstall:
chown admin1c:root /etc/apache2/conf-available/1c.conf
sed -i "s%vrd_path:.*\$%vrd_path: /var/www-1c/vrd%" /home/admin1c/webpub1c/webpub1c.yml
sed -i "s%dir_path:.*\$%dir_path: /var/www-1c/pub%" /home/admin1c/webpub1c/webpub1c.yml
# --- install opt tools ---
- |
set -x
@ -312,14 +292,12 @@ autoinstall:
snap install nvim --classic
apt-get install -y bat fd-find exa fzf
echo "alias bat=batcat" >> /home/admin1c/.bashrc
# --- install onescript ---
- |
set -x
apt-get install -y mono-runtime libmono-i18n4.0-all
curl -SLo /tmp/onescript-engine.deb https://github.com/EvilBeaver/OneScript/releases/download/v1.8.3/onescript-engine_1.8.3_all.deb
dpkg -i /tmp/onescript-engine.deb
# --- install wsdd ---
#- |
# set -x
@ -328,7 +306,7 @@ autoinstall:
# apt-get update
# apt-get install -y wsdd
# systemctl enable wsdd.service --now
# --- create bases ---
- |
set -x
@ -342,8 +320,6 @@ autoinstall:
sudo -u admin1c sh -exc "cd /home/admin1c/webpub1c && . venv/bin/activate && python webpub1c.py add_module && python webpub1c.py add test1 && python webpub1c.py add test2 && python webpub1c.py add test3"
systemctl restart apache2
# --- final ---
- |
set -x
@ -352,4 +328,3 @@ autoinstall:
# remove default user folder
rm -rf /home/ubuntu
echo -- done! ---

22
config/update_files.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
temp_yml() {
mktemp --suffix=.yml
}
gen_files() {
./gen_files_yml.sh >"$1"
}
update_files_from() {
SRC=$1 yq -i '.autoinstall.user-data.write_files |= load(strenv(SRC)).write_files' nocloud/user-data
}
pushd config >/dev/null 2>&1
TMP_YML=$(temp_yml)
gen_files "$TMP_YML"
update_files_from "$TMP_YML"
rm -f "$TMP_YML"
popd >/dev/null 2>&1