-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
223 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#!/command/with-contenv bash | ||
|
||
BACKUPPC_ADMIN_USER=${BACKUPPC_ADMIN_USER:-"backuppc"} | ||
BACKUPPC_UUID=${BACKUPPC_UUID:-1000} | ||
BACKUPPC_GUID=${BACKUPPC_GUID:-1000} | ||
CONFIG_PATH=${CONFIG_PATH:-"/etc/backuppc/"} | ||
DATA_PATH=${DATA_PATH:-"/var/lib/backuppc/"} | ||
LOG_PATH=${LOG_PATH:-"/www/logs/"} | ||
SSH_KEYS_PATH=${SSH_KEYS_PATH:-"/home/backuppc/.ssh"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/command/with-contenv bash | ||
|
||
bootstrap_filesystem() { | ||
print_debug "[bootstrap_filesystem] Creating Configuration directory" | ||
if [ ! -d "${CONFIG_PATH}" ]; then | ||
mkdir -p "${CONFIG_PATH}" | ||
fi | ||
if [ "$(stat -c '%u' "${CONFIG_PATH}")" != "$(id -u backuppc)" ] ; then chown -R backuppc:backuppc "${CONFIG_PATH}" ; fi | ||
if dir_empty "${CONFIG_PATH}" ; then | ||
print_notice "[bootstrap_filesystem] Detected New Installation - Generating default configuration" | ||
fi | ||
|
||
print_debug "[bootstrap_filesystem] Creating Configuration directory" | ||
if [ ! -d "${DATA_PATH}" ]; then | ||
mkdir -p "${DATA_PATH}" | ||
fi | ||
if [ "$(stat -c '%u' "${DATA_PATH}")" != "$(id -u backuppc)" ] ; then chown backuppc:backuppc "${DATA_PATH}" ; fi | ||
|
||
|
||
print_debug "[bootstrap_filesystem] Creating SSH Keys directory" | ||
if [ ! -d "${SSH_KEYS_PATH}" ]; then | ||
mkdir -p "${SSH_KEYS_PATH}" | ||
fi | ||
|
||
if [ "$(stat -c '%u' "${SSH_KEYS_PATH}")" != "$(id -u backuppc)" ] ; then chown -R backuppc:backuppc "${SSH_KEYS_PATH}" ; fi | ||
if [ "$(stat -c '%a' "${SSH_KEYS_PATH}")" != "700" ] ; then chmod 700 "${SSH_KEYS_PATH}" ; fi | ||
if [[ "${SSH_KEYS_PATH}" =~ "/home/backupppc".* ]] ; then | ||
if [ "$(stat -c '%u' "/home/backuppc")" != "$(id -u backuppc)" ] ; then chown -R backuppc:backuppc "/home/backuppc" ; fi | ||
fi | ||
if [ ! -d "/home/backuppc/.ssh" ] ; then | ||
ln -sf "${SSH_KEYS_PATH}" /home/backuppc/.ssh | ||
fi | ||
|
||
print_debug "[bootstrap_filesystem] Creating Logfiles" | ||
if [ ! -d "${LOG_PATH}" ]; then | ||
mkdir -p "${LOG_PATH}" | ||
fi | ||
if [ "$(stat -c '%u' "${LOG_PATH}")" != "$(id -u backuppc)" ] ; then chown -R backuppc:backuppc "${LOG_PATH}" ; fi | ||
} | ||
|
||
configure_ui() { | ||
sed -ie "s/^\$Conf{CgiAdminUsers}\s*=\s*'\w*'/\$Conf{CgiAdminUsers} = 'backuppc'/g" "${CONFIG_PATH}"/config.pl | ||
} | ||
|
||
generate_ssh_keys() { | ||
if [ ! -f "${SSH_KEYS_PATH}"/id_rsa ]; then | ||
print_notice "[generate_ssh_keys] Creating RSA SSH key" | ||
silent su backuppc -s /bin/sh -c "ssh-keygen -t rsa -b 4096 -N '' -f ${SSH_KEYS_PATH}/id_rsa" | ||
fi | ||
|
||
if [ ! -f "${SSH_KEYS_PATH}"/id_ed25519 ]; then | ||
print_notice "[generate_ssh_keys] Creating ed25519 SSH key" | ||
silent su backuppc -s /bin/sh -c "ssh-keygen -t ed25519 -o -a 100 -q -N '' -f ${SSH_KEYS_PATH}/id_ed25519" | ||
fi | ||
} | ||
|
||
install_backuppc() { | ||
print_debug "[install_backuppc] Installing BackupPC ${BACKUPPC_VERSION}" | ||
cd /assets/install || exit | ||
silent perl configure.pl \ | ||
--batch \ | ||
--config-dir "${CONFIG_PATH}" \ | ||
--cgi-dir /www/cgi-bin/BackupPC \ | ||
--data-dir "${DATA_PATH}" \ | ||
--hostname localhost \ | ||
--html-dir /www/html/BackupPC \ | ||
--html-dir-url /BackupPC \ | ||
--install-dir /usr/local/BackupPC \ | ||
--log-dir "${LOG_PATH}" | ||
} |
Oops, something went wrong.