F
F
fokin_nikolay19892016-10-14 17:36:37
bash
fokin_nikolay1989, 2016-10-14 17:36:37

How to make a file run as root?

Good day,
I wrote a button to start updating certificates and encountered such a problem
Launch button
nano /usr/share/applications/certcopy.desktop

[Desktop Entry]
Version=1.0
Name=Обновление сертификатов
Exec=/etc/certupdate
Terminal=true
Type=Application
StartupNotify=true
#Categories=X-Red-Hat-Extra;Application;Development;
Categories=System;Security;Settings;
X-Desktop-File-Install-Version=0.15
Icon=/usr/local/eclipse/icon.xpm

The /etc/certupdate file itself
starts installing certificates
#!/bin/bash

echo ================================================================================
echo "           УСТАНОВКА КОРНЕВЫХ И СПИСКОВ ОТОЗВАННЫХ СЕРТИФИКАТОВ"
echo ================================================================================

cd /opt/cprocsp/bin/*/
rm *.crl* 2> /dev/null
rm *.cer* 2> /dev/null

cp -r /mnt//cer/* /opt/cprocsp/bin/*/
echo

if ; then
echo --------------------------------------------------------------------------------
echo -e "	Корневой сертификат (2013)             \e[1;32m[OK]\e[0m"
echo --------------------------------------------------------------------------------
./certmgr -inst -store root -file cacer.cer | grep "Not valid"
else
err=$(./certmgr -inst -store root -file cacer.cer | grep "Error")
echo --------------------------------------------------------------------------------
echo -e "       Корневой сертификат (2013)           \e[31m[ERROR]\e[0m"
echo --------------------------------------------------------------------------------
echo $err
fi

if ; then
echo --------------------------------------------------------------------------------
echo -e "	Корневой сертификат (2015)             \e[1;32m[OK]\e[0m"
echo --------------------------------------------------------------------------------
./certmgr -inst -store root -file cacernew_2015.cer | grep "Not valid"
else
err=$(./certmgr -inst -store root -file cacernew_2015.cer | grep "Error")
echo --------------------------------------------------------------------------------
echo -e "	Корневой сертификат (2015)           \e[31m[ERROR]\e[0m"
echo --------------------------------------------------------------------------------
echo $err
fi

But he does not want to install certificates, he writes a failure on everything, how can I run and install from under the user

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rou1997, 2016-10-14
@Rou1997

Run the command first su.

P
Pavel, 2016-10-16
@pbt39

try one of these commands:
you will need to enter the password of the current user (if it is specified in sudoers)
you will need to enter the root password.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question