Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions projects/ROCKNIX/packages/network/rclone/package.mk
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,12 @@ unpack() {
makeinstall_target() {
mkdir -p ${INSTALL}/usr/bin/
mkdir -p ${INSTALL}/usr/config/
cp rclonectl ${INSTALL}/usr/bin/
cp cloud_backup ${INSTALL}/usr/bin/
cp cloud_restore ${INSTALL}/usr/bin/
cp cloud_sync_helper ${INSTALL}/usr/bin/
cp cloud_sync_cleanup_duplicates.sh ${INSTALL}/usr/bin/
cp ${PKG_BUILD}/${PKG_RCLONE} ${INSTALL}/usr/bin/
chmod 0755 ${INSTALL}/usr/bin/*
cp rsync-rules.conf ${INSTALL}/usr/config/
cp rsync.conf ${INSTALL}/usr/config/
cp cloud_sync-rules.txt ${INSTALL}/usr/config/
cp cloud_sync.conf ${INSTALL}/usr/config/
cp cloud_sync.conf.defaults ${INSTALL}/usr/config/
Expand Down
28 changes: 24 additions & 4 deletions projects/ROCKNIX/packages/network/rclone/sources/cloud_backup
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ read_controller_input() {
echo "left"
elif [[ "$event_output" =~ BTN_DPAD_RIGHT.*value[[:space:]]+1 ]] || [[ "$event_output" =~ ABS_HAT0X.*value[[:space:]]+1 ]]; then
echo "right"
elif [[ "$event_output" =~ BTN_SOUTH.*value[[:space:]]+1 ]] || [[ "$event_output" =~ BTN_A.*value[[:space:]]+1 ]] || [[ "$event_output" =~ "code 0.*value[[:space:]]+1" ]] || [[ "$event_output" =~ BTN_EAST.*value[[:space:]]+1 ]]; then
elif [[ "$event_output" =~ BTN_SOUTH.*value[[:space:]]+1 ]] || [[ "$event_output" =~ BTN_A.*value[[:space:]]+1 ]] || [[ "$event_output" =~ BTN_EAST.*value[[:space:]]+1 ]]; then
echo "confirm"
elif [[ "$event_output" =~ BTN_B.*value[[:space:]]+1 ]] || [[ "$event_output" =~ "code 1.*value[[:space:]]+1" ]]; then
elif [[ "$event_output" =~ BTN_B.*value[[:space:]]+1 ]]; then
echo "cancel"
elif [[ "$event_output" =~ BTN_START.*value[[:space:]]+1 ]]; then
echo "start"
Expand Down Expand Up @@ -306,7 +306,7 @@ report_rclone_error() {
6) log_message "${operation} failed: Less serious errors (e.g. partly transferred)" "true" "WARN" ;;
7) log_message "${operation} failed: Fatal error - rclone giving up" "true" "ERROR" ;;
8) log_message "${operation} failed: Transfer exceeded - limits exceeded" "true" "ERROR" ;;
9) log_message "${operation} failed: Operation failed - no retry" "true" "ERROR" ;;
9) log_message "${operation} completed: no files transferred" "true" ;;
*) log_message "${operation} failed with unknown error code: $exit_code" "true" "ERROR" ;;
esac
}
Expand Down Expand Up @@ -379,7 +379,7 @@ backup_game_saves() {
log_message "Ensuring remote sync path exists: ${REMOTENAME}${SYNCPATH}" "false"
rclone mkdir "${REMOTENAME}${SYNCPATH}" 2>/dev/null

# Set log level to DEBUG when INFO is selected for enhanced logging
# Pass an explicit --log-level INFO when LOG_LEVEL is INFO
local rclone_debug=""
local filtered_opts=("${RCLONE_OPTS_ARRAY[@]}")

Expand Down Expand Up @@ -407,12 +407,18 @@ backup_game_saves() {

# Add exclusions
all_opts+=(
"--stats-one-line"
"--exclude=${BACKUPFOLDER}/**"
"--exclude=backups/**"
"--exclude=bios/**"
"--exclude=*.zip"
)

# Check if the rclone version supports the terminal width flag
if rclone help | grep -q progress-terminal-width; then
all_opts+=("--progress-terminal-width=80")
fi

# Execute rclone with enhanced error handling
execute_rclone_with_error_handling \
"${BACKUPMETHOD}" \
Expand All @@ -425,6 +431,15 @@ backup_game_saves() {
# Report the result with detailed error information
report_rclone_error $BACKUP_STATUS "Game saves backup"

# RSYNCRMDIR: after a successful backup, remove orphaned empty directories on
# the remote (--leave-root keeps the sync root itself). Exit code 9 means
# "success, no files transferred", so tidy on that too.
if [ "${RSYNCRMDIR}" == "yes" ] && { [ $BACKUP_STATUS -eq 0 ] || [ $BACKUP_STATUS -eq 9 ]; }; then
log_message "Removing orphaned empty directories on remote: ${REMOTENAME}${SYNCPATH}" "false"
rclone rmdirs "${REMOTENAME}${SYNCPATH}" --leave-root --log-file /var/log/cloud_sync.log 2>/dev/null \
|| log_message "Empty-directory cleanup failed (non-fatal)" "true" "WARN"
fi

return $BACKUP_STATUS
}

Expand Down Expand Up @@ -470,6 +485,11 @@ backup_system_files() {
"--include=*.zip"
"--stats-one-line"
)

# Check if the rclone version supports the terminal width flag
if rclone help | grep -q progress-terminal-width; then
backup_opts+=("--progress-terminal-width=80")
fi

# Add any additional options from RESTORE_RCLONEOPTS
if [ -n "$RESTORE_RCLONEOPTS" ]; then
Expand Down
22 changes: 17 additions & 5 deletions projects/ROCKNIX/packages/network/rclone/sources/cloud_restore
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ read_controller_input() {
echo "left"
elif [[ "$event_output" =~ BTN_DPAD_RIGHT.*value[[:space:]]+1 ]] || [[ "$event_output" =~ ABS_HAT0X.*value[[:space:]]+1 ]]; then
echo "right"
elif [[ "$event_output" =~ BTN_SOUTH.*value[[:space:]]+1 ]] || [[ "$event_output" =~ BTN_A.*value[[:space:]]+1 ]] || [[ "$event_output" =~ "code 0.*value[[:space:]]+1" ]] || [[ "$event_output" =~ BTN_EAST.*value[[:space:]]+1 ]]; then
elif [[ "$event_output" =~ BTN_SOUTH.*value[[:space:]]+1 ]] || [[ "$event_output" =~ BTN_A.*value[[:space:]]+1 ]] || [[ "$event_output" =~ BTN_EAST.*value[[:space:]]+1 ]]; then
echo "confirm"
elif [[ "$event_output" =~ BTN_B.*value[[:space:]]+1 ]] || [[ "$event_output" =~ "code 1.*value[[:space:]]+1" ]]; then
elif [[ "$event_output" =~ BTN_B.*value[[:space:]]+1 ]]; then
echo "cancel"
elif [[ "$event_output" =~ BTN_START.*value[[:space:]]+1 ]]; then
echo "start"
Expand Down Expand Up @@ -342,6 +342,13 @@ load_config() {
RCLONEOPTS=$(echo "${RCLONEOPTS}" | sed 's/--verbose//g' | sed 's/-v / /g')
log_message "After removing verbose flags: ${RCLONEOPTS}" "false"

# Restore writes to local storage. The filter rules are an allowlist, so with
# RESTOREMETHOD="sync" a --delete-excluded would delete everything local that
# is not a save/state/screenshot (ROMs, BIOS, artwork). Strip it on restore;
# backup keeps it, where it only tidies the remote.
RCLONEOPTS=$(echo "${RCLONEOPTS}" | sed 's/--delete-excluded//g')
log_message "After removing restore-unsafe delete flags: ${RCLONEOPTS}" "false"

RCLONEOPTS=$(echo "${RCLONEOPTS}" | sed 's/--/ --/g' | sed 's/^ //')
log_message "After spacing fix: ${RCLONEOPTS}" "false"

Expand All @@ -354,7 +361,6 @@ load_config() {
RCLONE_OPTS_ARRAY+=("$opt")
done
log_message "Options array has ${#RCLONE_OPTS_ARRAY[@]} elements" "false"
RESTORE_RCLONEOPTS=$(echo "${RCLONEOPTS}" | sed 's/--delete-excluded//')
log_message "Configuration loaded successfully" "false"
}

Expand All @@ -373,7 +379,7 @@ report_rclone_error() {
6) log_message "${operation} failed: Less serious errors (e.g. partly transferred)" "true" "WARN" ;;
7) log_message "${operation} failed: Fatal error - rclone giving up" "true" "ERROR" ;;
8) log_message "${operation} failed: Transfer exceeded - limits exceeded" "true" "ERROR" ;;
9) log_message "${operation} failed: Operation failed - no retry" "true" "ERROR" ;;
9) log_message "${operation} completed: no files transferred" "true" ;;
*) log_message "${operation} failed with unknown error code: $exit_code" "true" "ERROR" ;;
esac
}
Expand Down Expand Up @@ -435,7 +441,7 @@ restore_game_saves() {
mkdir -p "${RESTOREPATH}"
fi

# Set log level to DEBUG when INFO is selected for enhanced logging
# Pass an explicit --log-level INFO when LOG_LEVEL is INFO
local rclone_debug=""
local filtered_opts=("${RCLONE_OPTS_ARRAY[@]}")

Expand All @@ -461,10 +467,16 @@ restore_game_saves() {
all_opts+=("$rclone_debug" "INFO")
fi # Add exclusions
all_opts+=(
"--stats-one-line"
"--exclude=${BACKUPFOLDER}/**"
"--exclude=backups/**"
"--exclude=bios/**"
)

# Check if the rclone version supports the terminal width flag
if rclone help | grep -q progress-terminal-width; then
all_opts+=("--progress-terminal-width=80")
fi

# Execute rclone with enhanced error handling
execute_rclone_with_error_handling \
Expand Down
12 changes: 2 additions & 10 deletions projects/ROCKNIX/packages/network/rclone/sources/cloud_sync_helper
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,8 @@ update_cloud_sync_config() {
# No existing config file, create one with defaults
log_to_file "${log_file}" "No existing config file, creating from template"

# Create a basic user config from defaults
touch /storage/.config/cloud_sync.conf

# Process each default variable
while IFS='=' read -r key value; do
if [[ "$key" == DEFAULT_* ]]; then
var_name="${key#DEFAULT_}"
echo "${var_name}=${value}" >> /storage/.config/cloud_sync.conf
fi
done < /usr/config/cloud_sync.conf.defaults
# Strip the DEFAULT_ prefix; sed preserves multi-line backslash-continued values
sed 's/^DEFAULT_//' /usr/config/cloud_sync.conf.defaults > /storage/.config/cloud_sync.conf
fi

return 0
Expand Down
95 changes: 0 additions & 95 deletions projects/ROCKNIX/packages/network/rclone/sources/rclonectl

This file was deleted.

22 changes: 0 additions & 22 deletions projects/ROCKNIX/packages/network/rclone/sources/rsync-rules.conf

This file was deleted.

23 changes: 0 additions & 23 deletions projects/ROCKNIX/packages/network/rclone/sources/rsync.conf

This file was deleted.

4 changes: 0 additions & 4 deletions projects/ROCKNIX/packages/rocknix/autostart/001-setup
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ fi
### Clean up settings
sort_settings

### We do not want to mount the cloud drive on startup
### so we'll reset the mount option to 0.
set_setting clouddrive.mounted 0

### Set up the runtime directory.
if [ ! -d "/var/run/0-runtime-dir" ]
then
Expand Down
5 changes: 0 additions & 5 deletions projects/ROCKNIX/packages/rocknix/sources/post-update
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ then
cp /usr/config/iwd/* /storage/.cache/iwd/
fi

### Sync rsync configs
echo "Update rsync configuration files..." >>${LOG}
rsync --ignore-existing /usr/config/rsync-rules.conf /storage/.config/
rsync --ignore-existing /usr/config/rsync.conf /storage/.config/

### Add cloud sync-related files if missing
echo "Update cloud sync files..." >>${LOG}
if [ -x "/usr/bin/cloud_sync_helper" ]; then
Expand Down
Loading