Files
debian-web-server/bin/_addUserSite.sh
T
bachirandClaude Sonnet 5 7ff4df1173 Fix installer bugs: broken root checks, PHP version mismatches, dead paths
- Replace $EUID with $(id -u) for root checks across all bin/*.sh and
  install.sh: dash (Debian's /bin/sh) never sets $EUID, so the check was
  silently broken everywhere.
- lemp.sh: make apt-get upgrade non-interactive (--yes), align the Redis
  PHP module and php-fpm restart with $PHP_VERSION instead of a hardcoded
  8.1, and template the nginx PHP-FPM socket path via a PHP_FPM_SOCK
  placeholder substituted at install time.
- nginx-phpmyadmin.conf: fix docroot to match the actual phpMyAdmin
  symlink location created by lemp.sh.
- mysql-db.sh: inline the root check instead of sourcing the
  nonexistent bin/checkroot.sh.
- webhook.sh: fix chowm typo (chown).
- urbackup.sh: copy the systemd unit from assets/ instead of a relative
  path to a file that doesn't exist in the repo.
- _addUserSite.sh: fix invalid `$var=value` assignment and an empty
  if-block that was a POSIX sh syntax error.

Also carries over pending fixes to deploy-drupal.sh (drush now
invoked via vendor/bin/drush) and gitbarrerepos.sh (comment cleanup).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-04 09:28:08 +02:00

129 lines
2.9 KiB
Bash
Executable File

#!/bin/sh
# bachir soussi chiadmi
# TODO check if root
echo -e '\033[35m
__ _______ __________
/ / / / ___// ____/ __ \
/ / / /\__ \/ __/ / /_/ /
/ /_/ /___/ / /___/ _, _/
\____//____/_____/_/ |_|
\033[0m'
echo -e "\033[35;1mCreate new user (you will be asked a user name and a password) \033[0m"
sleep 3
while [ "$user" = "" ]
do
read -p "Enter user name: " user
if [ "$user" != "" ]; then
read -p "is user $user correcte [y|n] " validated
if [ "$validated" = "y" ]; then
break
else
user=""
fi
fi
done
adduser "$user"
mkdir /home/$user/logs
mkdir /home/$user/public_html
mkdir /home/$user/backups
chmod -w /home/"$user"
echo -e '\033[35m
__ __
_ __/ /_ ____ _____/ /_
| | / / __ \/ __ \/ ___/ __/
| |/ / / / / /_/ (__ ) /_
|___/_/ /_/\____/____/\__/
\033[0m'
echo -e "\033[35;1mVHOST install \033[0m"
while [ "$_host_name" = "" ]
do
read -p "enter a hostname ? " _host_name
if [ "$_host_name" != "" ]; then
read -p "is hostname $_host_name correcte [y|n] " validated
if [ "$validated" = "y" ]; then
break
else
_host_name=""
fi
fi
done
#set proper right to user will handle the app
chown -R "$user":admin /home/"$user"/public_html
chown -R "$user":admin /home/"$user"/logs
chown -R "$user":admin /home/"$user"/backups
chmod -R g+wr /home/"$user"/public_html
chmod -R g+wr /home/"$user"/logs
mkdir -p /var/www/"$_host_name"
ln -s /home/"$user"/public_html /var/www/"$_host_name"/public_html
ln -s /home/"$user"/logs /var/www/"$_host_name"/logs
# TODO create nginx vhost
# cp "$_cwd"/assets/example.org.conf /etc/apache2/sites-available/"$_host_name".conf
# sed -i -r "s/example\.org/$_host_name/g" /etc/apache2/sites-available/"$_host_name".conf
#activate the vhost
# a2ensite "$_host_name".conf
#restart apache
# service apache2 restart
echo -e "\033[92;1mvhost $_host_name configured\033[Om"
# todo add mysql user and database
echo -e '\033[35m
__ ___ __
/ |/ /_ ___________ _/ /
/ /|_/ / / / / ___/ __ `/ /
/ / / / /_/ (__ ) /_/ / /
/_/ /_/\__, /____/\__, /_/
/____/ /_/
\033[0m'
echo -e "\033[35;1mMysql database \033[0m"
while [ "$_dbname" = "" ]
do
read -p "enter a database name ? " _dbname
if [ "$_dbname" != "" ]; then
read -p "is database name $_dbname correcte [y|n] " validated
if [ "$validated" = "y" ]; then
break
else
_dbname=""
fi
fi
done
passok=0
while [ "$passok" = "0" ]
do
echo -n "Write database password for $user"
read passwda
echo -n "confirm password"
read passwdb
if [ "$passwda" = "$passwdb" ]; then
_pswd=$passwda
passok=1
else
echo "pass words don't match, please try again"
fi
done
if [ "$passok" = 1 ]; then
# TODO: not implemented yet, run manually for now:
# mysql> create user '$_dbname'@'localhost' identified by '$_pswd';
# mysql> create database $_dbname;
# mysql> grant all privileges on esadhar_eval.* to 'esadhar_eval'@'localhost';
# mysql> flush privileges;
:
fi