@@ -98,9 +98,15 @@ function install_configuration_file {
9898function install_main_program {
9999 # copy source to target with executable permissions
100100 # install to target, with hardcoded version
101- trysudo sed -E " s/^VERSION=.*/VERSION=$VERSION /" " $SOURCE " > " $TARGET "
102- # allow execute permissions
101+ if [[ -f " $TARGET " ]]; then
102+ trysudo rm " $TARGET "
103+ fi
104+ trysudo cp " $SOURCE " " $TARGET "
105+ trysudo sed -E " s/^VERSION=.*/VERSION=$VERSION /" -i " $TARGET "
106+ # allow execute permissions with group
103107 trysudo chmod +x " $TARGET "
108+ # make sure non-root user is owner
109+ trysudo chown " $USER " " $TARGET "
104110 echo " Installed: $TARGET "
105111}
106112
@@ -114,9 +120,17 @@ function install_cpp_program {
114120 # compile program to temporary file first
115121 TMP_TARGET=" $( mktemp) "
116122 $COMPILE " $COMPILE_SOURCE " -o " $TMP_TARGET " -DCOMFORTABLE_SWIPE_VERSION=" \" $VERSION \" " -DCOMFORTABLE_SWIPE_CONFIG=" \" $CONF_TARGET \" " -DCOMFORTABLE_SWIPE_AUTOSTART=" \" $AUTOSTART_TARGET \" "
117- # compilation ok, now try to install
118- # check permissions maybe if will need sudo
123+ # compilation ok, now try to install with sudo
124+ trysudo mkdir -p " $( dirname " $COMPILE_TARGET " ) "
125+ # remove existing file for permissions to work
126+ if [[ -f " $COMPILE_TARGET " ]]; then
127+ sudo rm " $COMPILE_TARGET "
128+ fi
119129 trysudo mv " $TMP_TARGET " " $COMPILE_TARGET "
130+ # bugfix: add with group permissions
131+ trysudo chmod go+x " $COMPILE_TARGET "
132+ # make sure non-root user is owner
133+ trysudo chown " $USER " " $COMPILE_TARGET "
120134 echo " Installed: $COMPILE_TARGET "
121135}
122136
@@ -127,6 +141,7 @@ function install_cpp_program {
127141# /home/$USER/.config/autostart/comfortable-swipe.desktop
128142#
129143function install_autostart {
144+ mkdir -p " $( dirname " $AUTOSTART_TARGET " ) "
130145 cat " $AUTOSTART_SOURCE " > " $AUTOSTART_TARGET "
131146 echo " Installed: $AUTOSTART_TARGET "
132147}
0 commit comments