#!/bin/bash -e
template="blanc.docx"
student_list="ФИО.txt"
output_dir="certificate"
tmp_d="tmp_word"
mkdir -p "$tmp_d" "$output_dir"
unzip "$template" -d "$tmp_d"
cp "$tmp_d/word/document.xml" .
while read -r student_name; do
echo -e "\n\033[0;32m${student_name}\033[0m"
cp document.xml "$tmp_d/word/document.xml"
sed -i "s/????/$student_name/g" "$tmp_d/word/document.xml"
cd "$tmp_d"
zip -r "../$output_dir/$student_name.docx" *
cd ..
done < "$student_list"
rm -rf document.xml "$tmp_d"
env_keep
в /etc/sudoers
Defaults env_keep += "PATH"
man 5 sudoers :
env_reset If set, sudo will reset the environment to only contain
the LOGNAME, SHELL, USER, USERNAME and the SUDO_* vari-
ables. Any variables in the caller's environment that
match the env_keep and env_check lists are then added.
The default contents of the env_keep and env_check
lists are displayed when sudo is run by root with the
-V option. If sudo was compiled with the SECURE_PATH
option, its value will be used for the PATH environment
variable. This flag is on by default.