Add 08-install-additional-user-photos module
This commit is contained in:
committed by
T. R. Bernstein
parent
5011e0301d
commit
edc9b0f218
@@ -17,6 +17,9 @@ Scripts to align a macOS system to Astzweig system configuration.
|
||||
1. If the configuration file does not have those informations, it asks the user.
|
||||
1. `install.sh` then runs the modules with their required informations passed in as parameter values.
|
||||
|
||||
## License exclusion
|
||||
The license does not cover the file [Astzweig.png](resources/user-pictures/Astzweig.png).
|
||||
|
||||
## Required Information Format
|
||||
Modules must print their required information to stdout if they're called with
|
||||
`show-questions` command. Required information are all information the module
|
||||
|
||||
101
modules/08-install-additional-user-photos.sh
Executable file
101
modules/08-install-additional-user-photos.sh
Executable file
@@ -0,0 +1,101 @@
|
||||
#!/usr/bin/env zsh
|
||||
# vi: set ft=zsh tw=80 ts=2
|
||||
|
||||
function convertRelativePathToResourcesDir() {
|
||||
local resolved=''
|
||||
lop -- -d 'Converting path' -d "${picture_folder}" -d 'to a resources path if necessary.'
|
||||
if [ -d "${picture_folder}" ]; then
|
||||
lop -- -d 'Path seems to be a valid path already. Skipping conversion.'
|
||||
return
|
||||
fi
|
||||
pushd -q ${_DIR}/../'resources'
|
||||
resolved=$_/${picture_folder}
|
||||
lop -- -d 'Resolved path is' -d "${resolved}"
|
||||
popd -q
|
||||
[ -n "${resolved}" -a -d "${resolved}" ] && picture_folder="${resolved}"
|
||||
}
|
||||
|
||||
function findAvailableDestinationFolder() {
|
||||
local folderName=${picture_folder_name} counter=2
|
||||
while [[ -d '/Library/User Pictures/'$folderName ]]; do
|
||||
folderName="$folderName $counter"
|
||||
counter=$((counter + 1))
|
||||
done
|
||||
destinationFolder='/Library/User Pictures/'$folderName
|
||||
}
|
||||
|
||||
function copyPictureFolderToDestination() {
|
||||
cp -r $picture_folder $destinationFolder
|
||||
}
|
||||
|
||||
function fixPermissions() {
|
||||
chown -R root:wheel $destinationFolder
|
||||
chmod ugo+rx $destinationFolder
|
||||
find $destinationFolder -type d -exec chmod ugo+rx {} \;
|
||||
find $destinationFolder -type f -exec chmod ugo+r {} \;
|
||||
}
|
||||
|
||||
function configure_system() {
|
||||
local destinationFolder=
|
||||
lop -y h1 -- -i 'Install Additional User Pictures'
|
||||
indicateActivity -- 'Resolve path if relative to resources directory' convertRelativePathToResourcesDir
|
||||
[[ ! -d ${picture_folder} ]] && { lop -- -e 'Provided picture folder does not exist. Aborting.'; return 10 }
|
||||
[[ -n ${picture_folder_name} ]] || { lop -- -e 'Provided an empty picture folder name. Aborting.'; return 11 }
|
||||
indicateActivity -- 'Find available destination folder' findAvailableDestinationFolder
|
||||
indicateActivity -- 'Copy pictures to destination folder' copyPictureFolderToDestination
|
||||
indicateActivity -- 'Set correct permissions' fixPermissions
|
||||
}
|
||||
|
||||
function getExecPrerequisites() {
|
||||
cmds=(
|
||||
[git]=''
|
||||
)
|
||||
re
|
||||
}
|
||||
|
||||
function getDefaultUserPictureFolderPath() {
|
||||
pushd -q ${_DIR}/..
|
||||
print -- ${USER_PICTURE_FOLDER_PATH:-user-pictures}
|
||||
popd -q
|
||||
}
|
||||
|
||||
function getDefaultPictureFolderName() {
|
||||
print Astzweig
|
||||
}
|
||||
|
||||
function getQuestions() {
|
||||
questions=(
|
||||
'i: picture-folder=Which folder includes the user pictures to install? # default:'"$(getDefaultUserPictureFolderPath)"
|
||||
'i: picture-folder-name=How shall the picture folder be named once copied to the system files? # default:'"$(getDefaultPictureFolderName)"
|
||||
)
|
||||
}
|
||||
|
||||
function getUsage() {
|
||||
read -r -d '' text <<- USAGE
|
||||
Usage:
|
||||
$cmdName show-questions [<modkey> <modans>]...
|
||||
$cmdName [-v] [-d FILE] --picture-folder PATH --picture-folder-name NAME
|
||||
|
||||
Install additional user pictures.
|
||||
|
||||
Options:
|
||||
--picture-folder PATH Path to the folder containing the user pictures
|
||||
[default: $(getDefaultUserPictureFolderPath)].
|
||||
--picture-folder-name NAME Name of the picture folder once copied to the system
|
||||
files [default: $(getDefaultPictureFolderName)].
|
||||
-d FILE, --logfile FILE Print log message to logfile instead of stdout.
|
||||
-v, --verbose Be more verbose.
|
||||
----
|
||||
$cmdName 0.1.0
|
||||
Copyright (C) 2022 Rezart Qelibari, Astzweig GmbH & Co. KG
|
||||
License EUPL-1.2. There is NO WARRANTY, to the extent permitted by law.
|
||||
USAGE
|
||||
print -- ${text}
|
||||
}
|
||||
|
||||
if [[ "${ZSH_EVAL_CONTEXT}" == toplevel ]]; then
|
||||
_DIR="${0:A:h}"
|
||||
test -f "${ASTZWEIG_MACOS_SYSTEM_LIB}" || { echo 'This module requires macos-system library. Please run again with macos-system library provieded as a path in ASTZWEIG_MACOS_SYSTEM_LIB env variable.'; return 10 }
|
||||
source "${ASTZWEIG_MACOS_SYSTEM_LIB}"
|
||||
module_main $0 "$@"
|
||||
fi
|
||||
BIN
resources/user-pictures/Astzweig.png
Normal file
BIN
resources/user-pictures/Astzweig.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Reference in New Issue
Block a user