[Koha] User instance-koha already exists
Wagner, Alexander
alexander.wagner at desy.de
Fri May 3 19:05:24 NZST 2024
Hi!
> Koha v. 22.05.16
>
> Removed an instance
> $koha-remove instance
>
> Then I tried to create an instance with the same name
>
> $koha-create --create-db instance
>
> It displayed the following message "User instance-koha already exists"
>
> How can I resolve this?
As I do this quite a bit during the setup procedures in our migration, I found that this usually seems to result from a job that did not yet finish when the instance is removed or that is just running interactively and I forgot about it. `koha-shell`, `koha-mysql` in some other tmux-window come to mind. (Usually, during removal I also get some complaint further down the stream as well.)
Anyway, what you have left is a _Unix_ user named like your instance. So, `deluser` (on Debian) is your friend to get rid of the user once all jobs of said user are finished/closed.
Btw: The following function is from the j2k-setup script. Feel free to cannibalize what you need to avoid this issue in the future.
```bash
koharemove() {
echo "************************************************************"
echo "* Start R E M O V E *"
echo "************************************************************"
# The following needs root rights!
# Remove a koha-instance from the system
# Mind that we need to stop all processes running by the instances
# user _first_ or we end up in some messy state
j2kshowconfig
for (( i=5; i > 0; i-- )); do
echo -n " $i "
sleep 1
done
echo -n " [ GO ] "
echo ""
echo "Disabling sites and shutting down ..."
sudo service apache2 stop
echo "Killing common interactive shells ..."
sudo killall -9 koha-mysql
sudo killall -9 koha-shell
echo "Stopping koha services ..."
sudo koha-zebra --stop $kohalibname
sudo koha-indexer --stop $kohalibname
sudo koha-worker --stop $kohalibname
echo -n "Waiting for background jobs to settle down"
for (( i=10; i > 0; i-- )); do
echo -n " $i "
sleep 1
done
echo ""
sudo service memcached stop
sudo a2dissite $kohalibname
echo "Removing $kohalibname ..."
sudo koha-remove $kohalibname
echo "Removing j2k created files and dirs ..."
sudo rm /usr/share/keyrings/koha-keyring.gpg
sudo rm /etc/apt/sources.list.d/koha.list
sudo rm -rf $j2kbin
sudo rm -rf $j2ketc
sudo rm -rf $j2kopac
sudo rm -rf $kohaopac/htdocs/j2ktheme
# echo '(Re)starting servers with default settings ...'
sudo service memcached start
sudo service apache2 start
}
```
--
Kind regards,
Alexander Wagner
Deutsches Elektronen-Synchrotron DESY
Library and Documentation
Building 01d Room OG1.444
Notkestr. 85
22607 Hamburg
phone: +49-40-8998-1758
e-mail: alexander.wagner at desy.de
More information about the Koha
mailing list