Shadow-Here


Server : Apache
System : Linux methusalix2 3.16.0-11-amd64 #1 SMP Debian 3.16.84-1 (2020-06-09) x86_64
User : hios ( 1437)
PHP Version : 5.6.40-0+deb8u12
Disable Function : proc_close,proc_open,dl,shell_exec,passthru
Directory :  /usr/local/bin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :
Current File : //usr/local/bin/apx-phpmyadmin-update
#!/bin/bash

# definitions
path="/home/staff/phpMyAdmin/"
folder="phpMyAdmin-$1-all-languages"
packet="phpMyAdmin-$1-all-languages.tar.bz2"

usage(){
	echo '|------------------------------------------------'
	echo "| $0 version-nr"
	echo "| e.g. 2.11.8.1 will expand where necessary"
	echo "| to phpMyAdmin-2.11.8.1 or phpMyAdmin-2.11.8.1-all-languages.tar.bz2 etc"
	echo "|------------------------------------------------"
	exit 1
	}

# TODO ordentlich sanitation einbauen
if [ -z $1 ]; then
	usage
	exit 1
fi

# change to /staff
if ( ! cd $path ); then
	echo "cannot change to $path"
	echo "this location is mandatory! Abort"
	exit 1
fi
cd $path


# get the version from switch
if ( ! wget -P $path http://switch.dl.sourceforge.net/sourceforge/phpmyadmin/$packet ); then
	# fallback url
	if ( ! wget -P $path http://mesh.dl.sourceforge.net/sourceforge/phpmyadmin/$packet ); then
		# abort, cannot get from switch nor mesh
		echo "cannot fetch this version. abort"
		exit 1
	fi
fi

# unpack it
if ( ! tar xjf $path/$packet ); then
	echo "couldnt unpack this version. abort"
	exit 1
fi

# copy configs from old current to current
if ( ! cp $path/current/config.inc.php $path/$folder ); then
	echo "couldnt copy config to new version. abort"
	exit 1
fi

# secure the scripts folder
if ( ! chmod 0 $path/$folder/scripts ); then
	echo "WARNING: couldnt chmod 0 the scripts folder! continuing...."
fi

# switch the symlink
if ( ! rm current ); then
	echo "couldnt remove symlink. old version still used as current!"
	echo "check this! Abort."
	exit 1
fi

if ( ! ln -s $path/$folder current ); then
	echo "couldnt create new symlink, but the old on was allready removed!"
	echo "there is probably NO phpMyAdmin available now!"
	echo "abort"
	exit 1
fi

# --- done ---
echo "DONE. Please take a look via HTTP if everything is working fine"

Samx