Skip to content

Commit

Permalink
[Cmake] Cleaning script (credits: @mattiabiondi)
Browse files Browse the repository at this point in the history
  • Loading branch information
berdav committed Jan 31, 2020
1 parent 9fb6a8d commit 06ac0e5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
7 changes: 2 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ else (WITHEDITOR)
set(EDITOR "/usr/bin/vi")
endif (WITHEDITOR)

if(DEBUILD)
set(CADO_SPOOL_DIR "/var/spool/cado")
else(DEBUILD)
set(CADO_SPOOL_DIR "/usr/local/var/spool/cado")
endif(DEBUILD)
# Spool dir for scado files
set(CADO_SPOOL_DIR "/usr/local/var/spool/cado")

configure_file(
"include/config.h.in"
Expand Down
24 changes: 13 additions & 11 deletions PostInstall.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ execute_process(COMMAND bash -c "\
groupadd \
--system \
_cado;
fi")
fi"
ERROR_QUIET OUTPUT_QUIET)
execute_process(COMMAND bash -c "\
if ! getent passwd _cado >/dev/null 2>&1; then
useradd \
Expand All @@ -13,13 +14,14 @@ execute_process(COMMAND bash -c "\
--shell /bin/nologin \
-g _cado \
_cado;
fi")
execute_process(COMMAND mkdir -p ${CADO_SPOOL_DIR})
execute_process(COMMAND chown root:_cado ${CADO_SPOOL_DIR})
execute_process(COMMAND chmod 4770 ${CADO_SPOOL_DIR})
execute_process(COMMAND chown :_cado ${BINDIR}/scado)
execute_process(COMMAND chmod g+s ${BINDIR}/scado)
execute_process(COMMAND chown _cado: ${BINDIR}/cado)
execute_process(COMMAND chmod u+s ${BINDIR}/cado)
execute_process(COMMAND ldconfig ${LIBDIR})
execute_process(COMMAND bash -c "${BINDIR}/cado --setcap >/dev/null 2>&1")
fi"
ERROR_QUIET OUTPUT_QUIET)
execute_process(COMMAND mkdir -p ${CADO_SPOOL_DIR} ERROR_QUIET OUTPUT_QUIET)
execute_process(COMMAND chown root:_cado ${CADO_SPOOL_DIR} ERROR_QUIET OUTPUT_QUIET)
execute_process(COMMAND chmod 4770 ${CADO_SPOOL_DIR} ERROR_QUIET OUTPUT_QUIET)
execute_process(COMMAND chown :_cado ${BINDIR}/scado ERROR_QUIET OUTPUT_QUIET)
execute_process(COMMAND chmod g+s ${BINDIR}/scado ERROR_QUIET OUTPUT_QUIET)
execute_process(COMMAND chown _cado: ${BINDIR}/cado ERROR_QUIET OUTPUT_QUIET)
execute_process(COMMAND chmod u+s ${BINDIR}/cado ERROR_QUIET OUTPUT_QUIET)
execute_process(COMMAND ldconfig ${LIBDIR} ERROR_QUIET OUTPUT_QUIET)
execute_process(COMMAND ${BINDIR}/cado --setcap ERROR_QUIET OUTPUT_QUIET)
6 changes: 3 additions & 3 deletions Uninstall.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ foreach(file ${files})
message(STATUS "Removing file: '${file}'")

execute_process(
COMMAND bash "-c" "rm ${file}"
COMMAND rm "${file}"
OUTPUT_VARIABLE remove_file
)

Expand All @@ -24,7 +24,7 @@ endforeach(file)

message(STATUS "Removing user: '_cado'")
execute_process(
COMMAND bash "-c" "userdel _cado"
COMMAND userdel _cado
OUTPUT_VARIABLE remove_user
)
if(${remove_user})
Expand All @@ -33,7 +33,7 @@ endif()

message(STATUS "Removing folder: '${CADO_SPOOL_DIR}'")
execute_process(
COMMAND bash "-c" "rm -r ${CADO_SPOOL_DIR}"
COMMAND rm -r "${CADO_SPOOL_DIR}"
OUTPUT_VARIABLE remove_spool_folder
)
if("${remove_spool_folder}")
Expand Down

0 comments on commit 06ac0e5

Please sign in to comment.